/* * File for setting the properties of a new SIS3610 device to * default values. * */ #include <tango.h> using namespace Tango; main(unsigned int argc, char **argv) { // // create a connection to the new SIS3610 IO Register TANGO device // DeviceProxy *device = new DeviceProxy( "tango://has107k:10000/exp/line1/mcs1"); // Write default values to properties unsigned long base = 65536; long max_nb_channels = 32; long max_nb_acquisitions = 1000; DbDatum base_toput("Base"), max_nb_channels_toput("MaxNbChannels"); DbDatum max_nb_acquisitions_toput("MaxNbAcquisitions"); DbData db_data; base_toput << base; max_nb_channels_toput << max_nb_channels; max_nb_acquisitions_toput << max_nb_acquisitions; db_data.push_back(base_toput); db_data.push_back(max_nb_channels_toput); db_data.push_back(max_nb_acquisitions_toput); device->put_property(db_data); }
Example how to operate the Multi Channel Scaler and extract the readout values
/* * example of a client using the TANGO C++ api. */ #include <tango.h> using namespace Tango; main(unsigned int argc, char **argv) { unsigned long temp; float out; DeviceAttribute da; long nb_channels; long nb_acquisitions; // // create a connection to a TANGO device // DeviceProxy *device = new DeviceProxy( "tango://has107k:10000/exp/line1/mcs1"); // Read maximum nb of channels and acquisitions DbData prop; prop.push_back(DbDatum("MaxNbChannels")); prop.push_back(DbDatum("MaxNbAcquisitions")); device->get_property(prop); long max_nb_channels; long max_nb_acquisitions; prop[0] >> max_nb_channels; prop[1] >> max_nb_acquisitions; cout << "Max Nb Channels " << max_nb_channels << " Max Nb Acquisitions " << max_nb_acquisitions << endl; // Set Preset, number of channels and number of acquisitions DeviceAttribute *da_write1 = new DeviceAttribute( "Preset", (long)100); device->write_attribute(*da_write1); DeviceAttribute *da_write2 = new DeviceAttribute( "NbChannels", (long)4); device->write_attribute(*da_write2); DeviceAttribute *da_write3 = new DeviceAttribute( "NbAcquisitions", (long)10); device->write_attribute(*da_write3); // Read NbChannels and NbAcquisitions da = device->read_attribute("NbChannels"); da >> nb_channels; da = device->read_attribute("NbAcquisitions"); da >> nb_acquisitions; cout << "Number of active channels " << nb_channels << " Number of acquisitions " << nb_acquisitions << endl; // Execute setupmcs and readmcs (readmcs executes setupmcs case it was not // executed before) device->command_inout( "SetupMCS"); device->command_inout( "ReadMCS"); // Read channels vector<long> readout; long counts[nb_channels][nb_acquisitions]; da = device->read_attribute("CountsArray"); da >> readout; int k =0; for(int j = 0; j < (nb_acquisitions) ; j++){ for(int i= 0; i < nb_channels; i++){ counts[i][j] = readout[k]; k++; } } }
Example how to operate the Multi Channel Analyzer triggered externally by the Zebra box
The cable connected to the output of the Zebra box with the trigger pulses has to be plugin in the first channel of the MCS.
A full example for running the MCS with Zebra triggers via a spock macro is shown in the sardana documentation. Here a sequence of the actions to be performed is shown.
# Set the zebra device zebra_device.NbTriggers = nb_triggers zebra_device.TriggerInterval = trigger_interval # Set MCS mcs_device.NbAcquisitions = 0 # Continuous mode mcs_device.NbChannels = nb_mcs_channels mcs_device.Preset = 1 # every trigger is used nb_mcs_taken_triggers = nb_triggers # Clear and setup mcs mcs_device.ClearSetupMCS() # Start zebra triggering zebra_device.Arm = 1 # Check when the triggering is done while zebra_device.State() == PyTango.DevState.MOVING: time.sleep(1) # Read MCS mcs_device.ReadMCS() # MCS Data mcs_data = mcs_device.CountsArray # Zebra encoder Data zebra_data = zebra_device.EncoderSpectrum