コード例 #1
0
ファイル: iso_server.c プロジェクト: nono19710321/libiec61850
static void
closeAllOpenClientConnections(IsoServer self)
{

#if (CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS == -1)
    LinkedList openConnection = LinkedList_getNext(self->openClientConnections);
    while (openConnection != NULL) {
        IsoConnection isoConnection = (IsoConnection) openConnection->data;

        IsoConnection_close(isoConnection);

        openConnection = LinkedList_getNext(openConnection);
    }
#else
    int i;

    for (i = 0; i < CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS; i++) {
        if (self->openClientConnections[i] != NULL) {

            IsoConnection_close(self->openClientConnections[i]);

#if (CONFIG_MMS_SINGLE_THREADED == 1)
            /* if CONFIG_MMS_SINGLE_THREADED == 0 connection instance will be destroyed by connection thread. */
            IsoConnection_destroy(self->openClientConnections[i]);
#endif

        }
    }
#endif
}
コード例 #2
0
ファイル: ied_connection.c プロジェクト: duchuan1/libIEC61850
static void
addVariablesWithFc(char* fc, char* lnName, LinkedList variables, LinkedList lnDirectory)
{
    LinkedList variable = LinkedList_getNext(variables);

    while (variable != NULL) {
        char* variableName = (char*) variable->data;

        char* fcPos = strchr(variableName, '$');

        if (fcPos != NULL) {
            if (memcmp(fcPos + 1, fc, 2) != 0)
                goto next_element;

            int lnNameLen = fcPos - variableName;

            if (strncmp(variableName, lnName, lnNameLen) == 0) {
                char* fcEndPos = strchr(fcPos + 1, '$');

                if (fcEndPos != NULL) {
                    char* nameEndPos = strchr(fcEndPos + 1, '$');

                    if (nameEndPos == NULL)
                        addToStringSet(lnDirectory, copyString(fcEndPos + 1));
                }
            }
        }

        next_element:

        variable = LinkedList_getNext(variable);
    }
}
コード例 #3
0
ファイル: ied_connection.c プロジェクト: duchuan1/libIEC61850
LinkedList /*<char*>*/
IedConnection_getLogicalDeviceList(IedConnection self, IedClientError* error)
{
    *error = IED_ERROR_OK;

    if (self->logicalDevices == NULL) {
        IedConnection_getDeviceModelFromServer(self, error);

        if (*error != IED_ERROR_OK)
            return NULL;
    }

    if (self->logicalDevices != NULL) {
        LinkedList logicalDevice = LinkedList_getNext(self->logicalDevices);

        LinkedList logicalDeviceList = LinkedList_create();

        while (logicalDevice != NULL) {
            ICLogicalDevice* icLogicalDevice = (ICLogicalDevice*) logicalDevice->data;

            char* logicalDeviceName = copyString(icLogicalDevice->name);

            LinkedList_add(logicalDeviceList, logicalDeviceName);

            logicalDevice = LinkedList_getNext(logicalDevice);
        }

        *error = IED_ERROR_OK;
        return logicalDeviceList;
    }
    else {
        *error = IED_ERROR_UNKNOWN;
        return NULL;
    }
}
コード例 #4
0
ファイル: ied_connection.c プロジェクト: duchuan1/libIEC61850
void
IedConnection_getDeviceModelFromServer(IedConnection self, IedClientError* error)
{
    MmsError mmsError = MMS_ERROR_NONE;
    *error = IED_ERROR_OK;

    LinkedList logicalDeviceNames = MmsConnection_getDomainNames(self->connection, &mmsError);

    if (logicalDeviceNames != NULL) {

        if (self->logicalDevices != NULL) {
            LinkedList_destroyDeep(self->logicalDevices, (LinkedListValueDeleteFunction) ICLogicalDevice_destroy);
            self->logicalDevices = NULL;
        }

        LinkedList logicalDevice = LinkedList_getNext(logicalDeviceNames);

        LinkedList logicalDevices = LinkedList_create();

        while (logicalDevice != NULL) {
            char* name = (char*) logicalDevice->data;

            ICLogicalDevice* icLogicalDevice = ICLogicalDevice_create(name);

            LinkedList variables = MmsConnection_getDomainVariableNames(self->connection,
                    &mmsError, name);

            if (variables != NULL)
                ICLogicalDevice_setVariableList(icLogicalDevice, variables);
            else {
                *error = iedConnection_mapMmsErrorToIedError(mmsError);
                break;
            }

            LinkedList dataSets = MmsConnection_getDomainVariableListNames(self->connection,
                    &mmsError, name);

            if (dataSets != NULL)
                ICLogicalDevice_setDataSetList(icLogicalDevice, dataSets);
            else {
                *error = iedConnection_mapMmsErrorToIedError(mmsError);
                break;
            }

            LinkedList_add(logicalDevices, icLogicalDevice);

            logicalDevice = LinkedList_getNext(logicalDevice);
        }

        self->logicalDevices = logicalDevices;

        LinkedList_destroy(logicalDeviceNames);
    }
    else {
        *error = iedConnection_mapMmsErrorToIedError(mmsError);
    }
}
コード例 #5
0
ファイル: iso_server.c プロジェクト: brennane/gridpot
static void
handleClientConnections(IsoServer self)
{
#if (CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS == -1)

#if (CONFIG_MMS_THREADLESS_STACK != 1)
    lockClientConnections(self);
#endif

    LinkedList openConnection = LinkedList_getNext(self->openClientConnections);
    LinkedList lastConnection = self->openClientConnections;

    while (openConnection != NULL) {
        IsoConnection isoConnection = (IsoConnection) openConnection->data;

        if (IsoConnection_isRunning(isoConnection))
            IsoConnection_handleTcpConnection(isoConnection);
        else {
            IsoConnection_destroy(isoConnection);

            lastConnection->next = openConnection->next;

            GLOBAL_FREEMEM(openConnection);
        }

        openConnection = LinkedList_getNext(openConnection);
    }

#if (CONFIG_MMS_THREADLESS_STACK != 1)
    unlockClientConnections(self);
#endif

#else


    int i;

    for (i = 0; i < CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS; i++) {
        if (self->openClientConnections[i] != NULL) {
            if (IsoConnection_isRunning(self->openClientConnections[i])) {

                IsoConnection_handleTcpConnection(self->openClientConnections[i]);
            }
            else {
                IsoConnection_destroy(self->openClientConnections[i]);

                self->openClientConnections[i] = NULL;
            }

        }
    }
#endif /* (CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS == -1) */
}
コード例 #6
0
ファイル: ied_connection.c プロジェクト: duchuan1/libIEC61850
void
IedConnection_createDataSet(IedConnection self, IedClientError* error, char* dataSetReference,
        LinkedList /* <char*> */dataSetElements)
{

    char domainIdBuffer[65];
    char itemIdBuffer[129];

    char* domainId;
    char* itemId;
    bool isAssociationSpecific = false;

    if (dataSetReference[0] != '@') {
        domainId = MmsMapping_getMmsDomainFromObjectReference(dataSetReference, domainIdBuffer);
        itemId = copyStringToBuffer(dataSetReference + strlen(domainId) + 1, itemIdBuffer);
        StringUtils_replace(itemId, '.', '$');
    }
    else {
        itemId = dataSetReference;
        isAssociationSpecific = true;
    }

    MmsError mmsError;

    LinkedList dataSetEntries = LinkedList_create();

    LinkedList dataSetElement = LinkedList_getNext(dataSetElements);

    while (dataSetElement != NULL) {

        MmsVariableAccessSpecification* dataSetEntry =
                MmsMapping_ObjectReferenceToVariableAccessSpec((char*) dataSetElement->data);

        LinkedList_add(dataSetEntries, (void*) dataSetEntry);

        dataSetElement = LinkedList_getNext(dataSetElement);
    }

    if (isAssociationSpecific)
        MmsConnection_defineNamedVariableListAssociationSpecific(self->connection, &mmsError,
                itemId, dataSetEntries);
    else
        MmsConnection_defineNamedVariableList(self->connection, &mmsError,
                domainId, itemId, dataSetEntries);

    /* delete list and all elements */
    LinkedList_destroyDeep(dataSetEntries, (LinkedListValueDeleteFunction) MmsVariableAccessSpecification_destroy);

    *error = iedConnection_mapMmsErrorToIedError(mmsError);
}
コード例 #7
0
void
MmsServer_sendInformationReportVarList(MmsServer self, char* domainId, char* itemId, LinkedList values)
{
	int i;
	LinkedList value;
	AccessResult_t** accessResultList;
	int variableCount;
	InformationReport_t* report;
	MmsPdu_t* mmsPdu = calloc(1, sizeof(MmsPdu_t));

	mmsPdu->present = MmsPdu_PR_unconfirmedPDU;
	mmsPdu->choice.unconfirmedPDU.unconfirmedService.present = UnconfirmedService_PR_informationReport;

	report =  &(mmsPdu->choice.unconfirmedPDU.unconfirmedService.choice.informationReport);
	report->variableAccessSpecification.present = VariableAccessSpecification_PR_variableListName;

	if (domainId != NULL) {
		report->variableAccessSpecification.choice.variableListName.present = ObjectName_PR_domainspecific;
		report->variableAccessSpecification.choice.variableListName.choice.domainspecific.domainId.size = strlen(domainId);
		report->variableAccessSpecification.choice.variableListName.choice.domainspecific.domainId.buf = domainId;
		report->variableAccessSpecification.choice.variableListName.choice.domainspecific.itemId.size = strlen(itemId);
		report->variableAccessSpecification.choice.variableListName.choice.domainspecific.itemId.buf = itemId;
	}
	else {
		report->variableAccessSpecification.choice.variableListName.present = ObjectName_PR_vmdspecific;
		report->variableAccessSpecification.choice.variableListName.choice.vmdspecific.size = strlen(itemId);
		report->variableAccessSpecification.choice.variableListName.choice.vmdspecific.buf = itemId;
	}

	variableCount = LinkedList_size(values);

	accessResultList =
		mmsMsg_createAccessResultsList(mmsPdu, variableCount);

	/* iterate values list and add values to the accessResultList */
	value = LinkedList_getNext(values);

	for (i = 0; i < variableCount; i++) {
		AccessResult_t* accessResult = accessResultList[i];

		mmsMsg_addResultToResultList(accessResult, (MmsValue*) value->data);

		value = LinkedList_getNext(value);
	}

	report->listOfAccessResult.list.array = accessResultList;
	report->listOfAccessResult.list.size = variableCount;
	report->listOfAccessResult.list.count = variableCount;
}
コード例 #8
0
ファイル: mms_read_service.c プロジェクト: brennane/gridpot
static void
deleteValueList(LinkedList values)
{
    LinkedList value = LinkedList_getNext(values);

	while (value != NULL ) {
	    MmsValue* typedValue = (MmsValue*) (value->data);

		MmsValue_deleteConditional(typedValue);

		value = LinkedList_getNext(value);
	}

	LinkedList_destroyStatic(values);
}
コード例 #9
0
ファイル: ied_connection.c プロジェクト: duchuan1/libIEC61850
static bool
addToStringSet(LinkedList set, char* string)
{
    LinkedList element = set;

    while (LinkedList_getNext(element) != NULL) {
        if (strcmp((char*) LinkedList_getNext(element)->data, string) == 0)
            return false;

        element = LinkedList_getNext(element);
    }

    LinkedList_insertAfter(element, string);
    return true;
}
コード例 #10
0
ファイル: map.c プロジェクト: jiajw0426/easyscada
void*
Map_removeEntry(Map map, void* key, bool deleteKey)
{
	LinkedList element = map->entries;
	LinkedList lastElement = element;
	MapEntry* entry;
	void* value = NULL;

	while ((element = LinkedList_getNext(element)) != NULL) {
		entry = (MapEntry*) element->data;

		if (map->compareKeys(key, entry->key) == 0) {
			lastElement->next = element->next;
			value = entry->value;

			if (deleteKey == true)
				free(entry->key);
			free(entry);
			free(element);

			break;
		}

		lastElement = element;
	}

	return value;
}
コード例 #11
0
ファイル: control.c プロジェクト: brennane/gridpot
void
Control_processControlActions(MmsMapping* self, uint64_t currentTimeInMs)
{
    LinkedList element = LinkedList_getNext(self->controlObjects);

    while (element != NULL) {
        ControlObject* controlObject = (ControlObject*) element->data;

        if (controlObject->state == STATE_WAIT_FOR_ACTIVATION_TIME) {

            if (controlObject->operateTime <= currentTimeInMs) {

                if (DEBUG_IED_SERVER)
                    printf("time activated operate: start operation\n");

                controlObject->timeActivatedOperate = false;

                CheckHandlerResult checkResult = CONTROL_ACCEPTED;

                if (controlObject->checkHandler != NULL) { /* perform operative tests */
                    checkResult = controlObject->checkHandler(
                            controlObject->checkHandlerParameter, controlObject->ctlVal, controlObject->testMode,
                            controlObject->interlockCheck, (ClientConnection) controlObject->mmsConnection);
                }

                if (checkResult == CONTROL_ACCEPTED) {
                    executeControlTask(controlObject);
                }
                else {
                    ControlObject_sendLastApplError(controlObject, controlObject->mmsConnection, "Oper",
                    CONTROL_ERROR_NO_ERROR, ADD_CAUSE_BLOCKED_BY_INTERLOCKING,
                            controlObject->ctlNum, controlObject->origin, false);

                    abortControlOperation(controlObject);
                }
            }

        } /* if (controlObject->state == STATE_WAIT_FOR_ACTICATION_TIME) */
        else if (!((controlObject->state == STATE_UNSELECTED) || (controlObject->state == STATE_READY))) {
            executeControlTask(controlObject);
        }

        element = LinkedList_getNext(element);
    }
}
コード例 #12
0
LinkedList
LinkedList_get(LinkedList list, int index)
{
    LinkedList element = LinkedList_getNext(list);

    int i = 0;

    while (i < index) {
        element = LinkedList_getNext(element);

        if (element == NULL)
            return NULL;

        i++;
    }

    return element;
}
コード例 #13
0
ファイル: ied_connection.c プロジェクト: duchuan1/libIEC61850
static void
informationReportHandler(void* parameter, char* domainName,
        char* variableListName, MmsValue* value, bool isVariableListName)
{
    IedConnection self = (IedConnection) parameter;

    if (DEBUG_IED_CLIENT)
        printf("DEBUG_IED_CLIENT: received information report for %s\n", variableListName);

    if (domainName == NULL) {

        if (isVariableListName) {

            private_IedConnection_handleReport(self, value);
        }
        else {
            if (strcmp(variableListName, "LastApplError") == 0)
                handleLastApplErrorMessage(self, value);
            else {
                if (DEBUG_IED_CLIENT)
                    printf("IED_CLIENT: Received unknown variable list report for list: %s\n", variableListName);
            }
        }
    }
    else {
        if (DEBUG_IED_CLIENT)
            printf("IED_CLIENT: RCVD CommandTermination for %s/%s\n", domainName, variableListName);

        LinkedList control = LinkedList_getNext(self->clientControls);

        while (control != NULL) {
           ControlObjectClient object = (ControlObjectClient) control->data;

           char* objectRef = ControlObjectClient_getObjectReference(object);

           if (doesReportMatchControlObject(domainName, variableListName, objectRef))
               private_ControlObjectClient_invokeCommandTerminationHandler(object);

           control = LinkedList_getNext(control);
        }
    }

    MmsValue_delete(value);
}
コード例 #14
0
ファイル: ied_server.c プロジェクト: nono19710321/libiec61850
ClientConnection
private_IedServer_getClientConnectionByHandle(IedServer self, void* serverConnectionHandle)
{
    LinkedList element = LinkedList_getNext(self->clientConnections);
    ClientConnection matchingConnection = NULL;

    while (element != NULL) {
        ClientConnection connection = (ClientConnection) element->data;

        if (private_ClientConnection_getServerConnectionHandle(connection) == serverConnectionHandle) {
            matchingConnection = connection;
            break;
        }

        element = LinkedList_getNext(element);
    }

    return matchingConnection;
}
コード例 #15
0
ファイル: mms_domain.c プロジェクト: rwl/libiec61850
MmsNamedVariableList
MmsDomain_getNamedVariableList(MmsDomain* self, char* variableListName)
{
    MmsNamedVariableList variableList = NULL;

    LinkedList element = LinkedList_getNext(self->namedVariableLists);

    while (element != NULL) {
        MmsNamedVariableList varList = (MmsNamedVariableList) element->data;

        if (strcmp(MmsNamedVariableList_getName(varList), variableListName) == 0) {
            variableList = varList;
            break;
        }

        element = LinkedList_getNext(element);
    }

    return variableList;
}
コード例 #16
0
static void
createNamedVariableListResponse(MmsServerConnection* connection, MmsNamedVariableList namedList,
		int invokeId, ByteBuffer* response, ReadRequest_t* read, VarAccessSpec* accessSpec)
{

	LinkedList /*<MmsValue>*/ values = LinkedList_create();
	LinkedList variables = MmsNamedVariableList_getVariableList(namedList);

	int variableCount = LinkedList_size(variables);

	MmsServer_lockModel(connection->server);

	int i;

	LinkedList variable = LinkedList_getNext(variables);

	for (i = 0; i < variableCount; i++) {

		MmsNamedVariableListEntry variableListEntry = (MmsNamedVariableListEntry) variable->data;

		MmsDomain* variableDomain = MmsNamedVariableListEntry_getDomain(variableListEntry);
		char* variableName = MmsNamedVariableListEntry_getVariableName(variableListEntry);

		MmsTypeSpecification* namedVariable = MmsDomain_getNamedVariable(variableDomain,
				variableName);

		addNamedVariableToResultList(namedVariable, variableDomain, variableName,
								values, connection, NULL);

		variable = LinkedList_getNext(variable);
	}

	if (isSpecWithResult(read)) /* add specification to result */
		encodeReadResponse(connection, invokeId, response, values, accessSpec);
	else
		encodeReadResponse(connection, invokeId, response, values, NULL);

	MmsServer_unlockModel(connection->server);

	deleteValueList(values);
}
コード例 #17
0
ファイル: control.c プロジェクト: pangweishen/SmI_IEC104
ControlObject*
Control_lookupControlObject(MmsMapping* self, MmsDomain* domain, char* lnName, char* objectName)
{
    LinkedList element = LinkedList_getNext(self->controlObjects);

    while (element != NULL) {
        ControlObject* controlObject = (ControlObject*) element->data;

        if (ControlObject_getDomain(controlObject) == domain) {
            if (strcmp(ControlObject_getLNName(controlObject), lnName) == 0) {
                if (strcmp(ControlObject_getName(controlObject), objectName) == 0) {
                    return controlObject;
                }
            }
        }

        element = LinkedList_getNext(element);
    }

    return NULL;
}
コード例 #18
0
MmsNamedVariableList
MmsServerConnection_getNamedVariableList(MmsServerConnection* self, char* variableListName)
{
	//TODO remove code duplication - similar to MmsDomain_getNamedVariableList !
	MmsNamedVariableList variableList = NULL;

	LinkedList element = LinkedList_getNext(self->namedVariableLists);

	while (element != NULL) {
		MmsNamedVariableList varList = (MmsNamedVariableList) element->data;

		if (strcmp(MmsNamedVariableList_getName(varList), variableListName) == 0) {
			variableList = varList;
			break;
		}

		element = LinkedList_getNext(element);
	}

	return variableList;
}
コード例 #19
0
ファイル: ied_connection.c プロジェクト: duchuan1/libIEC61850
void
handleLastApplErrorMessage(IedConnection self, MmsValue* value)
{
    if (DEBUG_IED_CLIENT)
        printf("DEBUG_IED_CLIENT: received LastApplError\n");

    MmsValue* lastApplError = value;
    MmsValue* cntrlObj = MmsValue_getElement(lastApplError, 0);
    MmsValue* error = MmsValue_getElement(lastApplError, 1);
    //MmsValue* origin = MmsValue_getElement(lastApplError, 2);
    MmsValue* ctlNum = MmsValue_getElement(lastApplError, 3);
    MmsValue* addCause = MmsValue_getElement(lastApplError, 4);
    if (DEBUG_IED_CLIENT)
        printf("DEBUG_IED_CLIENT:  CntrlObj: %s\n", MmsValue_toString(cntrlObj));

    if (DEBUG_IED_CLIENT)
        printf("DEBUG_IED_CLIENT:  ctlNum: %u\n", MmsValue_toUint32(ctlNum));

    if (DEBUG_IED_CLIENT)
        printf("DEBUG_IED_CLIENT:  addCause: %i\n", MmsValue_toInt32(addCause));

    if (DEBUG_IED_CLIENT)
        printf("DEBUG_IED_CLIENT:  error: %i\n", MmsValue_toInt32(error));

    self->lastApplError.ctlNum = MmsValue_toUint32(ctlNum);
    self->lastApplError.addCause = MmsValue_toInt32(addCause);
    self->lastApplError.error = MmsValue_toInt32(error);
    LinkedList control = LinkedList_getNext(self->clientControls);
    while (control != NULL) {
        ControlObjectClient object = (ControlObjectClient) control->data;

        char* objectRef = ControlObjectClient_getObjectReference(object);

        if (doesControlObjectMatch(objectRef, MmsValue_toString(cntrlObj)))
            ControlObjectClient_setLastApplError(object, self->lastApplError);

        control = LinkedList_getNext(control);
    }
}
コード例 #20
0
ファイル: ied_connection.c プロジェクト: duchuan1/libIEC61850
LinkedList /*<char*>*/
IedConnection_getLogicalDeviceDirectory(IedConnection self, IedClientError* error,
        char* logicalDeviceName)
{
    if (self->logicalDevices == NULL)
        IedConnection_getDeviceModelFromServer(self, error);

    if (self->logicalDevices == NULL)
        return NULL;

    LinkedList logicalDevice = LinkedList_getNext(self->logicalDevices);

    while (logicalDevice != NULL) {
        ICLogicalDevice* device = (ICLogicalDevice*) logicalDevice->data;

        if (strcmp(device->name, logicalDeviceName) == 0) {
            LinkedList logicalNodeNames = LinkedList_create();

            LinkedList variable = LinkedList_getNext(device->variables);

            while (variable != NULL) {
                char* variableName = (char*) variable->data;

                if (strchr(variableName, '$') == NULL)
                    LinkedList_add(logicalNodeNames, copyString((char*) variable->data));

                variable = LinkedList_getNext(variable);
            }

            return logicalNodeNames;
        }

        logicalDevice = LinkedList_getNext(logicalDevice);
    }

    *error = IED_ERROR_OBJECT_REFERENCE_INVALID;

    return NULL;
}
コード例 #21
0
void
LinkedList_printStringList(LinkedList list)
{
	LinkedList element = list;

	int elementCount = 0;
	char* str;

	while ((element = LinkedList_getNext(element)) != NULL) {
		str = (char*) (element->data);
		printf("%s\n", str);
		elementCount++;
	}
}
コード例 #22
0
LinkedList
LinkedList_insertAfter(LinkedList list, void* data)
{
	LinkedList originalNextElement = LinkedList_getNext(list);

	LinkedList newElement = LinkedList_create();

	newElement->data = data;
	newElement->next = originalNextElement;

	list->next = newElement;

	return newElement;
}
コード例 #23
0
static void
deleteValueList(LinkedList values)
{
	LinkedList value = values;
	MmsValue* typedValue;
	while ((value = LinkedList_getNext(value)) != NULL ) {
		typedValue = (MmsValue*) (value->data);

		if (typedValue->deleteValue == 1) {
			MmsValue_delete(typedValue);
		}
	}
	LinkedList_destroyStatic(values);
}
コード例 #24
0
void
printDataDirectory(char* doRef, IedConnection con, int spaces) {
	IedClientError error;

	LinkedList dataAttributes = IedConnection_getDataDirectory(con, &error, doRef);

	if (dataAttributes != NULL) {
		LinkedList dataAttribute = LinkedList_getNext(dataAttributes);

		while (dataAttribute != NULL) {
			char* daName = (char*) dataAttribute->data;

			printSpaces(spaces);
			printf("DA: %s\n", (char*) dataAttribute->data);

			dataAttribute = LinkedList_getNext(dataAttribute);

			char* daRef = (char*) alloca(129);
			sprintf(daRef, "%s.%s", doRef, daName);
			printDataDirectory(daRef, con, spaces + 2);
		}

	}
}
コード例 #25
0
ファイル: map.c プロジェクト: jiajw0426/easyscada
void*
Map_getEntry(Map map, void* key)
{
	LinkedList element = map->entries;
	MapEntry* entry;

	while ((element = LinkedList_getNext(element)) != NULL) {
		entry = (MapEntry*) element->data;
		if (map->compareKeys(key, entry->key) == 0) {
			return entry->value;
		};
	}

	return NULL;
}
コード例 #26
0
ファイル: map.c プロジェクト: jiajw0426/easyscada
void
Map_deleteDeep(Map map, bool deleteKey, void (*valueDeleteFunction) (void*))
{
	LinkedList element = map->entries;
	MapEntry* entry;

	while ((element = LinkedList_getNext(element)) != NULL) {
		entry = (MapEntry*) element->data;
		if (deleteKey == true)
			free(entry->key);
		valueDeleteFunction(entry->value);
	}

	LinkedList_destroy(map->entries);
	free(map);
}
コード例 #27
0
ファイル: map.c プロジェクト: jiajw0426/easyscada
void
Map_deleteStatic(Map map, bool deleteKey)
{
	LinkedList element = map->entries;
	MapEntry* entry;

	if (deleteKey == true) {
		while ((element = LinkedList_getNext(element)) != NULL) {
			entry = (MapEntry*) element->data;
			free(entry->key);
		}
	}

	LinkedList_destroy(map->entries);
	free(map);
}
コード例 #28
0
ファイル: mms_client_read.c プロジェクト: andy-w/libiec61850
/**
 * Request multiple values of a single domain
 */
int
mmsClient_createReadRequestMultipleValues(char* domainId, LinkedList items,
		ByteBuffer* writeBuffer)
{
	MmsPdu_t* mmsPdu = mmsClient_createConfirmedRequestPdu(1);

	ReadRequest_t* readRequest = createReadRequest(mmsPdu);

	readRequest->specificationWithResult = NULL;

	int valuesCount = LinkedList_size(items);

	ListOfVariableSeq_t** listOfVars = createListOfVariables(readRequest, valuesCount);

	LinkedList item = items;
	char* itemId;
	int i = 0;

	while ((item = LinkedList_getNext(item)) != NULL) {
		itemId = (char*) (item->data);
		listOfVars[i] = createVariableIdentifier(domainId, itemId);
		i++;
	}

	asn_enc_rval_t rval;

	rval = der_encode(&asn_DEF_MmsPdu, mmsPdu,
	            mmsClient_write_out, (void*) writeBuffer);

	if (DEBUG) xer_fprint(stdout, &asn_DEF_MmsPdu, mmsPdu);

	for (i = 0; i < valuesCount; i++) {
		free(listOfVars[i]);
	}
	free(listOfVars);

	readRequest->variableAccessSpecification.choice.listOfVariable.list.count = 0;
	readRequest->variableAccessSpecification.choice.listOfVariable.list.size = 0;
	readRequest->variableAccessSpecification.choice.listOfVariable.list.array = NULL;


	asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0);

	return rval.encoded;
}
コード例 #29
0
ファイル: mms_client_read.c プロジェクト: feuvan/libiec61850
/**
 * Request multiple values of a single domain
 */
