26 const char cmd_opt_help[] =
"Control and monitor optics";
34 puts(
"*** Error/warnings values may not be correct ***");
37 puts(
"Ch BRD BCH ID HV as V TH as mV ENA ERROR / WARN");
38 puts(
"-- --- --- -------- --- ----- --- ----- --- ---------------");
43 for (i = 0; i < 31; ++i)
47 printf(
"%2d %s %3d %08x %2x %5d %2x %5d %s %s%s%s%s\n" ,
49 _OCT_BRD(i) == 0 ?
"SML" :
"LRG",
63 puts(
"High-Voltage disabled");
65 puts(
"High-Voltage ENABLED");
71 puts(
"Stopping da blast!");
75 bool cmd_opt_exec(
int argc,
const char *args[])
77 if (argc == 0 || (argc == 1 && strcmp(args[0],
"help") == 0)) {
78 puts(
"Usage: opt [command [args]] ");
79 puts(
"Where command may be:");
80 puts(
" status Gives a list of all channels with there configuration and state");
81 puts(
" set +|-<no> ... Enable / Disable channels, e.g. +3 enable channel 3, \n"
82 " -5 disable channel 5. Multiple values possible");
83 puts(
" cfg <no..> <h> <t> Sets the threshold and high voltage for a specific channel.");
84 puts(
" no: One or more channel numbers (max 4).");
85 puts(
" h : high voltage is in range of -700 to -1500 in Volts.");
86 puts(
" t : threshold is in range of 800 to 2400 in milliVolts");
87 puts(
" note: values are rounded to DAC values, and may differ.");
88 puts(
" hv on|off turns the high voltage on or off. Default is off.");
89 puts(
" note: should be enabled before configuring");
90 puts(
" blast <t> <ch>.. Blasts the TDC fifos full");
91 puts(
" t: Time to blast in ms, ch: Channel list, 0 based");
92 puts(
" veto [<v>|on|off] v : Sets high rate veto value. ");
93 puts(
" on : Turns veto on on all channels");
94 puts(
" off : Turns veto off on all channels");
95 puts(
" Leave empty to query the configuration");
97 }
else if (argc == 1 && strcmp(args[0],
"status") == 0)
101 }
else if (argc >= 2 && strcmp(args[0],
"set") == 0) {
104 for (i = 1; i < argc; i++) {
105 int c = atoi(args[i] + 1);
106 if (args[i][0] ==
'+') {
115 }
else if (argc >= 3 && strcmp(args[0],
"blast") == 0) {
117 puts(
" _____ __ __");
118 puts(
"|_ _|| \\ / _|");
119 puts(
" | | | | || |_ B L A S T E R");
120 puts(
" |_| |__/ \\__| 0.1");
125 for (i = 2; i < argc; i++) {
126 int c = atoi(args[i]);
130 static int myId = TASK_ID_NONE;
132 if (myId == TASK_ID_NONE)
135 if (!
schdRegister(stopBlast,
true, &myId))
return false;
143 }
else if (argc == 2 && strcmp(args[0],
"hv") == 0)
145 if (strcmp(args[1],
"on") == 0) {
151 }
else if (argc >= 1 && strcmp(args[0],
"veto") == 0)
155 printf(
"Limit: %d, Enabled Ch Bitmask: %08x\n",
159 if (strcmp(args[1],
"on") == 0) {
162 }
else if (strcmp(args[1],
"off") == 0) {
166 uint32_t v = atoi(args[1]);
167 if (v == 0)
return false;
173 }
else if (argc >= 4 && strcmp(args[0],
"cfg") == 0)
177 thrs = COERCE(thrs, 0, 255);
179 hv = COERCE(hv, 0, 255);
180 printf(
"Setting voltages high-voltage=%d V and threshold=%d mV\n",
182 for (i = 1; i < argc - 2; ++i) {
183 int ch = atoi(args[i]);
uint32_t chan_enable
Channel enable, bit per channel.
uint32_t hr_veto_ena_ch
High-rate veto enable, bit per channel.
Provides access to all variables of the various subsystems.
#define BIT(N)
Makes a value with the specified bit set.
bool schdRegister(SchdTaskF task, bool priority, int *taskId)
Register a task with the scheduler.
#define OPT_STS_ERR_OVERCUR
Over current.
#define SYS_SYS_DISABLE_HV
Bit which disables High Voltage.
Simple task scheduler for tasks.
#define OPT_STS_WARN_ID
ID is inconsistent.
void tdcDbgSetBlastFull(uint32_t channels)
Blast full FIFOs bitmask for debugging.
uint8_t pmt_highvolt[31]
High voltage settings per channel, 0=PMT at location 0, 31=PMT at location 31 Scaling: 0: -700V...
uint8_t chan_status[31]
Channel status, 0=PMT at location 0, 31=PMT at location 31.
#define PRMS_HV_V2DAC(V)
Converts the high voltage value into the high voltage DAC byte value.
void schdRunDelay(int taskId, int interval)
Schedule a task to run after a delay.
sys_t sys
Provides access to all process variables of subsystem System.
#define OPT_STS_WARN_HRVETO
High rate veto active.
uint32_t hr_veto_thres
High-rate veto (hits per timeslice)
uint8_t sys_disable
Disable parts of the system.
void errPrint(bool clear)
Prints the last error.
bool optUpdate()
Updates the status of the optics.
opt_t opt
Provides access to all process variables of subsystem Optics.
#define PRMS_THRS_DAC2MV(BYTE)
Converts the threshold DAC byte value into milliVolts.
This driver interfaces with the PROMiS PMT ASIC.
#define PRMS_THRS_MV2DAC(MV)
Converts a threshold value in milliVolts to the DAC value.
#define PRMS_HV_DAC2V(V)
Converts the high voltage DAC byte value into volts.
uint32_t pmt_id[31]
All PMT ID's, 0=PMT at location 0, 31=PMT at location 31.
uint8_t pmt_threshold[31]
Threshold settings per channel, 0=PMT at location 0, 31=PMT at location 31 Scaling: 0: 800mV...
#define OPT_STS_ERR_COMM
I2C communication error.