Skip to content
Snippets Groups Projects
Commit d9f22eba authored by Rolf Bork's avatar Rolf Bork
Browse files

Synched w/branch-2.9.

git-svn-id: https://redoubt.ligo-wa.caltech.edu/svn/advLigoRTS/trunk@3760 6dcd42c9-f523-4c6d-aada-af552506706e
parent f364d7ba
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,6 @@ of this distribution. ...@@ -12,7 +12,6 @@ of this distribution.
// TODO: // TODO:
// Need to check RESET and READ file yet. // Need to check RESET and READ file yet.
// Still need to add save/save as features
// Check top with full model loads for memory and cpu usage. // Check top with full model loads for memory and cpu usage.
// Add command error checking, command out of range, etc. // Add command error checking, command out of range, etc.
// Check autoBurt, particularly for SDF stuff // Check autoBurt, particularly for SDF stuff
...@@ -51,10 +50,11 @@ of this distribution. ...@@ -51,10 +50,11 @@ of this distribution.
#define SDF_RESET 3 #define SDF_RESET 3
#define SDF_LOAD_PARTIAL 1 #define SDF_LOAD_PARTIAL 1
#define SDF_MAX_CHANS 300000 #define SDF_MAX_CHANS 150000
#define SDF_MAX_TSIZE 20000 #define SDF_MAX_TSIZE 20000
#define SDF_ERR_TSIZE 40 #define SDF_ERR_TSIZE 40
#if 0
/// Pointers to status record /// Pointers to status record
DBENTRY *pdbentry_status[2][10]; DBENTRY *pdbentry_status[2][10];
...@@ -70,6 +70,7 @@ DBENTRY *pdbentry_crc = 0; ...@@ -70,6 +70,7 @@ DBENTRY *pdbentry_crc = 0;
DBENTRY *pdbentry_in_err_cnt = 0; DBENTRY *pdbentry_in_err_cnt = 0;
/// Number of readbacks in alarm.. /// Number of readbacks in alarm..
DBENTRY *pdbentry_out_err_cnt = 0; DBENTRY *pdbentry_out_err_cnt = 0;
#endif
/// Quick look up table for filter module switch decoding /// Quick look up table for filter module switch decoding
const unsigned int fltrConst[15] = {16, 64, 256, 1024, 4096, 16384, const unsigned int fltrConst[15] = {16, 64, 256, 1024, 4096, 16384,
...@@ -121,6 +122,7 @@ SET_ERR_TABLE unMonChans[SDF_ERR_TSIZE]; ...@@ -121,6 +122,7 @@ SET_ERR_TABLE unMonChans[SDF_ERR_TSIZE];
struct timespec t; struct timespec t;
// Quick convert of filter switch settings to match SWMASK
unsigned int filtCtrlBitConvert(unsigned int v) { unsigned int filtCtrlBitConvert(unsigned int v) {
unsigned int val = 0; unsigned int val = 0;
int i; int i;
...@@ -131,16 +133,6 @@ unsigned int filtCtrlBitConvert(unsigned int v) { ...@@ -131,16 +133,6 @@ unsigned int filtCtrlBitConvert(unsigned int v) {
} }
/// Initialize alarm variables.
void init_vars() {
int i, j;
for (i = 0; i < 2; i++)
for (j = 0; j < 10; j++) {
pdbentry_alarm[i][j] = 0;
pdbentry_status[i][j] = 0;
}
}
int getEpicsSettings(int numchans) int getEpicsSettings(int numchans)
{ {
dbAddr geaddr; dbAddr geaddr;
...@@ -291,6 +283,7 @@ int status; ...@@ -291,6 +283,7 @@ int status;
} }
#if 0
// Routine to change ASG, thereby changing record locking // Routine to change ASG, thereby changing record locking
void resetASG(char *name, int lock) { void resetASG(char *name, int lock) {
...@@ -308,6 +301,7 @@ void resetASG(char *name, int lock) { ...@@ -308,6 +301,7 @@ void resetASG(char *name, int lock) {
// printf("ASG = %s\n",t); // printf("ASG = %s\n",t);
dbFreeEntry(pdbentry); dbFreeEntry(pdbentry);
} }
#endif
void createSortTableEntries(int numEntries) void createSortTableEntries(int numEntries)
{ {
...@@ -346,7 +340,7 @@ int notMon = 0; ...@@ -346,7 +340,7 @@ int notMon = 0;
for(jj=0;jj<numEntries;jj++) for(jj=0;jj<numEntries;jj++)
{ {
if((!cdTable[jj].initialized) && (chNotInit < SDF_ERR_TSIZE)) { if((!cdTable[jj].initialized) && (chNotInit < SDF_ERR_TSIZE)) {
printf("Chan %s not init %d %d %d\n",cdTable[jj].chname,cdTable[jj].initialized,jj,numEntries); // printf("Chan %s not init %d %d %d\n",cdTable[jj].chname,cdTable[jj].initialized,jj,numEntries);
sprintf(uninitChans[chNotInit].chname,"%s",cdTable[jj].chname); sprintf(uninitChans[chNotInit].chname,"%s",cdTable[jj].chname);
chNotInit ++; chNotInit ++;
} }
...@@ -572,13 +566,15 @@ int newvalue(int numchans,CDS_CD_TABLE myTable[],int command) { ...@@ -572,13 +566,15 @@ int newvalue(int numchans,CDS_CD_TABLE myTable[],int command) {
} }
else { // Write errors to log file. else { // Write errors to log file.
myerror = 4; myerror = 4;
sprintf(unknownChans[chNotFound].chname,"%s",myTable[ii].chname); if(chNotFound < SDF_ERR_TSIZE) {
if(myTable[ii].datatype == 0) // Value if floating point number sprintf(unknownChans[chNotFound].chname,"%s",myTable[ii].chname);
sprintf(unknownChans[chNotFound].burtset,"%.6f",myTable[ii].chval); if(myTable[ii].datatype == 0) // Value if floating point number
else sprintf(unknownChans[chNotFound].burtset,"%.6f",myTable[ii].chval);
sprintf(unknownChans[chNotFound].burtset,"%s",myTable[ii].strval); else
sprintf(unknownChans[chNotFound].liveset,"%s"," "); sprintf(unknownChans[chNotFound].burtset,"%s",myTable[ii].strval);
sprintf(unknownChans[chNotFound].timeset,"%s"," "); sprintf(unknownChans[chNotFound].liveset,"%s"," ");
sprintf(unknownChans[chNotFound].timeset,"%s"," ");
}
log = fopen("./ioc.log","a"); log = fopen("./ioc.log","a");
fprintf(log,"SDF Load Error - Channel Not Found: %s\n",myTable[ii].chname); fprintf(log,"SDF Load Error - Channel Not Found: %s\n",myTable[ii].chname);
fclose(log); fclose(log);
...@@ -911,186 +907,6 @@ int readConfig(char *pref,char *sdfile, int command) ...@@ -911,186 +907,6 @@ int readConfig(char *pref,char *sdfile, int command)
return(lderror); return(lderror);
} }
/// Calculate Alarm (state) setpoint CRC checksums
// Not presently used.
unsigned int
field_crc(DBENTRY *pdbentry, char *field, unsigned int crc, unsigned int *len_crc) {
long status = dbFindField(pdbentry, field);
if (status) {
printf("No field %s was found\n", field);
exit(1);
}
char *s = dbGetString(pdbentry);
int l = strlen(s);
*len_crc += l;
return crc_ptr(s, l, crc);
}
/// Main subroutine for monitoring alarms
// NOTE: This code is not presently called. It was used when alarm monitoring was intended
// as the means to determine diffs between BURT and present settings.
void process_alarms(DBBASE *pdbbase, char *pref)
{
DBENTRY *pdbentry;
DBENTRY *pdbentry1;
long status;
int i, j;
unsigned int crc = 0;
unsigned int len_crc = 0;
pdbentry = dbAllocEntry(pdbbase);
if (0 == pdbentry_status[0][0]) {
status = dbFindRecordType(pdbentry, "stringout");
if (status) {
printf("No record type \"stringout\" was found\n");
exit(1);
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 10; j++) {
char s[256]; sprintf(s, "%s_%s_STAT%d", pref, i? "SDF_RB": "SDF_SP", j);
status = dbFindRecord(pdbentry, s);
if (status) {
printf("Could not find %s record\n", s);
exit(1);
}
status = dbFindField(pdbentry, "VAL");
if (status) {
printf("No field \"VAL\" was found\n");
exit(1);
}
pdbentry_status[i][j] = dbCopyEntry(pdbentry);
}
}
char s[256];
sprintf(s, "%s_SDF_ALH_CRC", pref);
status = dbFindRecord(pdbentry, s);
if (status) {
printf("Could not find %s record\n", s);
exit(1);
}
status = dbFindField(pdbentry, "VAL");
if (status) {
printf("No field \"VAL\" was found\n");
exit(1);
}
pdbentry_crc = dbCopyEntry(pdbentry);
sprintf(s, "%s_SDF_SP_ERR_CNT", pref);
status = dbFindRecord(pdbentry, s);
if (status) {
printf("Could not find %s record\n", s);
exit(1);
}
status = dbFindField(pdbentry, "VAL");
if (status) {
printf("No field \"VAL\" was found\n");
exit(1);
}
pdbentry_in_err_cnt = dbCopyEntry(pdbentry);
// sprintf(s, "%s__RB_ERR_CNT", pref);
// status = dbFindRecord(pdbentry, s);
// if (status) {
// printf("Could not find %s record\n", s);
// exit(1);
// }
status = dbFindField(pdbentry, "VAL");
if (status) {
printf("No field \"VAL\" was found\n");
exit(1);
}
pdbentry_out_err_cnt = dbCopyEntry(pdbentry);
}
for (i = 0; i < 2; i++) {
int nalrm = 0;
for (j = 0; j < 2; j++) {
char rtype[16];
sprintf(rtype, "%c%c", j? 'b': 'a', i? 'o': 'i');
status = dbFindRecordType(pdbentry, rtype);
if (status) {
printf("No record type %s was found\n", rtype);
exit(1);
}
status = dbFirstRecord(pdbentry);
while (!status) {
pdbentry1 = dbCopyEntry(pdbentry);
if (j) { // binary
crc = field_crc(pdbentry, "ZSV", crc, &len_crc);
crc = field_crc(pdbentry, "OSV", crc, &len_crc);
crc = field_crc(pdbentry, "COSV", crc, &len_crc);
} else { // analog
crc = field_crc(pdbentry, "HIGH", crc, &len_crc);
crc = field_crc(pdbentry, "LOW", crc, &len_crc);
crc = field_crc(pdbentry, "HSV", crc, &len_crc);
crc = field_crc(pdbentry, "LSV", crc, &len_crc);
}
status = dbFindField(pdbentry, "NAME");
if (status) {
printf("No field \"NAME\" was found\n");
exit(1);
}
status = dbFindField(pdbentry1, "STAT");
if (status) {
printf("No field \"STAT\" was found\n");
exit(1);
}
char *als = dbGetString(pdbentry1);
if (strcmp(als, "NO_ALARM") && strcmp(als, "UDF")) {
//printf("%s STAT=%s\n", dbGetString(pdbentry), als);
if (nalrm < 10) {
pdbentry_alarm[i][nalrm] = dbCopyEntry(pdbentry);
nalrm++;
}
}
dbFreeEntry(pdbentry1);
status = dbNextRecord(pdbentry);
}
}
}
// Display alarmed record names in status records
for (i = 0; i < 2; i++) {
int nalrm = 0;
for (j = 0; j < 10; j++) {
char *alarm_rec_name = "CLR";
if (pdbentry_alarm[i][j]) {
alarm_rec_name = dbGetString(pdbentry_alarm[i][j]);
nalrm++;
}
status = dbPutString(pdbentry_status[i][j], alarm_rec_name);
if (status) {
printf("Could not put field\n");
exit(1);
}
if (pdbentry_alarm[i][j]) {
dbFreeEntry(pdbentry_alarm[i][j]);
pdbentry_alarm[i][j] = 0;
}
}
char s[16]; sprintf(s, "%d", nalrm);
status = dbPutString(i? pdbentry_out_err_cnt: pdbentry_in_err_cnt, s);
if (status) {
printf("Could not put field\n");
exit(1);
}
}
// Output the CRC
crc = crc_len(len_crc, crc);
char s[16]; sprintf(s, "%d", crc);
status = dbPutString(pdbentry_crc, s);
if (status) {
printf("Could not put field\n");
exit(1);
}
//status = dbProcess(pdbentry_crc);
dbFreeEntry(pdbentry);
}
void dbDumpRecords(DBBASE *pdbbase) void dbDumpRecords(DBBASE *pdbbase)
{ {
DBENTRY *pdbentry; DBENTRY *pdbentry;
...@@ -1202,9 +1018,8 @@ int main(int argc,char *argv[]) ...@@ -1202,9 +1018,8 @@ int main(int argc,char *argv[])
if(argc>=2) { if(argc>=2) {
iocsh(argv[1]); iocsh(argv[1]);
printf("Executing post script commands\n"); // printf("Executing post script commands\n");
dbDumpRecords(*iocshPpdbbase); dbDumpRecords(*iocshPpdbbase);
init_vars();
// Get environment variables from startup command to formulate EPICS record names. // Get environment variables from startup command to formulate EPICS record names.
char *pref = getenv("PREFIX"); char *pref = getenv("PREFIX");
char *sdfDir = getenv("SDF_DIR"); char *sdfDir = getenv("SDF_DIR");
...@@ -1215,7 +1030,6 @@ int main(int argc,char *argv[]) ...@@ -1215,7 +1030,6 @@ int main(int argc,char *argv[])
char bufile[256]; char bufile[256];
char saveasfilename[128]; char saveasfilename[128];
printf("My prefix is %s\n",pref); printf("My prefix is %s\n",pref);
// sprintf(sdfile, "%s%s%s", sdfDir, sdf,".sdf");
sprintf(sdfile, "%s%s%s", sdfDir, sdf,".snap"); // Initialize with BURT_safe.snap sprintf(sdfile, "%s%s%s", sdfDir, sdf,".snap"); // Initialize with BURT_safe.snap
sprintf(bufile, "%s%s", sdfDir, "fec.snap"); // Initialize table dump file sprintf(bufile, "%s%s", sdfDir, "fec.snap"); // Initialize table dump file
printf("SDF FILE = %s\n",sdfile); printf("SDF FILE = %s\n",sdfile);
...@@ -1292,8 +1106,7 @@ int main(int argc,char *argv[]) ...@@ -1292,8 +1106,7 @@ int main(int argc,char *argv[])
for(;;) { for(;;) {
// Following line is from old alarm monitor version. // Following line is from old alarm monitor version.
// process_alarms(*iocshPpdbbase, pref); usleep(100000);
sleep(1);
// Check for reload request // Check for reload request
status = dbGetField(&reload_addr,DBR_LONG,&request,&ropts,&nvals,NULL); status = dbGetField(&reload_addr,DBR_LONG,&request,&ropts,&nvals,NULL);
// Get File Name // Get File Name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment