V 10 1 LANG:1 0 PANEL,-1 -1 631 271 N "_3DFace" 6 "$ED" "$LAYER" "$SEC" "$ST" "$STACK" "$isAnode" "main(){ //--------------------Define function-------------------------- dyn_int Itype,Vtype; //contains the event types of single values dyn_float Ivalue,Vvalue; //Contains the single values dyn_time Itime,Vtime; //Contains the source time for the values string starttime = $ST; string endtime = $ED; int stack = $STACK; int layer = $LAYER; string rack; string crate; int slot; string tmprack; string tmpcrate; int tmpslot; int sector = $SEC; bool isAnode = $isAnode; dyn_string split; string tmp; anytype fld; dyn_time loctime; int an; time sttime; time edtime; int smslot; string position; dyn_string dp; int rocserial; string roctype; int smid; dyn_int roc_smid; dyn_int roc_smslot; dyn_int roc_stack; dyn_int roc_layer; dyn_time roc_loctime; time tmptime; string dptest; //--------------------------------------------------------------- //----------------Convert Time----------------------------------- split = strsplit(starttime,\"-: \"); sttime = makeTime(split[1],split[2],split[3],split[4],split[5],split[6]); split = strsplit(endtime,\"-: \"); edtime = makeTime(split[1],split[2],split[3],split[4],split[5],split[6]); //--------------------------------------------------------------- //--------------------Set Max and Min of Trending---------------- setValue(\"TREND1\", \"trendStop\"); setValue(\"TREND1\", \"timeInterval\", edtime-sttime); setValue(\"TREND1\", \"timeBegin\", sttime); setValue(\"TREND1\", \"trendRun\"); //--------------------------------------------------------------- //------------------Channel Correction Function------------------ int channel; int modulefactor=0; channel = stack*6+layer; if(channel > 14){ modulefactor = 1; channel = channel - 15; } //--------------------------------------------------------------- //---------------------Define DB Function------------------------- dbConnection con; dbRecordset rec; int rc; string query; string query2; int count; //----------------------------------------------------------------- //Display Sector,Stack and Layer to Indicator in the Trending Window sprintf(tmp,\"Sector%02d Stack%d Layer%d\",sector,stack,layer); Indicator.text = tmp; //----------------------------------------------------------------- //-------------------Connect to the DB----------------------------- DebugTN(\"Connect to the DB\"); rc = dbOpenConnection(\"DSN=trdfero;UID=trdfero;PWD=secret;server=trdro2;port=1521\",con); if(!rc){ DebugTN(\"Connection OK\"); //------------------Convert Sector to SM_ID-------------------------- sprintf(query,\"select * from sm_loc where sm_slot=%d\",sector); rc = dbOpenRecordset(con,query,rec); if(!rc && !dbEOF(rec)){ rc = dbGetField(rec,0,fld); smid = fld; DebugTN(\"selected sm_id = \"+smid); } //------------------------------------------------------------------- //--------------------Get Latest ROC Serial-------------------------- sprintf(query,\"select * from roc_loc where sm_id=%d and sm_stack=%d and sm_layer=%d order by roc_loctime desc\", smid,stack,layer); rc = dbOpenRecordset(con,query,rec); bool getrocserial = false; while(!rc && !dbEOF(rec)&& !getrocserial){ rc = dbGetField(rec,6,fld); if(period(edtime) > period(fld)){ rc = dbGetField(rec,0,fld); roctype=fld; rc = dbGetField(rec,1,fld); rocserial=fld; DebugTN(\"selected roc type = \"+roctype); DebugTN(\"selected roc serial = \"+rocserial); getrocserial = true; } rc = dbMoveNext(rec); } //------------------------------------------------------------------- //--------------------Get ROC Informations--------------------------- sprintf(query,\"select * from roc_loc where roc_serial=%d and roc_type='%s' order by roc_loctime asc\",rocserial,roctype); rc = dbOpenRecordset(con,query,rec); while(!rc && !dbEOF(rec)){ count++; rc = dbGetField(rec,3,fld); roc_smid[count]=fld; rc = dbGetField(rec,4,fld); roc_stack[count]=fld; rc = dbGetField(rec,5,fld); roc_layer[count]=fld; rc = dbGetField(rec,6,fld); roc_loctime[count]=fld; rc = dbMoveNext(rec); } //------------------------------------------------------------------- count = 0; //------------------Get SM_ID and SM_SLOT---------------------------- for(int length=1; length<=dynlen(roc_loctime); length++){ sprintf(query,\"select * from sm_loc where sm_id=%d\",roc_smid[length]); rc = dbOpenRecordset(con,query,rec); if(!rc && !dbEOF(rec)){ rc = dbGetField(rec,1,fld); roc_smslot[length] = fld; } } //------------------------------------------------------------------- int selectcount = 0; //-------------------Get ROC, Cable and SM Informations-------------- for(int length=1; length<=dynlen(roc_loctime); length++){ //------------------Get Cable to SM Informations------------------------------ sprintf(query,\"select * from hv_conn where sm_slot=%d order by loctime asc\",roc_smslot[length]); if(dynlen(roc_loctime) >= length+1){ if(length==1){ rc = dbOpenRecordset(con,query,rec); while(!rc&& !dbEOF(rec)){ rc = dbGetField(rec,0,fld); tmp=fld; split = strsplit(tmp,\"0\"); rack = split[1]; crate = split[2]; for(int sl=0;sl<8;sl++){ sprintf(tmp,\"%d\",sl); if(strpos(split[3],tmp) >=0) slot=sl; } if(split[3] == \"\") slot=0; if((isAnode && slot%2!=0) || (!isAnode && slot%2==0) ){ rc = dbGetField(rec,2,fld); if(period(roc_loctime[length]) <= period(fld) && period(roc_loctime[length+1]) > period(fld)){ count++; loctime[count] = fld; sprintf(dptest,\"trd_hv:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); if(!dpExists(dptest)) sprintf(dptest,\"trd_hv2:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); dp[count] = dptest; } } rc = dbMoveNext(rec); } } if(length > 1){ rc = dbOpenRecordset(con,query,rec); while(!rc&& !dbEOF(rec)){ rc = dbGetField(rec,0,fld); tmp=fld; split = strsplit(tmp,\"0\"); rack = split[1]; crate = split[2]; for(int sl=0;sl<8;sl++){ sprintf(tmp,\"%d\",sl); if(strpos(split[3],tmp) >=0) slot=sl; } if(split[3] == \"\") slot=0; if((isAnode && slot%2!=0) || (!isAnode && slot%2==0) ){ rc = dbGetField(rec,2,fld); if(period(roc_loctime[length]) >= period(fld)){ selectcount++; if(selectcount==1) count++; loctime[count]=roc_loctime[length]; sprintf(dptest,\"trd_hv:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); if(!dpExists(dptest)) sprintf(dptest,\"trd_hv2:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); dp[count] = dptest; } if(period(roc_loctime[length]) <= period(fld) && period(roc_loctime[length+1]) > period(fld)){ count++; loctime[count] = fld; sprintf(dptest,\"trd_hv:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); if(!dpExists(dptest)) sprintf(dptest,\"trd_hv2:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); dp[count] = dptest; } } rc = dbMoveNext(rec); } } } selectcount = 0; if(dynlen(roc_loctime) < length+1){ rc = dbOpenRecordset(con,query,rec); while(!rc&& !dbEOF(rec)){ rc = dbGetField(rec,0,fld); tmp=fld; split = strsplit(tmp,\"0\"); rack = split[1]; crate = split[2]; for(int sl=0;sl<8;sl++){ sprintf(tmp,\"%d\",sl); if(strpos(split[3],tmp) >=0) slot=sl; } if(split[3] == \"\") slot=0; if((isAnode && slot%2!=0) || (!isAnode && slot%2==0) ){ rc = dbGetField(rec,2,fld); if(period(roc_loctime[length]) >= period(fld)){ selectcount++; if(selectcount==1) count++; loctime[count]=roc_loctime[length]; sprintf(dptest,\"trd_hv:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); if(!dpExists(dptest)) sprintf(dptest,\"trd_hv2:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); dp[count] = dptest; DebugTN(\"target dp = \"+dp[count]); } if(period(roc_loctime[length]) <= period(fld) && period(edtime) > period(fld)){ count++; loctime[count] = fld; sprintf(dptest,\"trd_hv:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); if(!dpExists(dptest)) sprintf(dptest,\"trd_hv2:Iseg/can/ra%scr%s/ma%02d/ch%02d.\",rack,crate,slot*2+modulefactor,channel); dp[count] = dptest; DebugTN(\"target dp =\" + dp[count]); } } rc = dbMoveNext(rec); } } } //------------------------------------------------------------------------ //----------------------Plot to the Trending Viewer----------------------- DebugTN(\"Plot to the trending\"); for(int i=1; i<=dynlen(loctime);i++){ if(period(sttime) <= period(loctime[i])) sttime = loctime[i]; if(period(sttime) < period(loctime[i])) continue; if(i+1 <= dynlen(loctime)){ if(period(edtime) >= period(loctime[i+1]) && period(sttime) <= period(loctime[i+1])){ an = dpGetPeriod(sttime,loctime[i+1],0,dp[i]+\"Actual.VMeas\",Vvalue,Vtime,Vtype); if(an !=0 ||dynlen(Vvalue)==0){ TEXT_FIELD1.text = \"dpGetPeriod generated an error or there are no values\"; continue; } an = dpGetPeriod(sttime,loctime[i+1],0,dp[i]+\"Actual.IMeas\",Ivalue,Itime,Itype); if(an !=0 ||dynlen(Ivalue)==0){ TEXT_FIELD1.text = \"dpGetPeriod generated an error or there are no values\"; continue; } for(int n=1; n<=dynlen(Ivalue);n++){ TREND1.curveVals(\"Curve1\",Ivalue[n],Itime[n]); } for(int n=1; n<=dynlen(Vvalue);n++){ TREND1.curveVals(\"Curve2\",Vvalue[n],Vtime[n]); } } if(period(edtime) <= period(loctime[i+1]) && period(sttime) <= period(loctime[i+1])){ an = dpGetPeriod(sttime,edtime,0,dp[i]+\"Actual.VMeas\",Vvalue,Vtime,Vtype); if(an !=0 || dynlen(Vvalue)==0){ TEXT_FIELD1.text = \"dpGetPeriod generated an error or there are no values\"; continue; } an = dpGetPeriod(sttime,edtime,0,dp[i]+\"Actual.IMeas\",Ivalue,Itime,Itype); if(an !=0 || dynlen(Ivalue)==0){ TEXT_FIELD1.text = \"dpGetPeriod generated an error or there are no values\"; continue; } for(int n=1; n<=dynlen(Ivalue);n++){ TREND1.curveVals(\"Curve1\",Ivalue[n],Itime[n]); } for(int n=1; n<=dynlen(Vvalue);n++){ TREND1.curveVals(\"Curve2\",Vvalue[n],Vtime[n]); } } } if(i == dynlen(loctime)){ an = dpGetPeriod(sttime,edtime,0,dp[i]+\"Actual.VMeas\",Vvalue,Vtime,Vtype); if(an !=0 || dynlen(Vvalue)==0){ TEXT_FIELD1.text = \"dpGetPeriod generated an error or there are no values\"; continue; } an = dpGetPeriod(sttime,edtime,0,dp[i]+\"Actual.IMeas\",Ivalue,Itime,Itype); if(an !=0 || dynlen(Ivalue)==0){ TEXT_FIELD1.text = \"dpGetPeriod generated an error or there are no values\"; continue; } for(int n=1; n<=dynlen(Ivalue);n++){ TREND1.curveVals(\"Curve1\",Ivalue[n],Itime[n]); } for(int n=1; n<=dynlen(Vvalue);n++){ TREND1.curveVals(\"Curve2\",Vvalue[n],Vtime[n]); } } } //---------------------------------------------------------------------- dbCloseConnection(con); } DebugTN(\"end\"); } " 0 E E E E 1 -1 -1 0 0 0 ""0 1 E E 2 "CBRef" "1" "EClose" E "" DISPLAY_LAYER, 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 LAYER, 0 1 LANG:1 0 23 0 "TREND1" "" 1 10 28 E E E 1 E 1 E N "_WindowText" E N "_Window" E E E E 1 0 0 0 0 0 E E E 0 1 LANG:1 0 0 1 LANG:1 98 -*-MS Shell Dlg-*-r-normal-*-11-*-100-100-*-*-iso8859-1|-11,0,0,0,505,0,0,0,0,0,0,0,0,MS Shell Dlg 0 "" 8 26 592 244 5 E "main() { /* dyn_float YValue; YValue[1] = 10; YValue[2] = 100; YValue[3] = 50; YValue[4] = 80; YValue[5] = 20; dyn_time t; t[1] = makeTime(2009,7,21,14,50); t[2] = makeTime(2009,7,21,14,51); t[3] = makeTime(2009,7,21,14,52); t[4] = makeTime(2009,7,21,14,53); t[5] = makeTime(2009,7,21,14,54); this.curveVals (\"Curve1\", YValue, t); */ }" 0 E 1 579 N {0,0,0} 0 0 1 0 1 0 2 0 "Curve1" "" 0 2 0 0 1 "3 2 0.0" "%x" 0 1 2 0 E E 1 0 0 3 2 1 LANG:1 7 Current 1 LANG:1 0 1 "" "" 1 0 0 1 0 1 N "Red" 0 0 0 0 0 0 0 0 0 "Curve2" "" 0 2 0 0 1 "3 2 0.0" "%x" 0 1 2 0 E E 1 0 0 3 2 1 LANG:1 7 Voltage 1 LANG:1 0 1 "" "" 1 0 0 1 0 1 N "blue" 0 0 0 0 0 0 0 0 1 1 "%H:%M:%S" "%x" 0 1 0 0 E 1 1 1 0 90 0 20 7200 1 LANG:1 98 -*-MS Shell Dlg-*-r-normal-*-11-*-100-100-*-*-iso8859-1|-11,0,0,0,505,0,0,0,0,0,0,0,0,MS Shell Dlg 0 "" 1 LANG:1 98 -*-MS Shell Dlg-*-r-normal-*-11-*-100-100-*-*-iso8859-1|-11,0,0,0,505,0,0,0,0,0,0,0,0,MS Shell Dlg 0 "" 1 LANG:1 98 -*-MS Shell Dlg-*-r-normal-*-11-*-100-100-*-*-iso8859-1|-11,0,0,0,505,0,0,0,0,0,0,0,0,MS Shell Dlg 0 "" 100 N {0,0,0} 0 0 1 0 1 150 1 5 5 1 2 0 2 1 "Indicator" "" 1 12 12 E E E 1 E 1 E N "_WindowText" E N "_Window" E E E E 3 0 0 0 0 0 E E E 0 1 LANG:1 0 1 "dashclr"N "_Transparent" E E 0 1 1 2 1 E U 1 E 12 12 134 26 1 2 2 "0s" 0 0 0 192 0 0 12 12 1 1 LANG:1 98 -*-MS Shell Dlg-*-r-normal-*-11-*-100-100-*-*-iso8859-1|-11,0,0,0,505,0,0,0,0,0,0,0,0,MS Shell Dlg 0 "" 1 LANG:1 23 SectorXX StackX LayerX 14 2 "TEXT_FIELD1" "" 1 190 10 E E E 1 E 1 E N "_WindowText" E N "_Window" E E E E 5 0 0 0 0 0 E E E 0 1 LANG:1 0 0 1 LANG:1 98 -*-MS Shell Dlg-*-r-normal-*-11-*-100-100-*-*-iso8859-1|-11,0,0,0,505,0,0,0,0,0,0,0,0,MS Shell Dlg 0 "" 188 8 592 29 3 "0s" 0 0 0 0 0 -1 E E E 0 LAYER, 1 1 LANG:1 0 0 LAYER, 2 1 LANG:1 0 0 LAYER, 3 1 LANG:1 0 0 LAYER, 4 1 LANG:1 0 0 LAYER, 5 1 LANG:1 0 0 LAYER, 6 1 LANG:1 0 0 LAYER, 7 1 LANG:1 0 0 0