19 #include "class/multi.h"
21 #include "tcpip_rs232.h"
25 #define DANFYSIK_REMOTE_CH 0
26 #define DANFYSIK_STATE_CH 1
27 #define DANFYSIK_DEMAND_CH 2
28 #define DANFYSIK_MEASURE_CH 3
30 #define DANFYSIK_TIMEOUT_CHECK 30
61 {
"Danfysik_in",
danfysik_in, 5, tcpip_rs232, DF_INPUT },
62 {
"Danfysik_out",
danfysik_out, 4, tcpip_rs232, DF_OUTPUT },
106 INT
poll_event(INT source, INT count, BOOL test) {
return 1;};
117 cm_deregister_transition(TR_START);
118 cm_deregister_transition(TR_STOP);
119 cm_deregister_transition(TR_PAUSE);
120 cm_deregister_transition(TR_RESUME);
146 HNDLE
hDB, hKeyIn, hKeyOut;
148 float setpoint_current, measured_current, remote, state;
149 static int err_count = 0;
161 cm_get_experiment_database(&hDB, NULL);
164 status = db_find_key(hDB, 0,
"/Equipment/Danfysik/Variables/Input", &hKeyIn);
165 if (status != DB_SUCCESS) {
166 cm_msg(MINFO,
"frontend_loop",
"danfysik_scfe, frontend_loop: couldn't get danfysik input key from the ODB.");
170 status = db_find_key(hDB, 0,
"/Equipment/Danfysik/Variables/Output", &hKeyOut);
171 if (status != DB_SUCCESS) {
172 cm_msg(MINFO,
"frontend_loop",
"danfysik_scfe, frontend_loop: couldn't get danfysik output key from the ODB.");
177 size =
sizeof(float);
178 status = db_get_data_index(hDB, hKeyOut, &remote, &size,
DANFYSIK_REMOTE_CH, TID_FLOAT);
179 size =
sizeof(float);
180 status = db_get_data_index(hDB, hKeyOut, &state, &size,
DANFYSIK_STATE_CH, TID_FLOAT);
183 if ((remote != 1.0) || (state != 1.0))
187 size =
sizeof(float);
188 status = db_get_data_index(hDB, hKeyOut, &setpoint_current, &size,
DANFYSIK_DEMAND_CH, TID_FLOAT);
191 size =
sizeof(float);
192 status = db_get_data_index(hDB, hKeyIn, &measured_current, &size,
DANFYSIK_MEASURE_CH, TID_FLOAT);
195 if (fabsf(setpoint_current-measured_current)/fabsf(setpoint_current) > 0.1) {
202 if (err_count == 10) {
203 sprintf(str,
"Danfysik Setpoint = %0.1f A, Measured = %0.1f A: something is fishy!", setpoint_current, measured_current);
204 al_trigger_alarm(
"danfysik_current_monitoring", str,
"Warning", str, AT_INTERNAL);
#define DANFYSIK_MEASURE_CH
#define DANFYSIK_STATE_CH
const char * frontend_name
< created by ODBedit, command "make"
INT max_event_size
maximum event size produced by this frontend
BOOL frontend_call_loop
frontend_loop is called periodically if this variable is TRUE
INT display_period
a frontend status page is displayed with this frequency in ms
INT event_buffer_size
buffer size to hold events
INT begin_of_run(INT run_number, char *error)
INT danfysik_in(INT cmd,...)
DEVICE_DRIVER danfysik_driver[]
INT interrupt_configure(INT cmd, INT source, PTYPE adr)
INT resume_run(INT run_number, char *error)
INT max_event_size_frag
maximum event size for fragmented events (EQ_FRAGMENTED)
BOOL equipment_common_overwrite
INT end_of_run(INT run_number, char *error)
INT poll_event(INT source, INT count, BOOL test)
#define DANFYSIK_TIMEOUT_CHECK
#define DANFYSIK_REMOTE_CH
#define DANFYSIK_DEMAND_CH
INT pause_run(INT run_number, char *error)
const char * frontend_file_name
The frontend file name, don't change it.
DWORD danfysik_check_timestamp
INT danfysik_out(INT cmd,...)