Adding Alarms in MIDAS
From tigwiki
In frontend.c provided with the TempControl package...
Starting from the top, under the comment /* number of channels */, N_there is the constant that determines the number of data values returned to MIDAS, which is equal to the total number of channels that the acquisition unit (Agilent 34970A) has. The array resp[512] is the array that is used by the function rs_gets(port,resp,sizeof(resp)) to store values that are in the unit's buffer. It is initialized to zero so that if a channel's value is exactly 0.0, that means it was never read, i.e. it is not in use. channelList[] is an array that holds the channel numbers that are actually to be read. Since only channels in this list are configured and read, the acquiring process is made more efficient than reading every channel's value. Channel's in this list do not need to be in order from smallest to largest, however, it is just neater to list them this way.
Skipping down past the structure used by MIDAS to characterise this experiment, under the comment /*hardware initialization*/, rs232_init sets the parameters of the serial port, which need to match those of the device. The meaning of the arguments can be determined by looking at the function in the file rs232.c that is provided as well in the package. The part of the program that is most likely to be edited is under the comment //Scan List Initialization. The command rs232_puts(hDev, “CONF:VOLT: DC (@104:115)\r\n”);, tells the unit to configure channels 4-15 of module 1 to read a DC voltage. If any configuration changes are to be made, it is here. The user's manual contains all the different commands that the unit will respond to. After all the channels have been configured as desired, the scan list needs to be established with the command rs232_puts(hDev, “ROUT:SCAN (@101:115)\r\n”). This command assigns channels 1 – 15 to the scan list, which means that 16 - 22 are not used.
Now, in the function read_ther_event, an array called SPURIOUS[] contains a list of the spurious measurement limits of all the channels. The key here is that the order in which the limits are written DOES matter. The first element of the array corresponds to module 1 channel 01, the second corresponds to module 1 channel 02. Most important is that if the scan list contains channels 1,3,4,5, the array SPURIOUS array must contain a value for channel 02 as well even though it isn't used! It doesn't matter what it is, but there must be a number there.
For example, say channel 01 and channel 03 read a voltage between 1-5Vdc so the spurious limit should be 5.5Vdc perhaps. If these are the only channels being used, the scan list should be altered to only read channels 01 and 03 and the array channelList[] should only contain the numbers 101 and 103. The array SPURIOUS[], however, should take the form, SPURIOUS[] = {5.5, 100, 5.5}. 100 is just the number chosen to be a place holder for the spurious limit of channel 02 even though it is not being used.

