/* Generated with snc from ../format.stt */ /* Program "format" */ #include #include #include #include #include "epicsTypes.h" #include "seqCom.h" /* Variable declarations */ struct UserVar { # line 114 "../format.stt" int case_val; # line 116 "../format.stt" int mult_i; # line 117 "../format.stt" int mult_l; # line 118 "../format.stt" int exp_l; # line 119 "../format.stt" string temp; # line 120 "../format.stt" int exp_p; # line 121 "../format.stt" int str_l; # line 123 "../format.stt" int length; # line 125 "../format.stt" int space_l; # line 126 "../format.stt" int i; # line 133 "../format.stt" int MAX_LEGEND; # line 134 "../format.stt" int START_VAL; # line 141 "../format.stt" float format_seq; # line 149 "../format.stt" double devval; # line 156 "../format.stt" int exp; # line 159 "../format.stt" string exp_s; # line 162 "../format.stt" float mult; # line 165 "../format.stt" string mult_s; # line 173 "../format.stt" string out_range_s; # line 180 "../format.stt" string space; # line 188 "../format.stt" int sign; # line 196 "../format.stt" int choose_format; # line 204 "../format.stt" int mon_proc; }; /* C code definitions */ # line 99 "../format.stt" #include /* strcpy,strcat, etc */ #include #include #include #include #include /* sprintf,NULL */ #include /* rintf */ /* Program init func */ static void G_prog_init(struct UserVar *pVar) { static struct UserVar pVarInit = { 0, 0, 0, 0, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, "", "", "", 0, 0, 0, }; *pVar = pVarInit; } /****** Code for state "format" in state set "val_format" ******/ /* Entry function for state "format" in state set "val_format" */ static void I_val_format_format(SS_ID ssId, struct UserVar *pVar) { # line 217 "../format.stt" pVar->MAX_LEGEND = 15; # line 218 "../format.stt" pVar->START_VAL = 9; # line 225 "../format.stt" seq_pvGet(ssId, 0/*format_seq*/, 0); } /* Delay function for state "format" in state set "val_format" */ static void D_val_format_format(SS_ID ssId, struct UserVar *pVar) { } /* Event function for state "format" in state set "val_format" */ static seqBool E_val_format_format(SS_ID ssId, struct UserVar *pVar, int *pTransNum, int *pNextState) { # line 228 "../format.stt" if (pVar->format_seq > 0.0) { *pNextState = 0; *pTransNum = 0; return TRUE; } return FALSE; } /* Action function for state "format" in state set "val_format" */ static void A_val_format_format(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState) { switch(transNum) { case 0: { # line 230 "../format.stt" seq_pvGet(ssId, 8/*sign*/, 0); # line 231 "../format.stt" seq_pvGet(ssId, 2/*exp*/, 0); # line 232 "../format.stt" seq_pvGet(ssId, 3/*exp_s*/, 0); # line 233 "../format.stt" seq_pvGet(ssId, 4/*mult*/, 0); # line 234 "../format.stt" seq_pvGet(ssId, 1/*devval*/, 0); # line 236 "../format.stt" pVar->format_seq = 0; # line 237 "../format.stt" seq_pvPut(ssId, 0/*format_seq*/, 0); # line 242 "../format.stt" if (pVar->devval == 0 || pVar->exp == 0) # line 243 "../format.stt" pVar->case_val = 1; else # line 244 "../format.stt" if (pVar->exp == 1) # line 245 "../format.stt" pVar->case_val = 2; else # line 246 "../format.stt" if (pVar->exp == 2) # line 247 "../format.stt" pVar->case_val = 3; else # line 248 "../format.stt" if (pVar->exp == 3) # line 249 "../format.stt" pVar->case_val = 4; else # line 250 "../format.stt" if (pVar->exp == -1 || pVar->exp == -2) # line 251 "../format.stt" pVar->case_val = 5; else # line 252 "../format.stt" if (pVar->exp <= -3 && pVar->exp > -10) # line 253 "../format.stt" pVar->case_val = 6; else # line 254 "../format.stt" if (pVar->exp >= 4 && pVar->exp < 10) # line 255 "../format.stt" pVar->case_val = 7; else # line 256 "../format.stt" if (pVar->exp <= -10 && pVar->exp > -100 && pVar->devval != 0) # line 257 "../format.stt" pVar->case_val = 8; else # line 258 "../format.stt" if (pVar->exp >= 10 && pVar->exp < 100) # line 259 "../format.stt" pVar->case_val = 9; else # line 260 "../format.stt" if (fabs(pVar->devval) >= 1e100) # line 261 "../format.stt" pVar->case_val = 10; else # line 262 "../format.stt" if (fabs(pVar->devval) <= 1e-100) # line 263 "../format.stt" pVar->case_val = 11; switch((pVar->case_val)) { /* C code definitions */ # line 268 "../format.stt" case 1: # line 269 "../format.stt" pVar->choose_format = 1; # line 270 "../format.stt" pVar->space_l = 10 + pVar->sign - 9; break; case 2: # line 274 "../format.stt" pVar->choose_format = 2; # line 275 "../format.stt" pVar->space_l = 10 + pVar->sign - 9; break; case 3: # line 279 "../format.stt" pVar->choose_format = 3; # line 280 "../format.stt" pVar->space_l = 10 + pVar->sign - 9; break; case 4: # line 284 "../format.stt" pVar->choose_format = 4; # line 285 "../format.stt" pVar->space_l = 9 + pVar->sign - 9; break; case 5: # line 289 "../format.stt" pVar->choose_format = 5; # line 290 "../format.stt" pVar->space_l = 9 + pVar->sign - 9; break; case 6: # line 296 "../format.stt" pVar->mult = pVar->mult * 100; # line 297 "../format.stt" pVar->mult_i = rintf(pVar->mult); # line 298 "../format.stt" pVar->mult = pVar->mult_i; # line 299 "../format.stt" pVar->mult = pVar->mult / 100; # line 300 "../format.stt" seq_pvPut(ssId, 4/*mult*/, 0); # line 303 "../format.stt" if (pVar->sign < 0) # line 304 "../format.stt" pVar->mult_l = 5; else # line 306 "../format.stt" pVar->mult_l = 4; # line 308 "../format.stt" pVar->exp_l = 2; # line 309 "../format.stt" pVar->length = pVar->mult_l + pVar->exp_l; # line 310 "../format.stt" pVar->space_l = (pVar->MAX_LEGEND - pVar->START_VAL - pVar->length); # line 311 "../format.stt" pVar->choose_format = 6; break; case 7: # line 317 "../format.stt" pVar->mult = pVar->mult * 100; # line 318 "../format.stt" pVar->mult_i = rintf(pVar->mult); # line 319 "../format.stt" pVar->mult = pVar->mult_i; # line 320 "../format.stt" pVar->mult = pVar->mult / 100; # line 321 "../format.stt" seq_pvPut(ssId, 4/*mult*/, 0); # line 324 "../format.stt" if (pVar->sign < 0) # line 325 "../format.stt" pVar->mult_l = 5; else # line 327 "../format.stt" pVar->mult_l = 4; # line 329 "../format.stt" pVar->exp_l = 2; # line 330 "../format.stt" pVar->exp_p = 1; # line 331 "../format.stt" strcpy(pVar->temp, "+"); # line 332 "../format.stt" strcpy(&pVar->temp[pVar->exp_p], pVar->exp_s); # line 333 "../format.stt" strcpy(pVar->exp_s, pVar->temp); # line 334 "../format.stt" seq_pvPut(ssId, 3/*exp_s*/, 0); # line 336 "../format.stt" pVar->length = pVar->mult_l + pVar->exp_l; # line 337 "../format.stt" pVar->space_l = (pVar->MAX_LEGEND - pVar->START_VAL - pVar->length); # line 338 "../format.stt" pVar->choose_format = 6; break; case 8: # line 343 "../format.stt" pVar->mult = pVar->mult * 10; # line 344 "../format.stt" pVar->mult_i = rintf(pVar->mult); # line 345 "../format.stt" pVar->mult = pVar->mult_i; # line 346 "../format.stt" pVar->mult = pVar->mult / 10; # line 347 "../format.stt" seq_pvPut(ssId, 4/*mult*/, 0); # line 350 "../format.stt" if (pVar->sign < 0) # line 351 "../format.stt" pVar->mult_l = 4; else # line 353 "../format.stt" pVar->mult_l = 3; # line 354 "../format.stt" pVar->exp_l = 3; # line 356 "../format.stt" pVar->length = pVar->mult_l + pVar->exp_l; # line 357 "../format.stt" pVar->space_l = (pVar->MAX_LEGEND - pVar->START_VAL - pVar->length); # line 358 "../format.stt" pVar->choose_format = 7; break; case 9: # line 363 "../format.stt" pVar->mult = pVar->mult * 10; # line 364 "../format.stt" pVar->mult_i = rintf(pVar->mult); # line 365 "../format.stt" pVar->mult = pVar->mult_i; # line 366 "../format.stt" pVar->mult = pVar->mult / 10; # line 367 "../format.stt" seq_pvPut(ssId, 4/*mult*/, 0); # line 370 "../format.stt" if (pVar->sign < 0) # line 371 "../format.stt" pVar->mult_l = 4; else # line 373 "../format.stt" pVar->mult_l = 3; # line 374 "../format.stt" pVar->exp_l = 3; # line 375 "../format.stt" pVar->exp_p = 1; # line 376 "../format.stt" strcpy(pVar->temp, "+"); # line 377 "../format.stt" strcpy(&pVar->temp[pVar->exp_p], pVar->exp_s); # line 378 "../format.stt" strcpy(pVar->exp_s, pVar->temp); # line 380 "../format.stt" seq_pvPut(ssId, 3/*exp_s*/, 0); # line 381 "../format.stt" pVar->length = pVar->mult_l + pVar->exp_l; # line 382 "../format.stt" pVar->space_l = (pVar->MAX_LEGEND - pVar->START_VAL - pVar->length); # line 383 "../format.stt" pVar->choose_format = 7; break; case 10: # line 388 "../format.stt" if (pVar->sign < 0) { # line 390 "../format.stt" pVar->str_l = 7; # line 391 "../format.stt" strcpy(pVar->out_range_s, ">-1+100"); } else { # line 395 "../format.stt" pVar->str_l = 6; # line 396 "../format.stt" strcpy(pVar->out_range_s, ">1+100"); } # line 398 "../format.stt" seq_pvPut(ssId, 6/*out_range_s*/, 0); # line 399 "../format.stt" pVar->length = pVar->str_l; # line 400 "../format.stt" pVar->space_l = (pVar->MAX_LEGEND - pVar->START_VAL - pVar->length); # line 401 "../format.stt" pVar->choose_format = 8; break; case 11: # line 408 "../format.stt" if (pVar->sign < 0) { # line 410 "../format.stt" pVar->str_l = 7; # line 411 "../format.stt" strcpy(pVar->out_range_s, "<-1-100"); } else { # line 415 "../format.stt" pVar->str_l = 6; # line 416 "../format.stt" strcpy(pVar->out_range_s, "<1-100"); } # line 418 "../format.stt" seq_pvPut(ssId, 6/*out_range_s*/, 0); # line 419 "../format.stt" pVar->length = pVar->str_l; # line 420 "../format.stt" pVar->space_l = (pVar->MAX_LEGEND - pVar->START_VAL - pVar->length); # line 421 "../format.stt" pVar->choose_format = 8; break; } # line 426 "../format.stt" seq_pvPut(ssId, 9/*choose_format*/, 0); # line 430 "../format.stt" strcpy(pVar->space, ""); for((pVar->i)=0;(pVar->i)<=(pVar->space_l);(pVar->i)++) strcat((pVar->space)," "); # line 433 "../format.stt" seq_pvPut(ssId, 7/*space*/, 0); # line 438 "../format.stt" pVar->mon_proc = 1; # line 439 "../format.stt" seq_pvPut(ssId, 10/*mon_proc*/, 0); } return; } } /************************ Tables ************************/ /* Channel table */ static seqChan G_channels[] = { /* chName, offset, varName, varType, count, eventNum, efId, monitored, queueSize, queueIndex */ {"KNOB:{LOCA}:{B}:K{K}_FORM_SEQ.VAL", offsetof(struct UserVar, format_seq), "format_seq", "float", 1, 1, 0, 1, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_DEVVAL.VAL", offsetof(struct UserVar, devval), "devval", "double", 1, 2, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_EXP.VAL", offsetof(struct UserVar, exp), "exp", "int", 1, 3, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_EXP_S.VAL", offsetof(struct UserVar, exp_s), "exp_s", "string", 1, 4, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_MULT.VAL", offsetof(struct UserVar, mult), "mult", "float", 1, 5, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_MULT_S.VAL", offsetof(struct UserVar, mult_s), "mult_s", "string", 1, 6, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_OUTRANG_S.VAL", offsetof(struct UserVar, out_range_s), "out_range_s", "string", 1, 7, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_LGNDSPACE.VAL", offsetof(struct UserVar, space), "space", "string", 1, 8, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_SIGN.VAL", offsetof(struct UserVar, sign), "sign", "int", 1, 9, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_WHCH_FORM.SELN", offsetof(struct UserVar, choose_format), "choose_format", "int", 1, 10, 0, 0, 0, 0}, {"KNOB:{LOCA}:{B}:K{K}_MONCHECK.PROC", offsetof(struct UserVar, mon_proc), "mon_proc", "int", 1, 11, 0, 0, 0, 0} }; /* Event masks for state set "val_format" */ static const seqMask EM_val_format_format[] = { 0x00000002, }; /* State table for state set "val_format" */ static seqState G_val_format_states[] = { { /* state name */ "format", /* action function */ A_val_format_format, /* event function */ E_val_format_format, /* delay function */ D_val_format_format, /* entry function */ I_val_format_format, /* exit function */ 0, /* event mask array */ EM_val_format_format, /* state options */ (0) }, }; /* State set table */ static seqSS G_state_sets[] = { { /* state set name */ "val_format", /* states */ G_val_format_states, /* number of states */ 1, /* number of delays */ 0 }, }; /* Program table (global) */ seqProgram format = { /* magic number */ 2001006, /* program name */ "format", /* channels */ G_channels, /* num. channels */ 11, /* state sets */ G_state_sets, /* num. state sets */ 1, /* user var size */ sizeof(struct UserVar), /* param */ "", /* num. event flags */ 0, /* encoded options */ (0 | OPT_CONN | OPT_NEWEF | OPT_REENT), /* init func */ G_prog_init, /* entry func */ NULL, /* exit func */ NULL, /* num. queues */ 0 }; /* Register sequencer commands and program */ #include "epicsExport.h" static void formatRegistrar (void) { seqRegisterSequencerCommands(); seqRegisterSequencerProgram (&format); } epicsExportRegistrar(formatRegistrar);