Hello, I have the following problem. I'm trying to create error list mapping to a servo drive. The drive sends and integer value which should be turned into text according to a scv file. There are approximately 650 different errors/states that would need to be mapped. Creating tag for each error is obviously out of the question. There can be only one error active at any given time from each drive. If there is another, it will come active once the first one is cleared.
I have only recently started working with InTouch though I have experience with the STL PLC coding and PanelView.
You may wonder why I need the same structure in the second FOR loop. well the errors are of different length so I need to count the offset to the right error.
Things I have noticed so far:
-I currently use 11 tags for the script, I think it will work faster if I add more though I'm wondering if there's a better
-FileReadFields did not seem to work with DIM MESSAGE tags? (hence the number for PLC tags)
-I can use the script asynchronously and it is allowed take some time. The operator rarely is by the screen when the error happen so some time is acceptable
-Currently it's about 500ms (for the last error) on my laptop, though I don't know yet how fast it will be on the final comp.
-SQL database did cross my mind, though that's another area I need to study more. Would it be more efficient? Or easier?
-IndirectTag.NAME does not seem to work with FOR LOOP (It would've saved me lot's of tags and time. Already missing the array[] from 'normal' PLC language. Anyway to dynamically reference the text tags within FOR LOOP?
(script= AlarmText(AlarmNumber) )
DIM found;
DIM Offset;
DIM index;
DIM AlarmNum AS MESSAGE;
found = 0;
Offset = 0;
AlarmNum = StringFromIntg( AlarmNumber, 10 );
FOR index = 0 TO 650 STEP 10
Offset = FileReadFields( "C:\comp path\AlarmNumber.csv", Offset, "text1", 10 );
IF text1 == AlarmNum THEN
found = index;
EXIT FOR;
ENDIF;
IF text2 == AlarmNum THEN
found = index+1;
EXIT FOR;
ENDIF;
IF text3 == AlarmNum THEN
found = index+2;
EXIT FOR;
ENDIF;
IF text4 == AlarmNum THEN
found = index+3;
EXIT FOR;
ENDIF;
IF text5 == AlarmNum THEN
found = index+4;
EXIT FOR;
ENDIF;
IF text6 == AlarmNum THEN
found = index+5;
EXIT FOR;
ENDIF;
IF text7 == AlarmNum THEN
found = index+6;
EXIT FOR;
ENDIF;
IF text8 == AlarmNum THEN
found = index+7;
EXIT FOR;
ENDIF;
IF text9 == AlarmNum THEN
found = index+8;
EXIT FOR;
ENDIF;
IF text10 == AlarmNum THEN
found = index+9;
EXIT FOR;
ENDIF;
NEXT;
Offset = 0;
FOR index = 0 TO 650 STEP 10
Offset = FileReadFields( "C:\comp path\AlarmText.csv", Offset, "text1", 10 );
IF found == index THEN
AlarmName1 = text1;
EXIT FOR;
ENDIF;
IF found == index+1 THEN
AlarmName1 = text2;
EXIT FOR;
ENDIF;
IF found == index+2 THEN
AlarmName1 = text3;
EXIT FOR;
ENDIF;
IF found == index+3 THEN
AlarmName1 = text4;
EXIT FOR;
ENDIF;
IF found == index+4 THEN
AlarmName1 = text5;
EXIT FOR;
ENDIF;
IF found == index+5 THEN
AlarmName1 = text6;
EXIT FOR;
ENDIF;
IF found == index+6 THEN
AlarmName1 = text7;
EXIT FOR;
ENDIF;
IF found == index+7 THEN
AlarmName1 = text8;
EXIT FOR;
ENDIF;
IF found == index+8 THEN
AlarmName1 = text9;
EXIT FOR;
ENDIF;
IF found == index+9 THEN
AlarmName1 = text10;
EXIT FOR;
ENDIF;
NEXT;
I have only recently started working with InTouch though I have experience with the STL PLC coding and PanelView.
You may wonder why I need the same structure in the second FOR loop. well the errors are of different length so I need to count the offset to the right error.
Things I have noticed so far:
-I currently use 11 tags for the script, I think it will work faster if I add more though I'm wondering if there's a better
-FileReadFields did not seem to work with DIM MESSAGE tags? (hence the number for PLC tags)
-I can use the script asynchronously and it is allowed take some time. The operator rarely is by the screen when the error happen so some time is acceptable
-Currently it's about 500ms (for the last error) on my laptop, though I don't know yet how fast it will be on the final comp.
-SQL database did cross my mind, though that's another area I need to study more. Would it be more efficient? Or easier?
-IndirectTag.NAME does not seem to work with FOR LOOP (It would've saved me lot's of tags and time. Already missing the array[] from 'normal' PLC language. Anyway to dynamically reference the text tags within FOR LOOP?
(script= AlarmText(AlarmNumber) )
DIM found;
DIM Offset;
DIM index;
DIM AlarmNum AS MESSAGE;
found = 0;
Offset = 0;
AlarmNum = StringFromIntg( AlarmNumber, 10 );
FOR index = 0 TO 650 STEP 10
Offset = FileReadFields( "C:\comp path\AlarmNumber.csv", Offset, "text1", 10 );
IF text1 == AlarmNum THEN
found = index;
EXIT FOR;
ENDIF;
IF text2 == AlarmNum THEN
found = index+1;
EXIT FOR;
ENDIF;
IF text3 == AlarmNum THEN
found = index+2;
EXIT FOR;
ENDIF;
IF text4 == AlarmNum THEN
found = index+3;
EXIT FOR;
ENDIF;
IF text5 == AlarmNum THEN
found = index+4;
EXIT FOR;
ENDIF;
IF text6 == AlarmNum THEN
found = index+5;
EXIT FOR;
ENDIF;
IF text7 == AlarmNum THEN
found = index+6;
EXIT FOR;
ENDIF;
IF text8 == AlarmNum THEN
found = index+7;
EXIT FOR;
ENDIF;
IF text9 == AlarmNum THEN
found = index+8;
EXIT FOR;
ENDIF;
IF text10 == AlarmNum THEN
found = index+9;
EXIT FOR;
ENDIF;
NEXT;
Offset = 0;
FOR index = 0 TO 650 STEP 10
Offset = FileReadFields( "C:\comp path\AlarmText.csv", Offset, "text1", 10 );
IF found == index THEN
AlarmName1 = text1;
EXIT FOR;
ENDIF;
IF found == index+1 THEN
AlarmName1 = text2;
EXIT FOR;
ENDIF;
IF found == index+2 THEN
AlarmName1 = text3;
EXIT FOR;
ENDIF;
IF found == index+3 THEN
AlarmName1 = text4;
EXIT FOR;
ENDIF;
IF found == index+4 THEN
AlarmName1 = text5;
EXIT FOR;
ENDIF;
IF found == index+5 THEN
AlarmName1 = text6;
EXIT FOR;
ENDIF;
IF found == index+6 THEN
AlarmName1 = text7;
EXIT FOR;
ENDIF;
IF found == index+7 THEN
AlarmName1 = text8;
EXIT FOR;
ENDIF;
IF found == index+8 THEN
AlarmName1 = text9;
EXIT FOR;
ENDIF;
IF found == index+9 THEN
AlarmName1 = text10;
EXIT FOR;
ENDIF;
NEXT;