Low-Energy Muon (LEM) Experiment  0.5.1
hvr400.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include "midas.h"
#include "msystem.h"
#include "mscb.h"
#include "hvr400.h"
#include "lemSCWatchdog.h"
Include dependency graph for hvr400.c:

Go to the source code of this file.

Data Structures

struct  HVR400_SETTINGS
 
struct  HVR400_NODE_VARS
 
struct  HVR400_INFO
 This structure contains private variables for the device driver. More...
 

Macros

#define HVR400_INIT_ERROR   -2
 tag: initializing error More...
 
#define HVR400_MAX_ERROR   5
 maximum number of error messages More...
 
#define HVR400_DELTA_TIME_ERROR   600
 reset error counter after DELTA_TIME_ERROR seconds More...
 
#define MSCB_DEBUG   FALSE
 MSCB debug flag. More...
 
#define HVR400_CONTROL   0
 
#define HVR400_VDEMAND   1
 
#define HVR400_VMEAS   2
 
#define HVR400_IMEAS   3
 
#define HVR400_STATUS   4
 
#define HVR400_TRIPCNT   5
 
#define HVR400_RAMPUP   6
 
#define HVR400_RAMPDOWN   7
 
#define HVR400_VLIMIT   8
 
#define HVR400_ILIMIT   9
 
#define HVR400_RILIMIT   10
 
#define HVR400_TRIPMAX   11
 
#define HVR400_TRIPTIME   12
 
#define HVR400_CTRL_HV_ON   0x01
 
#define HVR400_CTRL_REGULATION   0x02
 
#define HVR400_CTRL_IDLE   0x04
 
#define HVR400_SETTINGS_STR   "\Enabled = BOOL : 0\n\SCW_IN_USE = BOOL : 0\n\Detailed Messages = INT : 0\n\MSCB Port = STRING : [32] usb1\n\MSCB Pwd = STRING : [32]\n\Group Addr = INT : 400\n\Node Addr = INT : 1\n\HVR400 Name = STRING : [32] HVR400_1\n\HV ODB Offset = INT : 0\n\"
 Initializing string for the struct HVR400_SETTINGS. More...
 
#define HVR400_SCW_STR   "\Proc Name = STRING : [32]\n\PID = INT : -1\n\Log Name = STRING : [64]\n\DD Name = STRING : [32] \n\Last Updated = DWORD : 0\n\Timeout = DWORD : 180\n\"
 defines the slowcontrol default watchdog info structure More...
 

Functions

INT hvr400_read_all (HVR400_INFO *info, int channel)
 
INT hvr400_init (HNDLE hKey, void **pinfo, INT channels)
 
INT hvr400_exit (HVR400_INFO *info)
 
INT hvr400_set (HVR400_INFO *info, INT channel, float value)
 
INT hvr400_get (HVR400_INFO *info, INT channel, float *pvalue)
 
INT hvr400_set_current_limit (HVR400_INFO *info, INT channel, float limit)
 
INT hvr400_set_voltage_limit (HVR400_INFO *info, INT channel, float limit)
 
INT hvr400_set_rampup (HVR400_INFO *info, INT channel, float ramp)
 
INT hvr400_set_rampdown (HVR400_INFO *info, INT channel, float ramp)
 
INT hvr400_set_triptime (HVR400_INFO *info, INT channel, float trip_time)
 
INT hvr400 (INT cmd,...)
 

Macro Definition Documentation

#define HVR400_CONTROL   0

Definition at line 36 of file hvr400.c.

Referenced by hvr400_get(), and hvr400_set().

#define HVR400_CTRL_HV_ON   0x01

Definition at line 51 of file hvr400.c.

Referenced by hvr400_set().

#define HVR400_CTRL_IDLE   0x04

Definition at line 53 of file hvr400.c.

#define HVR400_CTRL_REGULATION   0x02

Definition at line 52 of file hvr400.c.

Referenced by hvr400_set().

#define HVR400_DELTA_TIME_ERROR   600

reset error counter after DELTA_TIME_ERROR seconds

Definition at line 29 of file hvr400.c.

Referenced by hvr400_get(), hvr400_set_current_limit(), hvr400_set_rampdown(), hvr400_set_rampup(), hvr400_set_triptime(), and hvr400_set_voltage_limit().

