-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getAllVars function #3
base: develop
Are you sure you want to change the base?
Conversation
cycles through all variables on the plc
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t->Internal.moList.enable = 1; | ||
t->Internal.moList.first = t->Internal.NextVariable; | ||
t->Internal.moList.pAppMoName = (UDINT)t->Internal.AppMoName; | ||
t->Internal.moList.pMoName = (UDINT)t->Internal.MoName; | ||
t->Internal.moList.sizeAppMoName = sizeof(t->Internal.AppMoName); | ||
t->Internal.moList.sizeMoName = sizeof(t->Internal.MoName); | ||
|
||
|
||
|
||
t->Status = xListStatus == ERR_BUR_NOENTRY ? 0 : 65535; | ||
|
||
|
||
t->Internal.moList.status = 0; // Set this to 0 to start the while loop | ||
t->Variable.dataType = VAR_TYPE_UNDEFINED; // Set this to UNDEFINED to start the while loop | ||
|
||
if(t->Internal.NextVariable) { | ||
// Check if variable has global | ||
varRefresh(&t->Variable); | ||
strcpy(t->Variable.name, t->Internal.xList.name); | ||
varGetInfo(&t->Variable); | ||
} | ||
t->Internal.NextVariable = 0; | ||
while (t->Internal.moList.status == 0 && t->Variable.dataType == VAR_TYPE_UNDEFINED) { | ||
|
||
slMoList(&t->Internal.moList); | ||
t->Internal.moList.first = 0; | ||
if(t->Internal.moList.status != 0) break; // Break if error | ||
|
||
// 0x11 = Object of a cyclic resource | ||
// MoName will be empty if its a cyclic not added by User | ||
if(t->Internal.moList.moType != 0x11 || t->Internal.MoName[0] == '\0') continue; | ||
varRefresh(&t->Variable); | ||
strcpy(t->Variable.name, t->Internal.MoName); | ||
strcat(t->Variable.name, ":"); | ||
strcat(t->Variable.name, t->Internal.xList.name); | ||
varGetInfo(&t->Variable); | ||
varGetValue(&t->Variable); | ||
|
||
} | ||
|
||
if(t->Internal.moList.status == ERR_BUR_NOENTRY) { | ||
t->Internal.NextVariable = 1; | ||
} | ||
else if(t->Internal.moList.status && moStatus != 65535 && moStatus != ERR_BUR_NOENTRY) { | ||
t->Status = moStatus; | ||
} | ||
|
||
// if(t->Internal.xList.dimension > 0) { | ||
// strcat(varName, "[0]"); | ||
// } | ||
// else if(t->Internal.xList.data_typ == PB_DT_ARRAY) { | ||
// strcat(varName, "[1]"); | ||
// } | ||
|
||
|
||
} | ||
else { | ||
t->Status = xListStatus; | ||
} | ||
} while(t->Internal.moList.status == ERR_BUR_NOENTRY && xListStatus == 0); | ||
} | ||
else { | ||
variableBrowser(&t->Internal.Browser); | ||
while(t->Internal.iMember[t->Internal.iDeep] > t->Internal.Browser.NumberMembers){ | ||
t->Internal.Browser.Back = 1; | ||
t->Internal.iDeep--; | ||
strcpy(t->Internal.Deep[t->Internal.iDeep], ""); | ||
t->Internal.iMember[t->Internal.iDeep] = 0; | ||
variableBrowser(&t->Internal.Browser); | ||
if(t->Internal.iDeep == 0) { | ||
t->Internal.iDeep = 0; | ||
goto VARIABLE_LOOP; | ||
// break; | ||
// We need to jump back to task loop here | ||
} | ||
} | ||
variableBrowser(&t->Internal.Browser); | ||
memcpy(&t->Variable, &t->Internal.Browser.MemberInfo[t->Internal.iMember[t->Internal.iDeep]], sizeof(t->Variable)); | ||
|
||
t->Internal.iMember[t->Internal.iDeep]++; | ||
if(t->Variable.dataType == VAR_TYPE_STRUCT) { | ||
t->Internal.Browser.MemberIndex = t->Internal.iMember[t->Internal.iDeep]-1; | ||
} | ||
|
||
} | ||
|
||
if(t->Variable.dataType == VAR_TYPE_STRUCT) { | ||
strcpy(t->Internal.Deep[t->Internal.iDeep], t->Variable.name); | ||
if(t->Internal.iDeep == 0) // Name browser will update its own name if we are digging deeper on an existing variable | ||
strcpy(t->Internal.Browser.VariableName, t->Variable.name); | ||
t->Internal.iDeep++; | ||
} | ||
} | ||
|
||
return; | ||
|
||
|
||
} // End Fn // | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to remove this before pushing
void varGetAllVars2(varGetAllVars_typ* t) | |
{ | |
// Check for invalid input | |
if (t == 0) return; | |
if(t->AcknowledgeError && t->Status && t->Status != 65535) { | |
t->Status = 0; | |
} | |
if(t->Execute && t->Status == 0) { | |
t->Internal.iVar = 0xFFFF; | |
t->Status = 65535; | |
t->Internal.NextVariable = 1; | |
} | |
if(t->Status == 65535) { | |
char varName[256]; | |
UINT nextVarIndex; | |
UINT xListStatus = 0; | |
UINT moStatus = 0; | |
VARIABLE_LOOP: | |
if(t->Internal.iDeep == 0) { | |
do { | |
if(t->Internal.NextVariable) { | |
nextVarIndex = t->Internal.iVar+1; | |
xListStatus = PV_xlist(t->Internal.iVar, (UDINT)&nextVarIndex, &t->Internal.xList); | |
t->Internal.iVar = nextVarIndex; | |
} | |
if(xListStatus == 0 || xListStatus == ERR_BUR_NOENTRY) { | |
t->Internal.moList.enable = 1; | |
t->Internal.moList.first = t->Internal.NextVariable; | |
t->Internal.moList.pAppMoName = (UDINT)t->Internal.AppMoName; | |
t->Internal.moList.pMoName = (UDINT)t->Internal.MoName; | |
t->Internal.moList.sizeAppMoName = sizeof(t->Internal.AppMoName); | |
t->Internal.moList.sizeMoName = sizeof(t->Internal.MoName); | |
t->Status = xListStatus == ERR_BUR_NOENTRY ? 0 : 65535; | |
t->Internal.moList.status = 0; // Set this to 0 to start the while loop | |
t->Variable.dataType = VAR_TYPE_UNDEFINED; // Set this to UNDEFINED to start the while loop | |
if(t->Internal.NextVariable) { | |
// Check if variable has global | |
varRefresh(&t->Variable); | |
strcpy(t->Variable.name, t->Internal.xList.name); | |
varGetInfo(&t->Variable); | |
} | |
t->Internal.NextVariable = 0; | |
while (t->Internal.moList.status == 0 && t->Variable.dataType == VAR_TYPE_UNDEFINED) { | |
slMoList(&t->Internal.moList); | |
t->Internal.moList.first = 0; | |
if(t->Internal.moList.status != 0) break; // Break if error | |
// 0x11 = Object of a cyclic resource | |
// MoName will be empty if its a cyclic not added by User | |
if(t->Internal.moList.moType != 0x11 || t->Internal.MoName[0] == '\0') continue; | |
varRefresh(&t->Variable); | |
strcpy(t->Variable.name, t->Internal.MoName); | |
strcat(t->Variable.name, ":"); | |
strcat(t->Variable.name, t->Internal.xList.name); | |
varGetInfo(&t->Variable); | |
varGetValue(&t->Variable); | |
} | |
if(t->Internal.moList.status == ERR_BUR_NOENTRY) { | |
t->Internal.NextVariable = 1; | |
} | |
else if(t->Internal.moList.status && moStatus != 65535 && moStatus != ERR_BUR_NOENTRY) { | |
t->Status = moStatus; | |
} | |
// if(t->Internal.xList.dimension > 0) { | |
// strcat(varName, "[0]"); | |
// } | |
// else if(t->Internal.xList.data_typ == PB_DT_ARRAY) { | |
// strcat(varName, "[1]"); | |
// } | |
} | |
else { | |
t->Status = xListStatus; | |
} | |
} while(t->Internal.moList.status == ERR_BUR_NOENTRY && xListStatus == 0); | |
} | |
else { | |
variableBrowser(&t->Internal.Browser); | |
while(t->Internal.iMember[t->Internal.iDeep] > t->Internal.Browser.NumberMembers){ | |
t->Internal.Browser.Back = 1; | |
t->Internal.iDeep--; | |
strcpy(t->Internal.Deep[t->Internal.iDeep], ""); | |
t->Internal.iMember[t->Internal.iDeep] = 0; | |
variableBrowser(&t->Internal.Browser); | |
if(t->Internal.iDeep == 0) { | |
t->Internal.iDeep = 0; | |
goto VARIABLE_LOOP; | |
// break; | |
// We need to jump back to task loop here | |
} | |
} | |
variableBrowser(&t->Internal.Browser); | |
memcpy(&t->Variable, &t->Internal.Browser.MemberInfo[t->Internal.iMember[t->Internal.iDeep]], sizeof(t->Variable)); | |
t->Internal.iMember[t->Internal.iDeep]++; | |
if(t->Variable.dataType == VAR_TYPE_STRUCT) { | |
t->Internal.Browser.MemberIndex = t->Internal.iMember[t->Internal.iDeep]-1; | |
} | |
} | |
if(t->Variable.dataType == VAR_TYPE_STRUCT) { | |
strcpy(t->Internal.Deep[t->Internal.iDeep], t->Variable.name); | |
if(t->Internal.iDeep == 0) // Name browser will update its own name if we are digging deeper on an existing variable | |
strcpy(t->Internal.Browser.VariableName, t->Variable.name); | |
t->Internal.iDeep++; | |
} | |
} | |
return; | |
} // End Fn // |
cycles through all variables on the plc