ganz soweit ist es noch nicht. aber ich veröffentliche hier schon mal Teile des Codes für die Allgemeinheit, der letztlich die Analyse machen wird.
Ausführung:
Code unter Unter Script ausführen auf der CCU (oder in einem anderen Editor mit Execute Funktionalität) ausführen
Code: Alles auswählen
!- Programm Konsistenz Checks V0.1
!- Pre Release Extract of SDV 3.07.08 by Black
!- Januar 2018
string sPRG;
string sSDest;
string sCond;
string sSCond;
object oPRG;
object oRule;
object oCond;
object oSCond;
object oDest;
object oSDest;
object oOBJ;
string ivtConst="ivtEmpty,ivtNull,ivtBinary,ivtToggle,ivtFloat,ivtRelScaling,ivtScaling,ivtBitMask,ivtByte,ivtWord,ivtDate,ivtTime,ivtDateTime,,,,ivtInteger,ivtDWord,ivtObjectId,ivtSystemId,ivtString,ivtSceneNumber,ivtCurrentValue,ivtCurrentDateTime,ivtCurrentDate,ivtCurrentTime,ivtSunrise,ivtSunset,ivtDelay,ivtCalMonthly,ivtCalYearly,ivtCalOnce,ivtCalDaily,ivtCalWeekly,ivtDeviceId,ivtSpecialValue";
string ivtCond =",bei,,um,,gleich,von..bis kleiner..,,größer als,größer oder gleich ..,kleiner oder gleich..,ungleich";
integer iType;
object oo;
string indirekt;
integer iRule=1;
integer n=1;
boolean testOK= true;
WriteLine ("ProgrammAnalyse Konsistenz Typen");
WriteLine ("by Black in Jan. 2019");
WriteLine ("Extracted from SDV 3.07.08 by Black")
WriteLine ("--------------------------------------------");
foreach (sPRG,dom.GetObject (ID_PROGRAMS).EnumIDs () ){
oPRG= dom.GetObject (sPRG);
if (oPRG) {
WriteLine ("\tAnalyse Program: " # oPRG.Name () # " [ID: "#oPRG.ID()#"]");
oRule= oPRG.Rule ();
iRule=1;
while (oRule){
foreach (sCond, system.GenerateEnum (0,oRule.RuleConditions().Count()-1)) {
oCond= oRule.RuleCondition (sCond.ToInteger () );
foreach (sSCond, system.GenerateEnum (0,oCond.CndSingleCount ()-1)) {
oSCond= oCond.CndSingleCondition (sSCond);
!- Single Condition erreicht:
if ((oSCond.LeftValType () == ivtSystemId) || (oSCond.LeftValType () == ivtObjectId)) {
oOBJ= dom.GetObject (oSCond.LeftVal() );
if (oOBJ.ValueType()== ivtString) {
if ((oSCond.ConditionType()!= 1) && (oSCond.ConditionType ()!= 5)) {
WriteLine ("\t\tInkonsistenz [SCND-ID: " # oSCond.ID () # "] Rule-Nr: " # iRule # ", CND-Nr: " # (sCond.ToInteger()+1) # ", SCND-Nr: " # (sSCond.ToInteger()+1) # " -- Value: " # oOBJ.ValueType()# " [" # (ivtConst.StrValueByIndex (",",oOBJ.ValueType() )) # "], Condition: " # oSCond.ConditionType() # " [" # (ivtCond.StrValueByIndex (",",oSCond.ConditionType() ) ) # "]" );
}
}
if (oOBJ.ValueType()== ivtBinary) {
if ((oSCond.ConditionType()!= 1)) {
WriteLine ("\t\tInkonsistenz [SCND-ID: " # oSCond.ID () # "] Rule-Nr: " # iRule # ",CND-Nr: " # (sCond.ToInteger()+1) # ", SCND-Nr: " # (sSCond.ToInteger()+1) # " -- Value: " # oOBJ.ValueType()# " [" # (ivtConst.StrValueByIndex (",",oOBJ.ValueType() )) # "], Condition: " # oSCond.ConditionType() # " [" # (ivtCond.StrValueByIndex (",",oSCond.ConditionType() ) ) # "]" );
}
}
if (oOBJ.ValueType()!= oSCond.RightVal1ValType () ) {
WriteLine ("\t\tInkonsistenz [SCND-ID: " # oSCond.ID () # "] Rule-Nr: " # iRule # ",CND-Nr: " # (sCond.ToInteger()+1) # ", SCND-Nr: " # (sSCond.ToInteger()+1) # " -- LeftVal: "# oOBJ.ValueType()# " [" # (ivtConst.StrValueByIndex (",",oOBJ.ValueType() )) # "], RightVal1: " #oSCond.RightVal1ValType () # " [" # (ivtConst.StrValueByIndex (",",oSCond.RightVal1ValType() ) ) # "]" );
}
if (oOBJ.ValueType()!= oSCond.RightVal2ValType () ) {
WriteLine ("\t\tInkonsistenz [SCND-ID: " # oSCond.ID () # "] Rule-Nr: " # iRule # ",CND-Nr: " # (sCond.ToInteger()+1) # ", SCND-Nr: " # (sSCond.ToInteger()+1) # " -- LeftVal: "# oOBJ.ValueType()# " [" # (ivtConst.StrValueByIndex (",",oOBJ.ValueType() )) # "], RightVal2: " #oSCond.RightVal2ValType () # " [" # (ivtConst.StrValueByIndex (",",oSCond.RightVal2ValType() ) ) # "]" );
}
}
}
}
oDest= oRule.RuleDestination ();
if (oDest) {
foreach (sSDest, system.GenerateEnum (0,oDest.DestSingleCount() -1)) {
oSDest= oDest.DestSingleDestination (sSDest.ToInteger () );
if (oSDest) {
!- SingleDestination erreicht
if ((oSDest.DestinationParam() == ivtSystemId) || (oSDest.DestinationParam () == ivtObjectId)) {
indirekt="";
oOBJ= dom.GetObject (oSDest.DestinationDP () );
iType= oSDest.DestinationValueType ();
if ((iType == ivtSystemId) || (iType == ivtObjectId)) {indirekt= " [ID: " # oSDest.DestinationValue () # "] ";oo=dom.GetObject ( oSDest.DestinationValue ()) ; iType= oo.ValueType (); }
if ((oOBJ.ValueType()!= iType) && (iType!=ivtSpecialValue) ) {
WriteLine ("\t\tInkonsistenz [SDEST-ID: " # oSDest.ID () # "] Rule-Nr: " # iRule # ",SDST-Nr: " # (sSDest.ToInteger()+1) # " -- DestinationDP : "# oOBJ.ValueType()# " [" # (ivtConst.StrValueByIndex (",",oOBJ.ValueType() )) # "], DestinationValueType " # indirekt # ": " # iType # " [" # (ivtConst.StrValueByIndex (",",iType ) ) # "]" );
}
}
}
}
}
oRule= oRule.RuleSubRule ();
iRule=iRule+1;
}
}
}
was kommt dabei raus:
Code: Alles auswählen
ProgrammAnalyse Konsistenz Typen
by Black in Jan. 2019
Extracted from SDV 3.07.08 by Black
--------------------------------------------
Analyse Program: Alarmtest [ID: Alarmtest]
Analyse Program: ANBAU_00_ShopStatusOffen [ID: ANBAU_00_ShopStatusOffen]
Analyse Program: ANBAU_03_SetModeAnbau [ID: ANBAU_03_SetModeAnbau]
Analyse Program: ANBAU_04_TempSet [ID: ANBAU_04_TempSet]
Analyse Program: InfoEPaper00 [ID: InfoEPaper00]
Analyse Program: LeavingHome_00 [ID: LeavingHome_00]
Analyse Program: ROLLO_00_AstroTrigger [ID: ROLLO_00_AstroTrigger]
Analyse Program: ROLLO_XX_MasterSollwert [ID: ROLLO_XX_MasterSollwert]
Analyse Program: Stringtest [ID: Stringtest]
Inkonsistenz [SCND-ID: 8631] Rule-Nr: 1, CND-Nr: 1, SCND-Nr: 1 -- Value: 20 [ivtString], Condition: 6 [von..bis kleiner..]
Analyse Program: StringTrigger [ID: StringTrigger]
Analyse Program: SYS_01_BOOT [ID: SYS_01_BOOT]
Analyse Program: SYS_01_MITTERNACHT [ID: SYS_01_MITTERNACHT]
Analyse Program: SYS_01_STAT [ID: SYS_01_STAT]
Analyse Program: SYS_02_SystemZeit [ID: SYS_02_SystemZeit]
Analyse Program: SYS_06_StatusRestore [ID: SYS_06_StatusRestore]
Analyse Program: SYS_99_ServiceMeldungen [ID: SYS_99_ServiceMeldungen]
Analyse Program: test cuxd timer [ID: test cuxd timer]
Analyse Program: TEST Rollo 1 [ID: TEST Rollo 1]
Analyse Program: test2245 [ID: test2245]
Analyse Program: testAlalrm [ID: testAlalrm]
Analyse Program: TestDestinations [ID: TestDestinations]
Inkonsistenz [SDEST-ID: 8594] Rule-Nr: 1,SDST-Nr: 1 -- DestinationDP : 6 [ivtScaling], DestinationValueType [ID: 4079] : 2 [ivtBinary]
Analyse Program: TestDestinations [ID: TestDestinations]
Inkonsistenz [SDEST-ID: 8605] Rule-Nr: 1,SDST-Nr: 1 -- DestinationDP : 6 [ivtScaling], DestinationValueType [ID: 7035] : 20 [ivtString]
Analyse Program: TestEvent [ID: TestEvent]
Analyse Program: TestLocal [ID: TestLocal]
Analyse Program: TestPRGFalsch [ID: TestPRGFalsch]
Analyse Program: TriggerType [ID: TriggerType]
Analyse Program: USV_01_SHUTDOWN [ID: USV_01_SHUTDOWN]
Inkonsistenz [SCND-ID: 2598] Rule-Nr: 1,CND-Nr: 1, SCND-Nr: 1 -- LeftVal: 4 [ivtFloat], RightVal1: 16 [ivtInteger]
Inkonsistenz [SCND-ID: 2598] Rule-Nr: 1,CND-Nr: 1, SCND-Nr: 1 -- LeftVal: 4 [ivtFloat], RightVal2: 16 [ivtInteger]
Inkonsistenz [SDEST-ID: 2600] Rule-Nr: 1,SDST-Nr: 1 -- DestinationDP : 2 [ivtBinary], DestinationValueType : 4 [ivtFloat]
Inkonsistenz [SDEST-ID: 2604] Rule-Nr: 2,SDST-Nr: 1 -- DestinationDP : 2 [ivtBinary], DestinationValueType : 4 [ivtFloat]
Analyse Program: USV_02_SHUTDOWN [ID: USV_02_SHUTDOWN]
Analyse Program: Alarmtest [ID: Alarmtest] ohne weitere Zeilen darunter: alles ist gut
Inkonsistenz [SCND-ID: 8615] Rule-Nr: 1,CND-Nr: 1, SCND-Nr: 1 -- LeftVal: 4 [ivtFloat], RightVal1: 16 [ivtInteger]
Eingerückt dargestellt: da darüberstehende programm hat eine Ungereimtheit:
wo:
Rule: 1 : im ersten Bedingungsteil
Rule: 2 : im zweiten Bedingungsteil (Sonstwenn oder sonst) etc
CND_Nr: 1: im ersten Conditionteil (im ersten block der jeweiligen Rule)
SCND_NR: 2: Die erste Zeile im jeweiligen Block (es ist auch die ID angegeben, im SDV kann die direkt eingegebn werden)
in dieser Singlekondition passt nicht: eine Float wird mit einer Integer verglichen: nicht schön, aber auch nicht sooo tragisch, kann man korrieren. (später mal)
Inkonsistenz [SCND-ID: 8631] Rule-Nr: 1, CND-Nr: 1, SCND-Nr: 1 -- Value: 20 [ivtString], Condition: 6 [von..bis kleiner..]
Den Fall, den wir hier schon mal diskutiert haben, eine Stringvariable als Trigger, dafür mit einer Condition 6. Die Garantie das es nicht funktioniert.
Sollte korrigiert werden
bei Booleans sollte auch cals Condition 5 [bei] stehen, grösser, kleiner was weiss ich kann, muss nicht, aber kann ein Grund für Nicht Funktionieren sein. Sollte auch korrigiert werden.
Destination:
Inkonsistenz [SDEST-ID: 8617] Rule-Nr: 1,SDST-Nr: 1 -- DestinationDP : 2 [ivtBinary], DestinationValueType : 4 [ivtFloat]
Vorgehensweise genau wie oben zum identifizeiren:
hier wird einem Bool ein Float zugewiesen: kann gut gehen, muss nicht. 0= false, also ungleich 0 = true
Inkonsistenz [SDEST-ID: 8605] Rule-Nr: 1,SDST-Nr: 1 -- DestinationDP : 6 [ivtScaling], DestinationValueType [ID: 7035] : 20 [ivtString]
Auch ein Garant dafür, das es nicht funktionieren wird.
Im idealfall tauchen keine Inkonsistenzmeldungen auf.
Ich bin damit aber selber immer noch dran... in ein bisscehn wühlen in den Tiefen.
Black