#define HVR400_ILIMIT   9

Definition at line 45 of file hvr400.c.

Referenced by hvr400_set_current_limit().

#define HVR400_IMEAS   3

Definition at line 39 of file hvr400.c.

Referenced by hvr400_get().

#define HVR400_INIT_ERROR   -2

tag: initializing error

Definition at line 26 of file hvr400.c.

Referenced by hvr400_get().

#define HVR400_MAX_ERROR   5

maximum number of error messages

Definition at line 28 of file hvr400.c.

Referenced by hvr400_get().

#define HVR400_RAMPDOWN   7

Definition at line 43 of file hvr400.c.

Referenced by hvr400_set_rampdown().

#define HVR400_RAMPUP   6

Definition at line 42 of file hvr400.c.

Referenced by hvr400_set_rampup().

#define HVR400_RILIMIT   10

Definition at line 46 of file hvr400.c.

#define HVR400_SCW_STR   "\Proc Name = STRING : [32]\n\PID = INT : -1\n\Log Name = STRING : [64]\n\DD Name = STRING : [32] \n\Last Updated = DWORD : 0\n\Timeout = DWORD : 180\n\"

defines the slowcontrol default watchdog info structure

Definition at line 123 of file hvr400.c.

Referenced by hvr400_init().

#define HVR400_SETTINGS_STR   "\Enabled = BOOL : 0\n\SCW_IN_USE = BOOL : 0\n\Detailed Messages = INT : 0\n\MSCB Port = STRING : [32] usb1\n\MSCB Pwd = STRING : [32]\n\Group Addr = INT : 400\n\Node Addr = INT : 1\n\HVR400 Name = STRING : [32] HVR400_1\n\HV ODB Offset = INT : 0\n\"

Initializing string for the struct HVR400_SETTINGS.

Definition at line 71 of file hvr400.c.

Referenced by hvr400_init().

#define HVR400_STATUS   4

Definition at line 40 of file hvr400.c.

#define HVR400_TRIPCNT   5

Definition at line 41 of file hvr400.c.

#define HVR400_TRIPMAX   11

Definition at line 47 of file hvr400.c.

#define HVR400_TRIPTIME   12

Definition at line 48 of file hvr400.c.

Referenced by hvr400_set_triptime().

#define HVR400_VDEMAND   1

Definition at line 37 of file hvr400.c.

Referenced by hvr400_set().

#define HVR400_VLIMIT   8

Definition at line 44 of file hvr400.c.

Referenced by hvr400_set_voltage_limit().

#define HVR400_VMEAS   2

Definition at line 38 of file hvr400.c.

#define MSCB_DEBUG   FALSE

MSCB debug flag.

Definition at line 33 of file hvr400.c.

Referenced by hvr400_init().

Function Documentation

INT hvr400_exit ( HVR400_INFO info)

terminates the MSCB and free's the memory allocated for the DD info structure.

Return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure

Definition at line 344 of file hvr400.c.

References HVR400_INFO::fd, HVR400_INFO::node_vars, HVR400_INFO::scw, HVR400_SETTINGS::scw_in_use, HVR400_INFO::settings, and HVR400_INFO::startup_error.

Referenced by hvr400().

INT hvr400_get ( HVR400_INFO info,
INT  channel,
float *  pvalue 
)
INT hvr400_init ( HNDLE  hKey,
void **  pinfo,
INT  channels 
)

Initializes the thermo element MSCB device driver, i.e. generates all the necessary structures in the ODB if necessary, and initializes the MSCB. Furthermore it makes some consitency checks to verify that the addressed module is indeed a thermo element MSCB card.

Return:

  • FE_SUCCESS if everything went smooth
  • FE_ERR_ODB otherwise
Parameters
hKeyis the device driver handle given from the class driver
pinfois needed to store the internal info structure
channelsis the number of channels of the device (from the class driver)

Definition at line 222 of file hvr400.c.

References HVR400_SETTINGS::enabled, HVR400_INFO::errcount, HVR400_INFO::fd, hDB, hvr400_read_all(), HVR400_SCW_STR, HVR400_SETTINGS_STR, info, HVR400_INFO::lasterrtime, MSCB_DEBUG, HVR400_SETTINGS::name, HVR400_SETTINGS::node_addr, HVR400_INFO::node_vars, HVR400_SETTINGS::port, HVR400_SETTINGS::pwd, HVR400_INFO::scw, HVR400_SETTINGS::scw_in_use, HVR400_INFO::settings, and HVR400_INFO::startup_error.

Referenced by hvr400().

INT hvr400_set ( HVR400_INFO info,
INT  channel,
float  value 
)

set a high voltage value of a hvr_400 channel.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure.
channelis the channel number
valuehigh voltage value in (kV) to be set

Definition at line 371 of file hvr400.c.

References HVR400_NODE_VARS::control, HVR400_INFO::fd, HVR400_CONTROL, HVR400_CTRL_HV_ON, HVR400_CTRL_REGULATION, HVR400_VDEMAND, HVR400_SETTINGS::node_addr, HVR400_INFO::node_vars, HVR400_INFO::settings, and HVR400_INFO::startup_error.

Referenced by hvr400().

INT hvr400_set_current_limit ( HVR400_INFO info,
INT  channel,
float  limit 
)

sets the current limit of a channel of the hvr_400's.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure.
channelis the channel number of the nhq
limitis the current limit value

Definition at line 490 of file hvr400.c.

References HVR400_INFO::errcount, HVR400_INFO::fd, HVR400_DELTA_TIME_ERROR, HVR400_ILIMIT, HVR400_INFO::lasterrtime, HVR400_SETTINGS::node_addr, HVR400_INFO::settings, and HVR400_INFO::startup_error.

Referenced by hvr400().

INT hvr400_set_rampdown ( HVR400_INFO info,
INT  channel,
float  ramp 
)

sets the ramping down speed in (V/s) of a channel of the hvr_400's. If the value is "0", ramping is performed as fast as possible.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure.
channelis the channel number of the nhq
rampis the ramping up value in (V/s)

Definition at line 603 of file hvr400.c.

References HVR400_INFO::errcount, HVR400_INFO::fd, HVR400_DELTA_TIME_ERROR, HVR400_RAMPDOWN, HVR400_INFO::lasterrtime, HVR400_SETTINGS::node_addr, HVR400_INFO::settings, and HVR400_INFO::startup_error.

Referenced by hvr400().

INT hvr400_set_rampup ( HVR400_INFO info,
INT  channel,
float  ramp 
)

sets the ramping up speed in (kV/s) of a channel of the hvr_400's. If the value is "0", ramping is performed as fast as possible.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure.
channelis the channel number of the nhq
rampis the ramping up value in (V/s)

Definition at line 565 of file hvr400.c.

References HVR400_INFO::errcount, HVR400_INFO::fd, HVR400_DELTA_TIME_ERROR, HVR400_RAMPUP, HVR400_INFO::lasterrtime, HVR400_SETTINGS::node_addr, HVR400_INFO::settings, and HVR400_INFO::startup_error.

Referenced by hvr400().

INT hvr400_set_triptime ( HVR400_INFO info,
INT  channel,
float  trip_time 
)

sets the trip time of a channel of the hvr_400's.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure.
channelis the channel number of the nhq
trip_timeis the trip time

Definition at line 640 of file hvr400.c.

References HVR400_INFO::errcount, HVR400_INFO::fd, HVR400_DELTA_TIME_ERROR, HVR400_TRIPTIME, HVR400_INFO::lasterrtime, HVR400_SETTINGS::node_addr, HVR400_INFO::settings, and HVR400_INFO::startup_error.

Referenced by hvr400().

INT hvr400_set_voltage_limit ( HVR400_INFO info,
INT  channel,
float  limit 
)

sets the voltage limit of a channel of the hvr_400's.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure.
channelis the channel number of the nhq
limitis the voltage limit value

Definition at line 527 of file hvr400.c.

References HVR400_INFO::errcount, HVR400_INFO::fd, HVR400_DELTA_TIME_ERROR, HVR400_VLIMIT, HVR400_INFO::lasterrtime, HVR400_SETTINGS::node_addr, HVR400_INFO::settings, and HVR400_INFO::startup_error.

Referenced by hvr400().