/////////////////////////////////////////////////////////////// void printAllAliases(){ dyn_string dps,ali; int nAliases; nAliases = getAllDpAliases(dps,ali); DebugN(" nAliases " + nAliases); // for(int i=1; i<= nAliases; i++){ // stupid PVSS indexing for(int i=400; i<=nAliases; i++){ // stupid PVSS indexing DebugN(" i " + i + " dp: " + dps[i] + " alias " + ali[i]); } return; } /////////////////////////////////////////////////////////////// void printSettingsToFile(){ DebugN(" in printSettings"); int nSM = 2; int nStacks = 5; int nLayers = 6; int nHVType = 2; dyn_string strSM; strSM[1] = "Supermodule00"; strSM[2] = "Supermodule08"; dyn_string strStack; strStack[1] = "Stack0"; strStack[2] = "Stack1"; strStack[3] = "Stack2"; strStack[4] = "Stack3"; strStack[5] = "Stack4"; dyn_string strLayer; strLayer[1] = "Layer0"; strLayer[2] = "Layer1"; strLayer[3] = "Layer2"; strLayer[4] = "Layer3"; strLayer[5] = "Layer4"; strLayer[6] = "Layer5"; dyn_string strType; strType[1] = "Anode"; strType[2] = "Drift"; int count = 0; // output: dyn_string outLogical; dyn_string outChannel; dyn_float outVSet; dyn_float outVAlarm1; dyn_float outVAlarm2; dyn_float outISet; dyn_float outITrip; dyn_float outIAlarm; dyn_bool outIsOnAlarmV; dyn_bool outIsOnAlarmI; int index = 1; for(int iSM=1; iSM<=nSM; iSM++){ for(int iStack=1; iStack<=nStacks; iStack++){ for(int iLayer=1; iLayer<=nLayers; iLayer++){ for(int iHV=1; iHV<=nHVType; iHV++){ string strchannelLog = strSM[iSM] + "/" + strStack[iStack] + "/" + strLayer[iLayer] + "/" + strType[iHV] + "/" + strType[iHV] + strLayer[iLayer]; string strchannel = dpAliasToName(strchannelLog); string Logical = strchannelLog; //substr(strchannelLog,strlen(strchannelLog)-11) + " "; string Channel = substr(strchannel,strlen(strchannel)-25,24); // DebugN(" strchannelLog " + strchannelLog + " Logical " + Logical); // DebugN(" strchannel " + strchannel + " Channel " + Channel); float VSet = -1; dpGet(strchannel + "Settings.VSet",VSet); float VAlarm1 = -1; dpGet(strchannel + "Actual.VMeas:_alert_hdl.1._u_limit",VAlarm1); float VAlarm2 = -1; dpGet(strchannel + "Actual.VMeas:_alert_hdl.2._u_limit",VAlarm2); float ISet = -1; dpGet(strchannel + "Settings.ISet",ISet); float ITrip = -1; dpGet(strchannel + "Settings.ITrip",ITrip); float IAlarm = -1; dpGet(strchannel + "Actual.IMeas:_alert_hdl.1._u_limit",IAlarm); bool isOnAlarmV = false; dpGet(strchannel + "Actual.VMeas:_alert_hdl.._active",isOnAlarmV); bool isOnAlarmI = false; dpGet(strchannel + "Actual.IMeas:_alert_hdl.._active",isOnAlarmI); // DebugN(" VSet " + VSet + " VAlarm1 " + VAlarm1 + " VAlarm2 " + VAlarm2); // DebugN(" ISet " + ISet + " ITrip " + ITrip + " IAlarm " + IAlarm); // DebugN(" isOnAlarmV " + isOnAlarmV + " isOnAlarmI " + isOnAlarmI); outLogical[index] = Logical; outChannel[index] = Channel; outVSet[index] = VSet; outVAlarm1[index] = VAlarm1; outVAlarm2[index] = VAlarm2; outISet[index] = ISet; outITrip[index] = ITrip; outIAlarm[index] = IAlarm; outIsOnAlarmV[index] = isOnAlarmV; outIsOnAlarmI[index] = isOnAlarmI; index++; } } } } file f; f = fopen("C:/Documents and Settings/obusch/Alarms.txt","w"); // open for reading int err=ferror(f); // export error fprintf(f," channel HWchannel VSet VAlarm1 VAlarm2 isOn Iset ITrip IAlarm isOn "); fprintf(f,"\n"); for(int i=1; i<=dynlen(outLogical); i++){ // stupid PVSS indexing fprintf(f,"%45s %24s %4.02f %4.02f %4.02f %d %4.02f %4.02f %4.02f %d \n", outLogical[i],outChannel[i],outVSet[i],outVAlarm1[i],outVAlarm2[i],outIsOnAlarmV[i], outISet[i],outITrip[i],outIAlarm[i],outIsOnAlarmI); } fclose(f); // close file if (err!=0) DebugN("Error no. ",err," occurred"); } /////////////////////////////////////////////////////////////// void setAlarms(){ // set 3-step alarm: // voltages: 1st thr = 0.5*(USet+UMax) "sense voltage high"/"terminal voltage high" // currents: 1st thr = IMax - 10 or 0.8*IMax if IMax<12.5 // 2nd thr = UMax/IMax // Supermodule08/Stack4/Layer1/Anode/AnodeLayer1 int nSM = 2; int nStacks = 5; int nLayers = 6; int nHVType = 2; dyn_string strSM; strSM[1] = "Supermodule00"; strSM[2] = "Supermodule08"; dyn_string strStack; strStack[1] = "Stack0"; strStack[2] = "Stack1"; strStack[3] = "Stack2"; strStack[4] = "Stack3"; strStack[5] = "Stack4"; dyn_string strLayer; strLayer[1] = "Layer0"; strLayer[2] = "Layer1"; strLayer[3] = "Layer2"; strLayer[4] = "Layer3"; strLayer[5] = "Layer4"; strLayer[6] = "Layer5"; dyn_string strType; strType[1] = "Anode"; strType[2] = "Drift"; int count = 0; for(int iSM=1; iSM<=nSM; iSM++){ for(int iStack=1; iStack<=nStacks; iStack++){ for(int iLayer=1; iLayer<=nLayers; iLayer++){ for(int iHV=1; iHV<=nHVType; iHV++){ string strchannelLog = strSM[iSM] + "/" + strStack[iStack] + "/" + strLayer[iLayer] + "/" + strType[iHV] + "/" + strType[iHV] + strLayer[iLayer]; string strchannel = dpAliasToName(strchannelLog); // first switch alert handling off float alertTypeV; dpGet(strchannel + "Actual.VMeas:_alert_hdl.._type",alertTypeV); float alertTypeI; dpGet(strchannel + "Actual.IMeas:_alert_hdl.._type",alertTypeI); if(alertTypeV != 0){// alarm defined? dpSetWait(strchannel + "Actual.VMeas:_alert_hdl.._active",false); } if(alertTypeI != 0){ dpSetWait(strchannel + "Actual.IMeas:_alert_hdl.._active",false); } bool switchOn = false; // .. and switch on / leave off // voltage: 3-step alarm float ULimit1 = 2500; // dummy limits - should they be negative for drift ? float ULimit2 = 3000; string alertTextU1 = strType[iHV] + " voltage high"; string alertTextU2 = strType[iHV] + " voltage too high"; dpSetWait(strchannel + "Actual.VMeas:_alert_hdl.._type", 13, strchannel + "Actual.VMeas:_alert_hdl.1._type", 4, strchannel + "Actual.VMeas:_alert_hdl.2._type", 4, strchannel + "Actual.VMeas:_alert_hdl.3._type", 4, strchannel + "Actual.VMeas:_alert_hdl.1._u_limit", ULimit1, strchannel + "Actual.VMeas:_alert_hdl.2._u_limit", ULimit2, strchannel + "Actual.VMeas:_alert_hdl.2._l_limit", ULimit1, strchannel + "Actual.VMeas:_alert_hdl.3._l_limit", ULimit2, strchannel + "Actual.VMeas:_alert_hdl.1._u_incl", true, strchannel + "Actual.VMeas:_alert_hdl.2._u_incl", true, strchannel + "Actual.VMeas:_alert_hdl.2._l_incl", false, strchannel + "Actual.VMeas:_alert_hdl.3._l_incl", false, strchannel + "Actual.VMeas:_alert_hdl.1._text", "", strchannel + "Actual.VMeas:_alert_hdl.2._text", alertTextU1, strchannel + "Actual.VMeas:_alert_hdl.3._text", alertTextU2, strchannel + "Actual.VMeas:_alert_hdl.2._class", "trd_hv:_fwWarningAck.", strchannel + "Actual.VMeas:_alert_hdl.3._class", "trd_hv:_fwFatalAck.", strchannel + "Actual.VMeas:_alert_hdl.._orig_hdl", TRUE, strchannel + "Actual.VMeas:_alert_hdl.._active", switchOn); // current: 2-step alarm since for trip dedicated datapoint exists float ITrip = 0; string strILimit = strchannel + "Actual.ITripVal"; dpGet(strILimit,ITrip); float ILimit = 0.8*ITrip; string alertTextI = strType[iHV] + " overcurrent"; dpSetWait(strchannel + "Actual.IMeas:_alert_hdl.._type", 13, strchannel + "Actual.IMeas:_alert_hdl.1._type", 4, strchannel + "Actual.IMeas:_alert_hdl.2._type", 4, strchannel + "Actual.IMeas:_alert_hdl.1._u_limit",ILimit, strchannel + "Actual.IMeas:_alert_hdl.2._l_limit",ILimit, strchannel + "Actual.IMeas:_alert_hdl.1._u_incl", true, strchannel + "Actual.IMeas:_alert_hdl.2._l_incl", false, strchannel + "Actual.IMeas:_alert_hdl.1._text", "", strchannel + "Actual.IMeas:_alert_hdl.2._text", alertTextI, strchannel + "Actual.IMeas:_alert_hdl.2._class", "trd_hv:_fwWarningAck.", strchannel + "Actual.IMeas:_alert_hdl.._orig_hdl", TRUE, strchannel + "Actual.IMeas:_alert_hdl.._active", switchOn); count++; } } } } DebugN(" count : " + count); } /////////////////////////////////////////////////////////////// int main(){ //setAlarms(); //printAllAliases(); printSettingsToFile(); }