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

Go to the source code of this file.

Data Structures

struct  XTC_SETTINGS
 Stores all the parameters the device driver needs. More...
 
struct  XTC_INFO
 This structure contains private variables for the device driver. More...
 

Macros

#define XTC_ETS_LOGOUT_SLEEP   10000
 sleep time (us) between the telnet commands of the ets_logout More...
 
#define XTC_MAX_READBACK_FAILURE   5
 maximum number of readback failures before a reconnect will take place More...
 
#define XTC_INIT_ERROR   -2
 error tag if there was an error during initializing the DD More...
 
#define XTC_READ_ERROR   -1
 error tag if there was communication problem More...
 
#define XTC_CHANNELS   2
 number of channels of the xtc More...
 
#define XTC_SETTINGS_STR   "\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\Name_1 = STRING : [32] XTC_Thickness\n\Name_2 = STRING : [32] XTC_Rate\n\"
 Initializing string for the struct XTC_SETTINGS_STR. More...
 
#define TIME_OUT_XTC   2000
 time out in msecs for bus driver -> device communication More...
 
#define MAX_ERROR   4
 maximum number of error messages More...
 
#define DELTA_TIME_ERROR   3600
 reset error counter after DELTA_TIME_ERROR seconds More...
 
#define ACK   0x06
 acknowledgment tag for device communication More...
 
#define DEBUG   FALSE
 debug tag More...
 

Functions

INT xtc_init (HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
 
INT xtc_exit (XTC_INFO *info)
 
INT xtc_set (XTC_INFO *info, INT channel, float value)
 
INT xtc_get (XTC_INFO *info, INT channel, float *pvalue)
 
INT xtc_get_label (XTC_INFO *info, INT channel, char *name)
 
INT xtc (INT cmd,...)
 

Macro Definition Documentation

#define ACK   0x06

acknowledgment tag for device communication

Definition at line 79 of file xtc.c.

Referenced by xtc_get(), and xtc_init().

#define DEBUG   FALSE

debug tag

Definition at line 80 of file xtc.c.

#define DELTA_TIME_ERROR   3600

reset error counter after DELTA_TIME_ERROR seconds

Definition at line 78 of file xtc.c.

Referenced by xtc_get().

#define MAX_ERROR   4

maximum number of error messages

Definition at line 77 of file xtc.c.

Referenced by xtc_get().

#define TIME_OUT_XTC   2000

time out in msecs for bus driver -> device communication

Definition at line 74 of file xtc.c.

Referenced by xtc_get(), and xtc_init().

#define XTC_CHANNELS   2

number of channels of the xtc

Definition at line 39 of file xtc.c.

Referenced by xtc_init().

#define XTC_ETS_LOGOUT_SLEEP   10000

sleep time (us) between the telnet commands of the ets_logout

Definition at line 28 of file xtc.c.

Referenced by xtc_get().

#define XTC_INIT_ERROR   -2

error tag if there was an error during initializing the DD

Definition at line 34 of file xtc.c.

Referenced by xtc_get().

#define XTC_MAX_READBACK_FAILURE   5

maximum number of readback failures before a reconnect will take place

Definition at line 31 of file xtc.c.

Referenced by xtc_get().

#define XTC_READ_ERROR   -1

error tag if there was communication problem

Definition at line 36 of file xtc.c.

Referenced by xtc_get().

#define XTC_SETTINGS_STR   "\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\Name_1 = STRING : [32] XTC_Thickness\n\Name_2 = STRING : [32] XTC_Rate\n\"

Initializing string for the struct XTC_SETTINGS_STR.

Definition at line 49 of file xtc.c.

Referenced by xtc_init().

Function Documentation

INT xtc ( INT  cmd,
  ... 
)

xtc is the main entry routine for the calling class driver. The micro balance device driver (DD) XTC is handling the communication between the XTC and midas. The XTC is used to measure the amount of gas condensed on to moderator. Though, since it is spatially apart form the moderator foil, it is at a higher temperature and exposed to a different mass flow.

Definition at line 342 of file xtc.c.

References hKey, info, xtc_exit(), xtc_get(), xtc_get_label(), xtc_init(), and xtc_set().

Referenced by write_env().

INT xtc_exit ( XTC_INFO info)

quits the bus driver and free's the memory allocated for the info structure

XTC_INFO

.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure

Definition at line 182 of file xtc.c.

References XTC_INFO::bd, and XTC_INFO::bd_info.

Referenced by xtc().

INT xtc_get ( XTC_INFO info,
INT  channel,
float *  pvalue 
)

reads a value back from the xtc micro balance.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure
channelto be read back. channel = 0 -> thickness in (A), channel = 1 -> rate in (A/s)
pvaluepointer to the ODB value

Definition at line 220 of file xtc.c.

References ACK, XTC_INFO::bd, XTC_INFO::bd_connected, XTC_INFO::bd_info, DELTA_TIME_ERROR, XTC_SETTINGS::detailed_msg, XTC_INFO::errorcount, XTC_SETTINGS::ets_in_use, ets_logout(), XTC_INFO::hkey, XTC_INFO::last_reconnect, XTC_INFO::last_value, XTC_INFO::lasterrtime, MAX_ERROR, XTC_INFO::readback_failure, XTC_INFO::reconnection_failures, XTC_INFO::startup_error, TIME_OUT_XTC, XTC_ETS_LOGOUT_SLEEP, XTC_INIT_ERROR, XTC_MAX_READBACK_FAILURE, XTC_READ_ERROR, and XTC_INFO::xtc_settings.

Referenced by xtc().

INT xtc_get_label ( XTC_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

Parameters
infois a pointer to the DD specific info structure
channelof the name to be set
namepointer to the ODB name

Definition at line 332 of file xtc.c.

References XTC_SETTINGS::name, and XTC_INFO::xtc_settings.

Referenced by xtc().

INT xtc_init ( HNDLE  hKey,
void **  pinfo,
INT  channels,
INT(*)(INT cmd,...)  bd 
)

Initializes the xtc device driver, i.e. generates all the necessary structures in the ODB if necessary and initializes the bus driver.

return:

  • FE_SUCCESS if everything is OK
  • FE_ERR_ODB in case of a severe error
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)
bdis a pointer to the bus driver

Definition at line 97 of file xtc.c.

References ACK, XTC_INFO::bd, XTC_INFO::bd_connected, XTC_INFO::bd_info, XTC_INFO::errorcount, hDB, XTC_INFO::hkey, hKey, info, XTC_INFO::last_reconnect, XTC_INFO::lasterrtime, XTC_INFO::num_channels, XTC_INFO::readback_failure, XTC_INFO::reconnection_failures, XTC_INFO::startup_error, TIME_OUT_XTC, XTC_CHANNELS, XTC_INFO::xtc_settings, and XTC_SETTINGS_STR.

Referenced by xtc().

INT xtc_set ( XTC_INFO info,
INT  channel,
float  value 
)

would sends a new value to the xtc. This is at the moment a dummy routine, i.e. it does nothing.

return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure
channeldevice channel number
valueto be set

Definition at line 204 of file xtc.c.

Referenced by xtc().