int SetDeviceFloatValue(char *name, float *value) { int command, j; int ival, ucode, error; short ecode; char mess[ERRMSGLEN + 1]; FORSTR messD = {ERRMSGLEN, 0, 0, mess}; MONITOR_ENTER(serializeAccess, "thread"); int iofunc = 1; if (SetActivCell(name) > - 1) { command = PIO_DEFINE + PIO_EXECUTE + PIO_DELETE; for (j = 0; j < 8; j++) if (ActivCells[0].name[j] < ' ') ActivCells[0].name[j] = ' '; for (j = 0; j < 4; j++) if (ActivCells[0].att[j] < ' ') ActivCells[0].att[j] = ' '; ActivCells[0].io_func = iofunc; ActivCells[0].ub.value = *value; Host2VaxF(&ActivCells[0].ub.value, ActivCells[0].ub.value); error = medmSingleIO(command, value, &ival, &ecode, &ucode); if(ecode != 1) { getErrMsgStr(&ecode, &messD); mess[ERRMSGLEN] = '\0'; C_postMsgEvent(messageWindow, 1, vaPrintf("device <%s> has io-error %d %s\n", name, ecode, mess)); } MONITOR_EXIT(serializeAccess, "thread"); return error; } else { C_postMsgEvent(messageWindow, 1, vaPrintf("device <%s> fec not found\n", name)); MONITOR_EXIT(serializeAccess, "thread"); return 0; } }
int RemoveValueCell(int indx) { MONITOR_ENTER(serializeAccess, "thread"); int status = RemoveCell(ValueCells, indx); MONITOR_EXIT(serializeAccess, "thread"); return status; }
int AddValueCell(char *name, int indx, char *aux) { MONITOR_ENTER(serializeAccess, "thread"); int status = AddCell(name, ValueCells, indx, aux); MONITOR_EXIT(serializeAccess, "thread"); return status; }
static void *Thread() { while (True) { //printf("execute thread with %d cells\n", NumCells); MONITOR_ENTER(serializeAccess, "thread"); if (NumCells > 0) { ExecuteValueCells(); } MONITOR_EXIT(serializeAccess, "thread"); usleep(333000); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// @author NIVIS LLC, Mihaela Goloman, Eduard Erdei /// @brief Adds an alert to the ARMO alert queue /// @param p_pAlert - pointer to an alert type structure /// @param p_pBuf - pointer to a buffer that contains alert data (Alert data len is inside p_pAlert->m_unSize) /// @return service feddback code /// @remarks /// Access level: user level uint8 ARMO_AddAlertToQueue(const ALERT* p_pAlert, const uint8* p_pBuf) { // reset custom alert timer g_unCustomAlarmCounter = CUSTOM_ALERT_PERIOD; uint16 unLen = DMAP_GetAlignedLength( sizeof(ALERT) + p_pAlert->m_unSize ); if (unLen > sizeof(g_aucARMOQueue)) // alert too big; will not fit even if queue is empty return SFC_INVALID_SIZE; if( !g_aARMO[p_pAlert->m_ucCategory].m_ucAlertsDisable && (unLen < sizeof(g_aucARMOQueue)) ) // valid alert { MONITOR_ENTER(); while( (g_pARMOQueueEnd + unLen) > (g_aucARMOQueue + sizeof(g_aucARMOQueue) ) ) // not enough space { // remove first alarm (oldest one); do not check that g_pARMOQueueEnd > g_aucARMOQueue ALERT* pAlert = (ALERT*)g_aucARMOQueue; uint16 unAlertLen = DMAP_GetAlignedLength( sizeof(ALERT) + pAlert->m_unSize ); g_pARMOQueueEnd -= unAlertLen; memmove(g_aucARMOQueue, g_aucARMOQueue+unAlertLen, g_pARMOQueueEnd-g_aucARMOQueue); } ALERT* pNext = (ALERT*)g_pARMOQueueEnd; // copy alert header memcpy(pNext, p_pAlert, sizeof(ALERT)); pNext->m_ucID = ARMO_getNextAlertId( p_pAlert->m_ucCategory ); pNext->m_ulNextSendTAI = 0xFFFFFFFF; // fill the detection time MLSM_GetCrtTaiTime( &pNext->m_stDetectionTime.m_ulSeconds, &pNext->m_stDetectionTime.m_unFract ); // copy alert data memcpy(g_pARMOQueueEnd + sizeof(ALERT), p_pBuf, p_pAlert->m_unSize); g_pARMOQueueEnd += unLen; MONITOR_EXIT(); return SFC_SUCCESS; } return SFC_OBJECT_STATE_CONFLICT; // alerts are disabled for this category }
void ARMO_ProcessAlertAck(uint8 p_ucID) { uint8* pBuf = g_aucARMOQueue; #if ( _UAP_TYPE == UAP_TYPE_ISA100_API ) uint8 ucNeedsUapNotification = 0; #endif g_unAlarmTimeout = 0; // clean alert timeout MONITOR_ENTER(); while ( pBuf < g_pARMOQueueEnd ) { ALERT* pAlert = (ALERT*)pBuf; uint16 unLen = DMAP_GetAlignedLength( sizeof(ALERT) + pAlert->m_unSize ); if(pAlert->m_ucID == p_ucID) // alert found { #if ( _UAP_TYPE == UAP_TYPE_ISA100_API ) if( pAlert->m_unDetObjTLPort != ISA100_DMAP_PORT ) { ucNeedsUapNotification = 1; } #endif // #if ( _UAP_TYPE == UAP_TYPE_ISA100_API ) g_pARMOQueueEnd -= unLen; memmove(pBuf, pBuf+unLen, g_pARMOQueueEnd-pBuf); break; } pBuf += unLen; } MONITOR_EXIT(); #if ( _UAP_TYPE == UAP_TYPE_ISA100_API ) if( ucNeedsUapNotification ) { UAP_NotifyAlertAcknowledge( p_ucID ); } #endif }
int SetDeviceStringValue(char *name, char *data) { int command, i, j; char asc[80]; int ival, ucode, error; short ecode; float value; char mess[ERRMSGLEN + 1]; FORSTR messD = {ERRMSGLEN, 0, 0, mess}; char devS[9], attS[5]; DSC devD = {8, 0, 0, devS}; DSC attD = {4, 0, 0, attS}; F_CMDT_RCRD bitmapping[MAX_RECORDS]; int dim = 16, num; int found = False; MONITOR_ENTER(serializeAccess, "thread"); //printf("SendString %s %s\n", name, data); if (SetActivCell(name) > - 1) { command = PIO_DEFINE + PIO_EXECUTE + PIO_DELETE; for (j = 0; j < 8; j++) if (ActivCells[0].name[j] < ' ') ActivCells[0].name[j] = ' '; for (j = 0; j < 4; j++) if (ActivCells[0].att[j] < ' ') ActivCells[0].att[j] = ' '; memcpy(devS, ActivCells[0].name, 8); memcpy(attS, ActivCells[0].att, 4); num = getCmdNames(&devD, &attD, &dim, bitmapping); for(i = 0; i < num; i++) { char aux[9]; strncpy(aux, bitmapping[i].bitName, 8); aux[8] = '\0'; //printf("%s %s\n", aux, data); if(IsInside(aux, data)) { found = True; //printf("found number=%d bitmapping is %x %x\n", i, bitmapping[i].smask, bitmapping[i].cmask); ActivCells[0].conv = 1; ActivCells[0].io_func = CELL_DIGITAL; ActivCells[0].ub.int2val[0] = (unsigned short) bitmapping[i].smask; ActivCells[0].ub.int2val[1] = (unsigned short) bitmapping[i].cmask; sprintf(asc, "Digital Action on %.8s.%.4s;%d - Data %04x %04x", ActivCells[0].name, ActivCells[0].att, ActivCells[0].conv, (unsigned short) ActivCells[0].ub.int2val[0], (unsigned short) ActivCells[0].ub.int2val[1]); C_postMsgEvent(messageWindow, 1, asc); error = medmSingleIO(command, &value, &ival, &ecode, &ucode); if(ecode != 1) { getErrMsgStr(&ecode, &messD); mess[ERRMSGLEN] = '\0'; C_postMsgEvent(messageWindow, 1, vaPrintf("device <%.8s.%.4s;%d> has io-error %d %s\n", ActivCells[0].name, ActivCells[0].att, ActivCells[0].conv, ecode, mess)); } MONITOR_EXIT(serializeAccess, "thread"); return error; } } if(!found) { sprintf(asc, "device <%.8s.%.4s;%d> no bitpattern found", ActivCells[0].name, ActivCells[0].att, ActivCells[0].conv); C_postMsgEvent(messageWindow, 1, asc); MONITOR_EXIT(serializeAccess, "thread"); return 0; } } else { C_postMsgEvent(messageWindow, 1, vaPrintf("device <%s> fec not found\n", name)); MONITOR_EXIT(serializeAccess, "thread"); return 0; } MONITOR_EXIT(serializeAccess, "thread"); return 0; }