Bläddra i källkod

The function to calc the size of an ExpandedNodeId has been created.
This function needs to be tested. The body of the test function has been created too.

MaximilianBauer 11 år sedan
förälder
incheckning
45d6ace3e3

+ 1 - 0
open62541Stack/.cproject

@@ -499,6 +499,7 @@
 			</target>
 			<target name="Server" path="src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
 				<buildCommand>make</buildCommand>
+				<buildArguments/>
 				<buildTarget>Server</buildTarget>
 				<stopOnError>true</stopOnError>
 				<useDefaultCommand>true</useDefaultCommand>

+ 7 - 2
open62541Stack/INSTALL

@@ -1,8 +1,8 @@
 Installation Instructions
 *************************
 
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
+Inc.
 
    Copying and distribution of this file, with or without modification,
 are permitted in any medium without royalty provided the copyright
@@ -226,6 +226,11 @@ order to use an ANSI C compiler:
 
 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
 
+   HP-UX `make' updates targets which have the same time stamps as
+their prerequisites, which makes it generally unusable when shipped
+generated files such as `configure' are involved.  Use GNU `make'
+instead.
+
    On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
 parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
 a workaround.  If GNU CC is not installed, it is therefore recommended

+ 41 - 0
open62541Stack/src/opcua_binaryEncDec.c

@@ -1019,6 +1019,47 @@ Int32 encodeExpandedNodeId(UA_ExpandedNodeId *nodeId, Int32 *pos, char *dstBuf)
 	return UA_NO_ERROR;
 }
 
+Int32 ExpandedNodeId_calcSize(UA_ExpandedNodeId *nodeId){
+	Int32 length = 0;
+
+	length += sizeof(UInt32); //nodeId->NodeId.EncodingByte
+
+	switch (nodeId->NodeId.EncodingByte)
+	{
+	case NIEVT_TWO_BYTE:
+		length += sizeof(Byte);//nodeId->NodeId.Identifier.Numeric
+		break;
+	case NIEVT_FOUR_BYTE:
+		length += sizeof(UInt16);//nodeId->NodeId.Identifier.Numeric
+		break;
+	case NIEVT_NUMERIC:
+		length += sizeof(UInt32);//nodeId->NodeId.Identifier.Numeric
+		break;
+	case NIEVT_STRING:
+		//nodeId->NodeId.Identifier.String
+		length += UAString_calcSize(&(nodeId->NodeId.Identifier.String));
+		break;
+	case NIEVT_GUID:
+		//nodeId->NodeId.Identifier.Guid
+		length += UAGuid_calcSize(&(nodeId->NodeId.Identifier.Guid));
+		break;
+	case NIEVT_BYTESTRING:
+		//nodeId->NodeId.Identifier.ByteString
+		length += UAByteString_calcSize(&(nodeId->NodeId.Identifier.ByteString));
+		break;
+	}
+	if (nodeId->NodeId.EncodingByte & NIEVT_NAMESPACE_URI_FLAG)
+	{
+		length += sizeof(UInt16);//nodeId->NodeId.Namespace
+		length += UAString_calcSize(&(nodeId->NamespaceUri));//nodeId->NamespaceUri
+	}
+	if (nodeId->NodeId.EncodingByte & NIEVT_SERVERINDEX_FLAG)
+	{
+		length += sizeof(UInt32); //nodeId->ServerIndex
+	}
+	return length;
+}
+
 Int32 decodeUAStatusCode(char * const buf, Int32 *pos, UA_StatusCode* dst)
 {
 	decoder_decodeBuiltInDatatype(buf, UINT32, pos, dst);

+ 24 - 0
open62541Stack/tests/check_stack.c

@@ -500,6 +500,15 @@ START_TEST(responseHeader_calcSize_test)
 }
 END_TEST
 
+//ToDo: Function needs to be filled
+START_TEST(expandedNodeId_calcSize_test)
+{
+	Int32 valreal = 300;
+	Int32 valcalc = 0;
+	ck_assert_int_eq(valcalc,valreal);
+}
+END_TEST
+
 START_TEST(encodeDataValue_test)
 {
 	UA_DataValue dataValue;
@@ -734,6 +743,15 @@ Suite* testSuite_encodeDataValue()
 	return s;
 }
 
+Suite* testSuite_expandedNodeId_calcSize(void)
+{
+	Suite *s = suite_create("expandedNodeId_calcSize");
+	TCase *tc_core = tcase_create("Core");
+	tcase_add_test(tc_core,expandedNodeId_calcSize_test);
+	suite_add_tcase(s,tc_core);
+	return s;
+}
+
 /*
 Suite* TL_<TESTSUITENAME>(void)
 {
@@ -907,6 +925,12 @@ int main (void)
 	number_failed += srunner_ntests_failed(sr);
 	srunner_free(sr);
 
+	s = testSuite_expandedNodeId_calcSize();
+	sr = srunner_create(s);
+	srunner_run_all(sr,CK_NORMAL);
+	number_failed += srunner_ntests_failed(sr);
+	srunner_free(sr);
+
 	/* <TESTSUITE_TEMPLATE>
 	s =  <TESTSUITENAME>;
 	sr = srunner_create(s);