Low-Energy Muon (LEM) Experiment
0.5.1
|
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "midas.h"
#include "msystem.h"
#include "mscb.h"
#include "scs900.h"
#include "lemSCWatchdog.h"
Go to the source code of this file.
Data Structures | |
struct | SCS900_SETTINGS |
Stores all the parameters the device driver needs. More... | |
struct | SCS900_INFO |
This structure contains private variables for the device driver. More... | |
Macros | |
#define | SCS900_INIT_ERROR -2 |
tag: initializing error More... | |
#define | SCS900_MSCB_DEBUG FALSE |
MSCB debug flag. More... | |
#define | SCS900_NOVARS 51 |
number of variables of the SCS900 More... | |
#define | SCS900_DAC_OFFSET 8 |
offset for the DAC channels More... | |
#define | SCS900_SETTINGS_STR "\Detailed Messages = INT : 0\n\SCW_IN_USE = INT : 0\n\Read Period (sec) = INT : 1\n\DD Name = STRING : [32] SCS900\n\MSCB Port = STRING : [32] usb0\n\MSCB Pwd = STRING : [32] \n\Group Addr = INT : 1\n\Node Addr = INT : 1\n\Error Timeout = INT : 3600\n\Error Log = STRING : [128] \n\ADC Name = STRING[8] : \n\[32] ADC0\n\[32] ADC1\n\[32] ADC2\n\[32] ADC3\n\[32] ADC4\n\[32] ADC5\n\[32] ADC6\n\[32] ADC7\n\DAC Name = STRING[8] : \n\[32] DAC0\n\[32] DAC1\n\[32] DAC2\n\[32] DAC3\n\[32] DAC4\n\[32] DAC5\n\[32] DAC6\n\[32] DAC7\n\" |
Initializing string for the struct SCS900_SETTINGS. More... | |
#define | SCS900_SCW_STR "\Proc Name = STRING : [32]\n\PID = INT : -1\n\Log Name = STRING : [64]\n\DD Name = STRING : [32] scs900\n\Last Updated = DWORD : 0\n\Timeout = DWORD : 180\n\" |
defines the slowcontrol default watchdog info structure More... | |
Functions | |
INT | scs900_in_init (HNDLE hKey, void **pinfo, INT channels) |
INT | scs900_out_init (HNDLE hKey, void **pinfo, INT channels) |
INT | scs900_exit (SCS900_INFO *info) |
INT | scs900_set (SCS900_INFO *info, INT channel, float value) |
INT | scs900_get_in_label (SCS900_INFO *info, INT channel, char *name) |
INT | scs900_get_out_label (SCS900_INFO *info, INT channel, char *name) |
float | scs900_mscb_to_float (char *data, int index) |
INT | scs900_get (SCS900_INFO *info, INT channel, float *pvalue) |
INT | scs900_in (INT cmd,...) |
INT | scs900_out (INT cmd,...) |
Variables | |
SCS900_INFO * | info |
global info structure, in/out-init routines need the same structure More... | |
#define SCS900_DAC_OFFSET 8 |
offset for the DAC channels
Definition at line 36 of file scs900.c.
Referenced by scs900_in_init(), and scs900_set().
#define SCS900_INIT_ERROR -2 |
#define SCS900_MSCB_DEBUG FALSE |
#define SCS900_NOVARS 51 |
number of variables of the SCS900
Definition at line 35 of file scs900.c.
Referenced by scs900_in_init().
#define SCS900_SCW_STR "\Proc Name = STRING : [32]\n\PID = INT : -1\n\Log Name = STRING : [64]\n\DD Name = STRING : [32] scs900\n\Last Updated = DWORD : 0\n\Timeout = DWORD : 180\n\" |
defines the slowcontrol default watchdog info structure
Definition at line 87 of file scs900.c.
Referenced by scs900_in_init().
#define SCS900_SETTINGS_STR "\Detailed Messages = INT : 0\n\SCW_IN_USE = INT : 0\n\Read Period (sec) = INT : 1\n\DD Name = STRING : [32] SCS900\n\MSCB Port = STRING : [32] usb0\n\MSCB Pwd = STRING : [32] \n\Group Addr = INT : 1\n\Node Addr = INT : 1\n\Error Timeout = INT : 3600\n\Error Log = STRING : [128] \n\ADC Name = STRING[8] : \n\[32] ADC0\n\[32] ADC1\n\[32] ADC2\n\[32] ADC3\n\[32] ADC4\n\[32] ADC5\n\[32] ADC6\n\[32] ADC7\n\DAC Name = STRING[8] : \n\[32] DAC0\n\[32] DAC1\n\[32] DAC2\n\[32] DAC3\n\[32] DAC4\n\[32] DAC5\n\[32] DAC6\n\[32] DAC7\n\" |
Initializing string for the struct SCS900_SETTINGS.
Definition at line 55 of file scs900.c.
Referenced by scs900_in_init().
INT scs900_exit | ( | SCS900_INFO * | info | ) |
terminates the MSCB and free's the memory allocated for the info structure SCS900_INFO.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
Definition at line 268 of file scs900.c.
References SCS900_INFO::fd, SCS900_INFO::scw, SCS900_SETTINGS::scw_in_use, SCS900_INFO::settings, and SCS900_INFO::startup_error.
Referenced by scs900_in().
INT scs900_get | ( | SCS900_INFO * | info, |
INT | channel, | ||
float * | pvalue | ||
) |
Reads a value from the scs900
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | to be read back |
pvalue | pointer to the ODB value |
Definition at line 395 of file scs900.c.
References SCS900_SETTINGS::dd_name, SCS900_SETTINGS::detailed_msg, SCS900_SETTINGS::err_log, SCS900_SETTINGS::err_timeout, SCS900_INFO::errcount, SCS900_INFO::fd, SCS900_INFO::input_buffer, SCS900_INFO::lasterrtime, SCS900_SETTINGS::node_addr, SCS900_INFO::present_value, SCS900_INFO::previous_value, SCS900_SETTINGS::read_timeout, SCS900_INFO::read_timer, SCS900_INIT_ERROR, scs900_mscb_to_float(), SCS900_INFO::scw, SCS900_SETTINGS::scw_in_use, SCS900_INFO::settings, and SCS900_INFO::startup_error.
Referenced by scs900_in().
INT scs900_get_in_label | ( | SCS900_INFO * | info, |
INT | channel, | ||
char * | name | ||
) |
at startup, after initialization of the DD, this routine allows to write default names into the ODB.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | of the name to be set |
name | pointer to the ODB name |
Definition at line 341 of file scs900.c.
References SCS900_SETTINGS::adc_name, and SCS900_INFO::settings.
Referenced by scs900_in().
INT scs900_get_out_label | ( | SCS900_INFO * | info, |
INT | channel, | ||
char * | name | ||
) |
at startup, after initialization of the DD, this routine allows to write default names into the ODB.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | of the name to be set |
name | pointer to the ODB name |
Definition at line 358 of file scs900.c.
References SCS900_SETTINGS::dac_name, and SCS900_INFO::settings.
Referenced by scs900_out().
INT scs900_in | ( | INT | cmd, |
... | |||
) |
MIDAS device driver for the SCS900 MSCB ADC/DAC card (input channels).
Definition at line 475 of file scs900.c.
References hKey, info, scs900_exit(), scs900_get(), scs900_get_in_label(), and scs900_in_init().
INT scs900_in_init | ( | HNDLE | hKey, |
void ** | pinfo, | ||
INT | channels | ||
) |
Initializes the SCS900 device driver, i.e. generates all the necessary structures in the ODB if necessary, initializes the MSCB and the checks if the addressed device is consistent with a SCS900.
Return:
hKey | is the device driver handle given from the class driver |
pinfo | is needed to store the internal info structure |
channels | is the number of channels of the device (from the class driver) |
Definition at line 127 of file scs900.c.
References SCS900_INFO::dac_width, SCS900_SETTINGS::dd_name, SCS900_INFO::errcount, SCS900_INFO::fd, hDB, info, SCS900_INFO::lasterrtime, SCS900_SETTINGS::node_addr, SCS900_SETTINGS::port, SCS900_SETTINGS::pwd, SCS900_INFO::read_timer, SCS900_DAC_OFFSET, SCS900_MSCB_DEBUG, SCS900_NOVARS, SCS900_SCW_STR, SCS900_SETTINGS_STR, SCS900_INFO::scw, SCS900_SETTINGS::scw_in_use, SCS900_INFO::settings, and SCS900_INFO::startup_error.
Referenced by scs900_in().
float scs900_mscb_to_float | ( | char * | data, |
int | index | ||
) |
Converts mscb bytes into a valid float
data | |
index |
Definition at line 371 of file scs900.c.
Referenced by scs900_get().
INT scs900_out | ( | INT | cmd, |
... | |||
) |
MIDAS device driver for the SCS900 MSCB ADC/DAC card (output channels).
Definition at line 527 of file scs900.c.
References hKey, info, scs900_get_out_label(), scs900_out_init(), and scs900_set().
INT scs900_out_init | ( | HNDLE | hKey, |
void ** | pinfo, | ||
INT | channels | ||
) |
Passes the info pointer to the class driver. All the rest is done in scs900_in_init.
Return:
hKey | is the device driver handle given from the class driver |
pinfo | is needed to store the internal info structure |
channels | is the number of channels of the device (from the class driver) |
Definition at line 248 of file scs900.c.
Referenced by scs900_out().
INT scs900_set | ( | SCS900_INFO * | info, |
INT | channel, | ||
float | value | ||
) |
sets the values of the SCS900.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | to be set |
value | to be sent to the SCS900 |
Definition at line 292 of file scs900.c.
References SCS900_INFO::dac_width, SCS900_SETTINGS::dd_name, SCS900_SETTINGS::err_log, SCS900_INFO::errcount, SCS900_INFO::fd, SCS900_SETTINGS::node_addr, SCS900_DAC_OFFSET, SCS900_INFO::settings, and SCS900_INFO::startup_error.
Referenced by scs900_out().
SCS900_INFO* info |