📄 ictautil.c
字号:
if (pstVar->bUserType) theTypeId = pstVar->pstType->typeId; else theTypeId = NULL; if (!pstVar->varPtr) initializeVar (pstVar); status = icDefineClientVariable(pstRemote->remoteId, pstVar->varName, pstVar->varScope, pstVar->iccpType, theTypeId, pstVar->varPtr, (icUserData) pstVar, &pstVar->varId, clientWriteCallBack, clientReadCallBack); if (status) { ICA_Log_Err2("ERROR: icDefineClientVariable status =%d %s", status, icPerror(status)); ICA_Log_ErrC1(" Var = %s", pstVar->varName); } else pstVar->bVarDefined = icTrue; pstVar = (ICTA_VAR_INFO *) list_get_next ((ST_VOID *)pstRemote->clientObj->variableList, (ST_VOID *)pstVar); } } } /************************************************************************//* defAllTGForRemote: define all transfer groups for a remote *//************************************************************************/static void defAllTGForRemote (ICTA_REMOTE_INFO *pstRemote) {ICTA_LINK_INFO *pstLink;ICTA_TRANSFER_INFO *pstTran;ICTA_VAR_LIST *pstVarList;icInt status;icLong startTime;icVariableId theVars[2000];struct timeval tp;int i; printf ("\nDefining All TranGroups for Remote %s", pstRemote->remoteName); ICA_Log_Flow1 ("Defining All TransferGroups for Remote %s", pstRemote->remoteName); if (pstRemote->bIsClient) { pstTran = pstRemote->clientObj->tranGroupList; while (pstTran) { pstLink = findLink (pstRemote, pstTran->linkName); if (pstLink) { if (!pstTran->bGroupDefined) { if (pstTran->bUseStartTime) startTime = pstTran->startTime; else if (pstTran->nStartBuf > 0) { gettimeofday (&tp, (void *) NULL); startTime = tp.tv_sec+pstTran->nStartBuf; } else startTime = 0; pstVarList = pstTran->varList; pstTran->numVars = list_get_sizeof(pstVarList); for (i=0; i<pstTran->numVars; i++) { theVars[i] = pstVarList->pstVariable->varId; pstVarList = (ICTA_VAR_LIST *) list_get_next ((ST_VOID *)pstTran->varList, (ST_VOID *)pstVarList); } status = icDefineTransferGroup(pstLink->linkId, pstTran->bPeriodic, pstTran->nPerInterval, pstTran->nPerOffset, pstTran->bExceptOnly, pstTran->nBufInterval, pstTran->nIntegInterval, pstTran->bCritical, (void*)&startTime, &theVars[0], pstTran->numVars, transRejectCallBack, &pstTran->transferGroupId); if (status) { ICA_Log_Err2("ERROR: DefineTransferGroup status=%d %s\n", status, icPerror(status)); } else { pstTran->bGroupDefined = icTrue; } } /* end if !bGroupDefined */ } /* end if pstLink */ pstTran = (ICTA_TRANSFER_INFO *) list_get_next ((ST_VOID *)pstRemote->clientObj->tranGroupList, (ST_VOID *)pstTran); } /* end while pstTran */ } }/************************************************************************//* defAllMsgForRemote: define all information messages for a remote *//************************************************************************/static void defAllMsgForRemote (ICTA_REMOTE_INFO *pstRemote) {ICTA_MSG_INFO *pstMsg;icInt status; printf ("\nDefining All Messages for Remote %s", pstRemote->remoteName); ICA_Log_Flow1 ("Defining All Messages for Remote %s", pstRemote->remoteName); if (bUseNewB4B8) { if (pstRemote->bIsClient) setupB4Client (pstRemote); if (pstRemote->bIsServer) setupB4Server (pstRemote); return; } if (pstRemote->bIsServer) { pstMsg = pstRemote->serverObj->infoMsgsList; while (pstMsg && !pstMsg->bMsgDefined) { status = icDefineServerMessage(pstRemote->remoteId, pstMsg->nRef, pstMsg->scope, pstMsg->maxMsgSize, &pstMsg->msgId, (icUserData) pstMsg, reqInfoMsgCallBack); if (status) { ICA_Log_Err3("ERROR: DefineServerMessage ref#=%d status = %d %s", pstMsg->nRef, status, icPerror(status)); } else pstMsg->bMsgDefined = icTrue; pstMsg = (ICTA_MSG_INFO *) list_get_next ((ST_VOID *)pstRemote->serverObj->infoMsgsList, (ST_VOID *)pstMsg); } /* end while pstMsg */ } if (pstRemote->bIsClient) { pstMsg = pstRemote->clientObj->infoMsgsList; while (pstMsg && !pstMsg->bMsgDefined) { status = icDefineClientMessage(pstRemote->remoteId, pstMsg->nRef, pstMsg->scope, pstMsg->maxMsgSize, &pstMsg->msgId, (icUserData) pstMsg, recvMsgCallBack); if (status) { ICA_Log_Err3("ERROR: DefineClientMessage ref#=%d status = %d %s", pstMsg->nRef, status, icPerror(status)); } else pstMsg->bMsgDefined = icTrue; pstMsg = (ICTA_MSG_INFO *) list_get_next ((ST_VOID *)pstRemote->clientObj->infoMsgsList, (ST_VOID *)pstMsg); } /* end while pstMsg */ } }/************************************************************************//* defAllDevForRemote: define all devices for a remote *//************************************************************************/static void defAllDevForRemote (ICTA_REMOTE_INFO *pstRemote) {ICTA_DEVICE *pstDevice;icInt status; printf ("\nDefining All Devices for Remote %s", pstRemote->remoteName); ICA_Log_Flow1 ("Defining All Devices for Remote %s", pstRemote->remoteName); if (pstRemote->bIsServer) { pstDevice = pstRemote->serverObj->devicesList; while (pstDevice && !pstDevice->bDeviceDefined) { status = icDefineServerDevice(pstRemote->remoteId, pstDevice->name, pstDevice->scope, pstDevice->type, (icUserData) pstDevice, &pstDevice->deviceId, pstDevice->sbo, selectDevInd, operateDevInd); if (status) { ICA_Log_Err3("ERROR: DefineServerDevice %s status = %d %s", pstDevice->name, status, icPerror(status)); } else { pstDevice->bDeviceDefined = icTrue; status = icAddServerTags (pstDevice->deviceId, icTrue, getDevTagInd, setDevTagInd); if (status) { ICA_Log_Err3("Error: AddServerTags for %s status = %d %s", pstDevice->name, status, icPerror (status)); } } pstDevice = (ICTA_DEVICE *) list_get_next ((ST_VOID *)pstRemote->serverObj->devicesList, (ST_VOID *)pstDevice); } /* end while pstDevice */ } /* end if server */ if (pstRemote->bIsClient) { pstDevice = pstRemote->clientObj->devicesList; while (pstDevice && !pstDevice->bDeviceDefined) { status = icDefineClientDevice(pstRemote->remoteId, pstDevice->name, pstDevice->scope, pstDevice->type, &pstDevice->deviceId, pstDevice->sbo); if (status) { ICA_Log_Err3("ERROR: DefineClientDevice %s status = %d %s", pstDevice->name, status, icPerror(status)); } else { pstDevice->bDeviceDefined = icTrue; status = icAddClientTags (pstDevice->deviceId, icTrue); if (status) { ICA_Log_Err3 ("ERROR: AddClientTags %s status = %d %s", pstDevice->name, status, icPerror (status)); } } pstDevice = (ICTA_DEVICE *) list_get_next ((ST_VOID *)pstRemote->clientObj->devicesList, (ST_VOID *)pstDevice); } /* end while pstDevice */ } /* end if client */ }/************************************************************************//* defAllTAForRemote: define a transfer accounts for a remote *//************************************************************************/ static void defAllTAForRemote (ICTA_REMOTE_INFO *pstRemote) {ICTA_SIMPLE_ACCT *pstAcct;icInt numFloats, numInts, status;icTAVariableId floatIds[50], intIds[50];ICTA_MATRIX_ACCT *pstMatrix;ICTA_LINK_INFO *pstLink;ICTA_TA_CONDITION *pstCond; printf ("\nDefining All Accounts for Remote %s", pstRemote->remoteName); ICA_Log_Flow1 ("Defining All TransferAccounts for Remote %s", pstRemote->remoteName); if (bUseNewB4B8) { if (pstRemote->bIsClient) setupB8Client (pstRemote); if (pstRemote->bIsServer) setupB8Server (pstRemote); return; } if (pstRemote->bIsServer) { pstAcct = pstRemote->serverObj->accountList; while (pstAcct && !pstAcct->bAcctDefined) { status = icDefineServerSimpleAccount(pstRemote->remoteId, pstAcct->nRef, pstAcct->scope, pstAcct->acctType, NULL, pstAcct->valueType, &pstAcct->variableId, (icUserData)pstAcct, sendTACallBack, TACondCallBack); if (status) { ICA_Log_Err3("ERROR: DefineServerAccount %d status = %d %s", pstAcct->nRef, status, icPerror(status)); } else pstAcct->bAcctDefined = icTrue; pstAcct = (ICTA_SIMPLE_ACCT * ) list_get_next ((ST_VOID *)pstRemote->serverObj->accountList, (ST_VOID *)pstAcct); } /* end while pstAcct */ } /* end if server */ if (pstRemote->bIsClient) { /* Define client simple accounts */ pstAcct = pstRemote->clientObj->accountList; while (pstAcct && !pstAcct->bAcctDefined) { status = icDefineClientSimpleAccount(pstRemote->remoteId, pstAcct->nRef, pstAcct->scope, pstAcct->acctType, NULL, pstAcct->valueType, &pstAcct->variableId, (icUserData)pstAcct, recvTACallBack); if (status) { ICA_Log_Err3("ERROR: DefineClientAccount %d status = %d %s", pstAcct->nRef, status, icPerror(status)); } else pstAcct->bAcctDefined = icTrue; pstAcct = (ICTA_SIMPLE_ACCT * ) list_get_next ((ST_VOID *)pstRemote->clientObj->accountList, (ST_VOID *)pstAcct); } /* end while pstAcct */ /* define client matrix accounts */ pstMatrix = pstRemote->clientObj->matrixList; while (pstMatrix && !pstMatrix->bMatrixDefined) { numFloats = 0; numInts = 0; pstAcct = pstRemote->clientObj->accountList; while (pstAcct) { if (pstAcct->matrixRef == pstMatrix->matrixRef) { switch (pstAcct->valueType) { case IC_INTEGER_ACCOUNT: intIds[numInts++] = pstAcct->variableId; break; case IC_FLOAT_ACCOUNT: floatIds[numFloats++] = pstAcct->variableId; break; } /* end switch */ } /* end if */ pstAcct = (ICTA_SIMPLE_ACCT *) list_get_next ((ST_VOID *)pstRemote->clientObj->accountList, (ST_VOID *)pstAcct); } /* end while pstAcct */ /* make the API call */ if (numFloats+numInts >0) { status = icDefineClientMatrixAccount (pstRemote->remoteId, pstMatrix->matrixRef, pstMatrix->matrixScope, numFloats, floatIds, numInts, intIds, &pstMatrix->variableId, (icUserData)pstMatrix); if (status != IC_OK) { printf("\nDefineClientMatrixAccount for %d status %d '%s'", pstMatrix->matrixRef, status, icPerror(status)); ICA_Log_Err3("ERROR: DefineClientMatrixAccount %d status = %d %s", pstMatrix->matrixRef, status, icPerror(status)); } else { pstMatrix->bMatrixDefined = icTrue; } } pstMatrix = (ICTA_MATRIX_ACCT *) list_get_next ((ST_VOID *)pstRemote->clientObj->matrixList, (ST_VOID *)pstMatrix); } /* end while pstMatrix */ /* define transfer account conditions */ pstCond = pstRemote->clientObj->conditionList; while (pstCond && !pstCond->bCondDefined) { pstLink = findLink(pstRemote, pstCond->linkName); if (!pstLink) { ICA_Log_Err1("Define Conditions: Link %s Not Found.", pstCond->linkName); } else { pstAcct = pstRemote->clientObj->accountList; /* any acct will do*/ if (!pstAcct) { ICA_Log_Err0("Define Conditions: Account Not Found.") } else { status = icDefineTAConditions(pstLink->linkId, pstAcct->variableId, pstCond->condition); if (status) { ICA_Log_Err2("ERROR: Define Conditions status %d %s", status, icPerror(status)); } else pstCond->bCondDefined = icTrue; } } pstCond = (ICTA_TA_CONDITION *) list_get_next ((ST_VOID *)pstRemote->clientObj->conditionList, (ST_VOID *)pstCond); } /* end while pstCond */ } /* end if client */ }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -