/////////////////////////////////////////////////////////////// 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 DebugN(" dp: " + dps[i] + " alias " + ali[i]); } return; } /////////////////////////////////////////////////////////////// void printSettingsToFile(){ DebugN(" in printSettings"); // chambers int nSM = 2; int nConf = 10; dyn_string strSM; strSM[1] = "SM00"; strSM[2] = "SM08"; dyn_string strSMLV; strSMLV[1] = "SM00LowVoltage/SM00LowVoltage"; strSMLV[2] = "SM08LowVoltage/SM08LowVoltage"; dyn_string strConf; strConf[1] = "L01/SMXXL01A1V8"; strConf[2] = "L01/SMXXL01D1V8"; strConf[3] = "L01/SMXXL01A3V3"; strConf[4] = "L23/SMXXL23A1V8"; strConf[5] = "L23/SMXXL23D1V8"; strConf[6] = "L23/SMXXL23A3V3"; strConf[7] = "L45/SMXXL45A1V8"; strConf[8] = "L45/SMXXL45D1V8"; strConf[9] = "L45/SMXXL45A3V3"; strConf[10] = "D3V3/SMXXD3V3"; // output: dyn_string outLogical; dyn_string outChannel; dyn_float outUSet; dyn_float outUSenseMax; dyn_float outUTermMax; dyn_float outIMax; dyn_float outAlarmSense1; dyn_float outAlarmSense2; dyn_float outAlarmTerm1; dyn_float outAlarmTerm2; dyn_float outAlarmCurrent1; dyn_float outAlarmCurrent2; dyn_bool outAlarmIsOnUSense; dyn_bool outAlarmIsOnUTerm; dyn_bool outAlarmIsOnI; int index = 1; for(int iSM = 1; iSM <= nSM; iSM++){ // stupid PVSS indexing for(int iConf = 1; iConf <= nConf; iConf++){ // logial name -> channel string strConfSM = strConf[iConf]; strreplace(strConfSM,"SMXX",strSM[iSM]); string strdpLogical = strSMLV[iSM] + strConfSM; string strdpChannel = dpAliasToName(strdpLogical); // values for ouput string Logical = substr(strdpLogical,strlen(strdpLogical)-11) + " "; if(iConf == nConf) Logical = substr(strdpLogical,strlen(strdpLogical)-8) + " "; string Channel = substr(strdpChannel,strlen(strdpChannel)-22,21); float USet = -1; dpGet(strdpChannel + "Settings.Voltage",USet); float USenseMax = -1; dpGet(strdpChannel + "Settings.SupervisionMaxSenseVoltage",USenseMax); float UTermMax = -1; dpGet(strdpChannel + "Settings.SupervisionMaxTerminalVoltage",UTermMax); float IMax = -1; dpGet(strdpChannel + "Settings.SupervisionMaxCurrent",IMax); float AlarmSense1 = -1; dpGet(strdpChannel + "MeasurementSenseVoltage:_alert_hdl.1._u_limit",AlarmSense1); float AlarmSense2 = -1; dpGet(strdpChannel + "MeasurementSenseVoltage:_alert_hdl.2._u_limit",AlarmSense2); float AlarmTerm1 = -1; dpGet(strdpChannel + "MeasurementTerminalVoltage:_alert_hdl.1._u_limit",AlarmTerm1); float AlarmTerm2 = -1; dpGet(strdpChannel + "MeasurementTerminalVoltage:_alert_hdl.2._u_limit",AlarmTerm2); float AlarmCurrent1 = -1; dpGet(strdpChannel + "MeasurementCurrent:_alert_hdl.1._u_limit",AlarmCurrent1); float AlarmCurrent2 = -1; dpGet(strdpChannel + "MeasurementCurrent:_alert_hdl.2._u_limit",AlarmCurrent2); bool AlarmIsOnUTerm = false; dpGet(strdpChannel + "MeasurementTerminalVoltage:_alert_hdl.._active",AlarmIsOnUTerm); bool AlarmIsOnUSense = false; dpGet(strdpChannel + "MeasurementSenseVoltage:_alert_hdl.._active",AlarmIsOnUSense); bool AlarmIsOnI = false; dpGet(strdpChannel + "MeasurementCurrent:_alert_hdl.._active",AlarmIsOnI); outLogical[index] = Logical; outChannel[index] = Channel; outUSet[index] = USet; outUSenseMax[index] = USenseMax; outUTermMax[index] = UTermMax; outIMax[index] = IMax; outAlarmSense1[index] = AlarmSense1; outAlarmSense2[index] = AlarmSense2; outAlarmTerm1[index] = AlarmTerm1; outAlarmTerm2[index] = AlarmTerm2; outAlarmCurrent1[index] = AlarmCurrent1; outAlarmCurrent2[index] = AlarmCurrent2; outAlarmIsOnUSense[index] = AlarmIsOnUSense; outAlarmIsOnUTerm[index] = AlarmIsOnUTerm; outAlarmIsOnI[index] = AlarmIsOnI; index++; } } // other PDB/PCU int nAliasLogical = 3; dyn_string aliasLogical; aliasLogical[1] = "DCS_PDB/SM0809"; aliasLogical[2] = "DCS_PDB/SM0001"; aliasLogical[3] = "PCU/PCU_LVchB"; for(int iAL = 1; iAL <= nAliasLogical; iAL++){ // stupid PVSS indexing string strdpLogical = aliasLogical[iAL]; string strdpChannel = dpAliasToName(strdpLogical); // values for ouput string Logical = strdpLogical; string Channel = substr(strdpChannel,strlen(strdpChannel)-22,21); float USet = -1; dpGet(strdpChannel + "Settings.Voltage",USet); float USenseMax = -1; dpGet(strdpChannel + "Settings.SupervisionMaxSenseVoltage",USenseMax); float UTermMax = -1; dpGet(strdpChannel + "Settings.SupervisionMaxTerminalVoltage",UTermMax); float IMax = -1; dpGet(strdpChannel + "Settings.SupervisionMaxCurrent",IMax); float AlarmSense1 = -1; dpGet(strdpChannel + "MeasurementSenseVoltage:_alert_hdl.1._u_limit",AlarmSense1); float AlarmSense2 = -1; dpGet(strdpChannel + "MeasurementSenseVoltage:_alert_hdl.2._u_limit",AlarmSense2); float AlarmTerm1 = -1; dpGet(strdpChannel + "MeasurementTerminalVoltage:_alert_hdl.1._u_limit",AlarmTerm1); float AlarmTerm2 = -1; dpGet(strdpChannel + "MeasurementTerminalVoltage:_alert_hdl.2._u_limit",AlarmTerm2); float AlarmCurrent1 = -1; dpGet(strdpChannel + "MeasurementCurrent:_alert_hdl.1._u_limit",AlarmCurrent1); float AlarmCurrent2 = -1; dpGet(strdpChannel + "MeasurementCurrent:_alert_hdl.2._u_limit",AlarmCurrent2); bool AlarmIsOnUTerm = false; dpGet(strdpChannel + "MeasurementTerminalVoltage:_alert_hdl.._active",AlarmIsOnUTerm); bool AlarmIsOnUSense = false; dpGet(strdpChannel + "MeasurementSenseVoltage:_alert_hdl.._active",AlarmIsOnUSense); bool AlarmIsOnI = false; dpGet(strdpChannel + "MeasurementCurrent:_alert_hdl.._active",AlarmIsOnI); outLogical[index] = Logical; outChannel[index] = Channel; outUSet[index] = USet; outUSenseMax[index] = USenseMax; outUTermMax[index] = UTermMax; outIMax[index] = IMax; outAlarmSense1[index] = AlarmSense1; outAlarmSense2[index] = AlarmSense2; outAlarmTerm1[index] = AlarmTerm1; outAlarmTerm2[index] = AlarmTerm2; outAlarmCurrent1[index] = AlarmCurrent1; outAlarmCurrent2[index] = AlarmCurrent2; outAlarmIsOnUSense[index] = AlarmIsOnUSense; outAlarmIsOnUTerm[index] = AlarmIsOnUTerm; outAlarmIsOnI[index] = AlarmIsOnI; // DebugN(" Logical " + Logical + " Channel " + Channel); // DebugN(" Logical " + Logical + " outChannel " + outChannel); // DebugN(" USet " + USet + " USenseMax " + USenseMax + " UTermMax " + UTermMax + " IMax " + IMax); // DebugN(" AlarmSense1 " + AlarmSense1 + " 2 " + AlarmSense2); // DebugN(" AlarmTerm1 " + AlarmTerm1 + " 2 " + AlarmTerm2); // DebugN(" AlarmCurrent1 " + AlarmCurrent1 + " 2 " + AlarmCurrent2); // DebugN(" isOn " + AlarmIsOn); index++; } file f; f = fopen("C:/usr/docs/Alarms.txt","w"); // open for reading int err=ferror(f); // export error fprintf(f," channel HWchannel U_set USense_max UTerm_max I_max USense_al1 USense_al2 isOn UTerm_al1 UTerm_al2 isOn I_al1 I_al2 isOn \n"); fprintf(f,"\n"); for(int i=1; i<=dynlen(outLogical); i++){ // stupid PVSS indexing fprintf(f,"%14s %s %4.02f %4.02f %4.02f %6.2f %4.02f %4.02f %d %4.02f %4.02f %d %6.2f %6.2f %d \n", outLogical[i],outChannel[i],outUSet[i],outUSenseMax[i], outUTermMax[i],outIMax[i], outAlarmSense1[i],outAlarmSense2[i],outAlarmIsOnUSense[i], outAlarmTerm1[i],outAlarmTerm2[i],outAlarmIsOnUTerm[i], outAlarmCurrent1[i],outAlarmCurrent2[i],outAlarmIsOnI[i]); } 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 dyn_string channels = dpNames("trd_lv:Wiener/alidcswie*/Channel*"); int nChannels = dynlen(channels); int count = 0; for(int i=1; i<=nChannels; i++){ // stupid PVSS indexing string strUSet = channels[i] + ".Settings.Voltage"; string strUSenseMax = channels[i] + ".Settings.SupervisionMaxSenseVoltage"; string strUTermMax = channels[i] + ".Settings.SupervisionMaxTerminalVoltage"; string strIMax = channels[i] + ".Settings.SupervisionMaxCurrent"; double USet = 0; double USenseMax = 0; double UTermMax = 0; double IMax = 0; dpGet(strUSet,USet); dpGet(strUSenseMax,USenseMax); dpGet(strUTermMax,UTermMax); dpGet(strIMax,IMax); if(USet>0 && USenseMax > 0 && UTermMax > 0){ // sometimes USet 0.5 and IMax = 2, but USenseMax & UTermMax not set - ignore double UTermLimit1 = 0.5*(USet + UTermMax); double UTermLimit2 = UTermMax; double USenseLimit1 = 0.5*(USet + USenseMax); double USenseLimit2 = USenseMax; double ILimit1 = IMax > 12.5 ? IMax-10 : 0.8*IMax; double ILimit2 = IMax; // DebugN("i " + i + " channels[i] : " + channels[i]); // DebugN("USet " + USet + " USenseMax " + USenseMax + " UTermMax " + UTermMax + " IMax " + IMax); // DebugN("UTermLimit1 " + UTermLimit1 + " UTermLimit2 " + UTermLimit2); // DebugN("USenseLimit1 " + USenseLimit1 + "USenseLimit2 " + USenseLimit2); // DebugN("ILimit1 " + ILimit1 + " ILimit2 " + ILimit2); // first switch alert handling off ... dpSetWait(channels[i] + ".MeasurementSenseVoltage:_alert_hdl.._active",false); dpSetWait(channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.._active",false); dpSetWait(channels[i] + ".MeasurementCurrent:_alert_hdl.._active",false); // alias: check, if channel included in logical view string ali = dpGetAlias(channels[i] + "."); if(ali == "") continue; // ... then redefine bool switchOn = true; // .. and switch on / leave off dpSetWait(channels[i] + ".MeasurementSenseVoltage:_alert_hdl.._type", 13, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.1._type", 4, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.2._type", 4, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.3._type", 4, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.1._u_limit", USenseLimit1, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.2._u_limit", USenseLimit2, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.2._l_limit", USenseLimit1, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.3._l_limit", USenseLimit2, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.1._u_incl", true, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.2._u_incl", true, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.2._l_incl", false, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.3._l_incl", false, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.1._text", "", channels[i] + ".MeasurementSenseVoltage:_alert_hdl.2._text", "sense voltage high ", channels[i] + ".MeasurementSenseVoltage:_alert_hdl.3._text", "sense voltage trip", channels[i] + ".MeasurementSenseVoltage:_alert_hdl.2._class", "trd_lv:_fwWarningAck.", channels[i] + ".MeasurementSenseVoltage:_alert_hdl.3._class", "trd_lv:_fwFatalAck.", channels[i] + ".MeasurementSenseVoltage:_alert_hdl.._orig_hdl", TRUE, channels[i] + ".MeasurementSenseVoltage:_alert_hdl.._active", switchOn); dpSetWait(channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.._type", 13, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.1._type", 4, // Min-Max value range channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.2._type", 4, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.3._type", 4, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.1._u_limit", UTermLimit1, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.2._u_limit", UTermLimit2, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.2._l_limit", UTermLimit1, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.3._l_limit", UTermLimit2, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.1._u_incl", true, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.2._u_incl", true, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.2._l_incl", false, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.3._l_incl", false, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.1._text", "", channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.2._text", "terminal voltage high ", channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.3._text", "terminal voltage trip", channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.2._class", "trd_lv:_fwWarningAck.", channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.3._class", "trd_lv:_fwFatalAck.", channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.._orig_hdl", TRUE, channels[i] + ".MeasurementTerminalVoltage:_alert_hdl.._active", switchOn); dpSetWait(channels[i] + ".MeasurementCurrent:_alert_hdl.._type", 13, channels[i] + ".MeasurementCurrent:_alert_hdl.1._type", 4, // Min-Max value range channels[i] + ".MeasurementCurrent:_alert_hdl.2._type", 4, channels[i] + ".MeasurementCurrent:_alert_hdl.3._type", 4, channels[i] + ".MeasurementCurrent:_alert_hdl.1._u_limit", ILimit1, channels[i] + ".MeasurementCurrent:_alert_hdl.2._u_limit", ILimit2, channels[i] + ".MeasurementCurrent:_alert_hdl.2._l_limit", ILimit1, channels[i] + ".MeasurementCurrent:_alert_hdl.3._l_limit", ILimit2, channels[i] + ".MeasurementCurrent:_alert_hdl.1._u_incl", true, channels[i] + ".MeasurementCurrent:_alert_hdl.2._u_incl", true, channels[i] + ".MeasurementCurrent:_alert_hdl.2._l_incl", false, channels[i] + ".MeasurementCurrent:_alert_hdl.3._l_incl", false, channels[i] + ".MeasurementCurrent:_alert_hdl.1._text", "", channels[i] + ".MeasurementCurrent:_alert_hdl.2._text", "LV overcurrent ", channels[i] + ".MeasurementCurrent:_alert_hdl.3._text", "LV trip", channels[i] + ".MeasurementCurrent:_alert_hdl.2._class", "trd_lv:_fwWarningAck.", channels[i] + ".MeasurementCurrent:_alert_hdl.3._class", "trd_lv:_fwFatalAck.", channels[i] + ".MeasurementCurrent:_alert_hdl.._orig_hdl", TRUE, channels[i] + ".MeasurementCurrent:_alert_hdl.._active", switchOn); count++; } } } /////////////////////////////////////////////////////////////// int main(){ //setAlarms(); //printAllAliases(); printSettingsToFile(); }