int
mmsClient_createReadRequestMultipleValues(uint32_t invokeId, const char* domainId, LinkedList items,
		ByteBuffer* writeBuffer)
{
	MmsPdu_t* mmsPdu = mmsClient_createConfirmedRequestPdu(invokeId);

	ReadRequest_t* readRequest = createReadRequest(mmsPdu);

	readRequest->specificationWithResult = NULL;

	int valuesCount = LinkedList_size(items);

	ListOfVariableSeq_t** listOfVars = createListOfVariables(readRequest, valuesCount);

	LinkedList item = items;

	int i = 0;

	while ((item = LinkedList_getNext(item)) != NULL) {
		listOfVars[i] = createVariableIdentifier(domainId, (char*) (item->data));
		i++;
	}

	asn_enc_rval_t rval;

	rval = der_encode(&asn_DEF_MmsPdu, mmsPdu,
		(asn_app_consume_bytes_f*) mmsClient_write_out, (void*) writeBuffer);

	for (i = 0; i < valuesCount; i++) {
		GLOBAL_FREEMEM(listOfVars[i]);
	}
	GLOBAL_FREEMEM(listOfVars);

	readRequest->variableAccessSpecification.choice.listOfVariable.list.count = 0;
	readRequest->variableAccessSpecification.choice.listOfVariable.list.size = 0;
	readRequest->variableAccessSpecification.choice.listOfVariable.list.array = NULL;


	asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0);

	return rval.encoded;
}
コード例 #30
0
ファイル: reporting.c プロジェクト: vipinvc51288/libIEC61850
void
Reporting_processReportEvents(MmsMapping* self, uint64_t currentTimeInMs)
{
    LinkedList element = self->reportControls;

    while ((element = LinkedList_getNext(element)) != NULL ) {
        ReportControl* rc = (ReportControl*) element->data;

        if (rc->enabled) {
            if (rc->triggerOps & TRG_OPT_GI) {
                if (rc->gi) {
                    updateTimeOfEntry(rc, currentTimeInMs);
                    sendReport(rc, false, true);
                    rc->triggered = false;
                }
            }

            if (rc->triggerOps & TRG_OPT_INTEGRITY) {
                if (rc->intgPd > 0) {
                    if (currentTimeInMs >= rc->nextIntgReportTime) {
                        rc->nextIntgReportTime = currentTimeInMs + rc->intgPd;
                        updateTimeOfEntry(rc, currentTimeInMs);
                        sendReport(rc, true, false);
                        rc->triggered = false;
                    }
                }
            }

            if (rc->triggered) {
                if (currentTimeInMs >= rc->reportTime) {
                    sendReport(rc, false, false);
                    rc->triggered = false;
                }
            }
        }
    }
}