UA ANSI C Server Professional  1.4.2.297
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
uaprovider_demo_types_1.c
/******************************************************************************
**
** **************************** auto-generated ****************************
** This code was generated by a tool: UaModeler
** Runtime Version: 1.2.0, using ANSI C SDK 1.4.0 provider template (version 1)
**
** Changes to this file may cause incorrect behavior and will be lost if
** the code is regenerated.
** **************************** auto-generated ****************************
** Copyright (c) 2006-2014 Unified Automation GmbH All rights reserved.
** Web: http://www.unifiedautomation.com
**
** Software License Agreement ("SLA") Version 2.3
**
** Unless explicitly acquired and licensed from Licensor under another
** license, the contents of this file are subject to the Software License
** Agreement ("SLA") Version 2.3, or subsequent versions
** as allowed by the SLA, and You may not copy or use this file in either
** source code or executable form, except in compliance with the terms and
** conditions of the SLA.
**
** All software distributed under the SLA is provided strictly on an
** "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
** AND LICENSOR HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
** LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
** PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the SLA for specific
** language governing rights and limitations under the SLA.
**
** Project: OPC Ansi C DemoProvider for namespace http://www.unifiedautomation.com/DemoServer/
**
** Description: OPC Unified Architecture Software Development Kit.
**
** The complete license agreement can be found here:
** http://unifiedautomation/License/SLA/2.3/
**
** Created: 15.07.2014
**
******************************************************************************/
#include "uaprovider_demo_types_1.h"
/* base */
#include <opcua_platformdefs.h>
#include <opcua_statuscodes.h>
#include <opcua_errorhandling.h>
/* core */
#include <opcua_memory.h>
#include <opcua_string.h>
#include <opcua_guid.h>
/* stack */
#include <opcua_encoder.h>
#include <opcua_decoder.h>
/* types */
#include <opcua_identifiers.h>
#include "uaprovider_demo_identifiers_1.h"
#ifndef OPCUA_EXCLUDE_Demo_HeaterStatus
/*============================================================================
* OpcUa_IdType_EnumeratedType
*===========================================================================*/
static struct _OpcUa_EnumeratedValue g_Demo_HeaterStatus_EnumeratedValues[] =
{
{"Demo_HeaterStatus_Off", 0},
{"Demo_HeaterStatus_Heating", 1},
{"Demo_HeaterStatus_Cooling", 2},
{ OpcUa_Null, 0 }
};
struct _OpcUa_EnumeratedType Demo_HeaterStatus_EnumeratedType =
{
"HeaterStatus",
g_Demo_HeaterStatus_EnumeratedValues
};
#endif /*OPCUA_EXCLUDE_Demo_HeaterStatus*/
#ifndef OPCUA_EXCLUDE_Demo_Vector
/*============================================================================
* Demo_Vector_Initialize
*===========================================================================*/
OpcUa_Void Demo_Vector_Initialize(Demo_Vector* a_pValue)
{
if (a_pValue != OpcUa_Null)
{
OpcUa_Field_Initialize(Double, x);
OpcUa_Field_Initialize(Double, y);
OpcUa_Field_Initialize(Double, z);
}
}
/*============================================================================
* Demo_Vector_Clear
*===========================================================================*/
OpcUa_Void Demo_Vector_Clear(Demo_Vector* a_pValue)
{
if (a_pValue != OpcUa_Null)
{
OpcUa_Field_Clear(Double, x);
OpcUa_Field_Clear(Double, y);
OpcUa_Field_Clear(Double, z);
}
}
/*============================================================================
* Demo_Vector_GetSize
*===========================================================================*/
OpcUa_StatusCode Demo_Vector_GetSize(Demo_Vector* a_pValue, OpcUa_Encoder* a_pEncoder, OpcUa_Int32* a_pSize)
{
OpcUa_Int32 iSize = 0;
OpcUa_InitializeStatus(OpcUa_Module_Serializer, "Vector_GetSize");
OpcUa_ReturnErrorIfArgumentNull(a_pValue);
OpcUa_ReturnErrorIfArgumentNull(a_pEncoder);
OpcUa_ReturnErrorIfArgumentNull(a_pSize);
*a_pSize = -1;
OpcUa_Field_GetSize(Double, x);
OpcUa_Field_GetSize(Double, y);
OpcUa_Field_GetSize(Double, z);
*a_pSize = iSize;
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
*a_pSize = -1;
OpcUa_FinishErrorHandling;
}
/*============================================================================
* Demo_Vector_Encode
*===========================================================================*/
OpcUa_StatusCode Demo_Vector_Encode(Demo_Vector* a_pValue, OpcUa_Encoder* a_pEncoder)
{
OpcUa_InitializeStatus(OpcUa_Module_Serializer, "Vector_Encode");
OpcUa_ReturnErrorIfArgumentNull(a_pValue);
OpcUa_ReturnErrorIfArgumentNull(a_pEncoder);
OpcUa_Field_Write(Double, x);
OpcUa_Field_Write(Double, y);
OpcUa_Field_Write(Double, z);
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
/* nothing to do */
OpcUa_FinishErrorHandling;
}
/*============================================================================
* Demo_Vector_Decode
*===========================================================================*/
OpcUa_StatusCode Demo_Vector_Decode(Demo_Vector* a_pValue, OpcUa_Decoder* a_pDecoder)
{
OpcUa_InitializeStatus(OpcUa_Module_Serializer, "Vector_Decode");
OpcUa_ReturnErrorIfArgumentNull(a_pValue);
OpcUa_ReturnErrorIfArgumentNull(a_pDecoder);
Demo_Vector_Initialize(a_pValue);
OpcUa_Field_Read(Double, x);
OpcUa_Field_Read(Double, y);
OpcUa_Field_Read(Double, z);
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
Demo_Vector_Clear(a_pValue);
OpcUa_FinishErrorHandling;
}
#if OPCUA_ENCODEABLE_OBJECT_COMPARE_SUPPORTED
/*============================================================================
* Demo_Vector_Compare
*===========================================================================*/
OPCUA_EXPORT OpcUa_Int Demo_Vector_Compare(const Demo_Vector* a_pValue1, const Demo_Vector* a_pValue2)
{
if (a_pValue1 == a_pValue2)
{
return 0;
}
OpcUa_Field_Compare(Double, x);
OpcUa_Field_Compare(Double, y);
OpcUa_Field_Compare(Double, z);
return 0;
}
#endif /* OPCUA_ENCODEABLE_OBJECT_COMPARE_SUPPORTED */
#if OPCUA_ENCODEABLE_OBJECT_COPY_SUPPORTED
/*============================================================================
* Demo_Vector_Copy
*===========================================================================*/
OPCUA_EXPORT OpcUa_StatusCode Demo_Vector_Copy(const Demo_Vector* a_pSource, Demo_Vector** a_ppCopy)
{
OpcUa_InitializeStatus(OpcUa_Module_ProxyStub, "Vector_Copy");
OpcUa_ReturnErrorIfArgumentNull(a_pSource);
OpcUa_ReturnErrorIfArgumentNull(a_ppCopy);
*a_ppCopy = OpcUa_Alloc(sizeof( Demo_Vector ));
OpcUa_GotoErrorIfAllocFailed((*a_ppCopy));
uStatus = Demo_Vector_CopyTo(a_pSource, *a_ppCopy);
OpcUa_GotoErrorIfBad(uStatus);
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
if (*a_ppCopy != OpcUa_Null)
{
OpcUa_Free(*a_ppCopy);
*a_ppCopy = OpcUa_Null;
}
OpcUa_FinishErrorHandling;
}
/*============================================================================
* Demo_Vector_CopyTo
*===========================================================================*/
OPCUA_EXPORT OpcUa_StatusCode Demo_Vector_CopyTo(const Demo_Vector* a_pSource, Demo_Vector* a_pDestination)
{
OpcUa_InitializeStatus(OpcUa_Module_ProxyStub, "Vector_CopyTo");
OpcUa_ReturnErrorIfArgumentNull(a_pSource);
OpcUa_ReturnErrorIfArgumentNull(a_pDestination);
Demo_Vector_Initialize(a_pDestination);
OpcUa_Field_CopyToScalar(Double, x);
OpcUa_Field_CopyToScalar(Double, y);
OpcUa_Field_CopyToScalar(Double, z);
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
Demo_Vector_Clear(a_pDestination);
OpcUa_FinishErrorHandling;
}
#endif /* OPCUA_ENCODEABLE_OBJECT_COPY_SUPPORTED */
/*============================================================================
* Demo_Vector_ArrayFromVariant
*===========================================================================*/
OPCUA_EXPORT OpcUa_StatusCode Demo_Vector_ArrayFromVariant(OpcUa_Variant* a_pVariant, OpcUa_Int32 *a_pNoOfValues, Demo_Vector **a_ppValues, OpcUa_Boolean a_bDetach)
{
OpcUa_Int32 i;
Demo_Vector *pValue;
Demo_Vector *pValues;
OpcUa_InitializeStatus(OpcUa_Module_ProxyStub, "Demo_Vector_ArrayFromVariant");
OpcUa_ReturnErrorIfArgumentNull(a_pVariant);
OpcUa_ReturnErrorIfArgumentNull(a_pNoOfValues);
OpcUa_ReturnErrorIfArgumentNull(a_ppValues);
if (!a_pVariant || a_pVariant->ArrayType != OpcUa_VariantArrayType_Array || a_pVariant->Datatype != OpcUaType_ExtensionObject
|| (a_pVariant->Value.Array.Length && !a_pVariant->Value.Array.Value.ExtensionObjectArray) )
{
return OpcUa_BadInvalidArgument;
}
for (i=0; i<a_pVariant->Value.Array.Length; i++)
{
if (a_pVariant->Value.Array.Value.ExtensionObjectArray[i].Encoding != OpcUa_ExtensionObjectEncoding_EncodeableObject
|| !a_pVariant->Value.Array.Value.ExtensionObjectArray[i].Body.EncodeableObject.Type
|| a_pVariant->Value.Array.Value.ExtensionObjectArray[i].Body.EncodeableObject.Type->TypeId != Demo_VectorId)
{
return OpcUa_BadInvalidArgument;
}
}
*a_pNoOfValues = a_pVariant->Value.Array.Length;
pValues = (Demo_Vector*) OpcUa_Alloc((*a_pNoOfValues) * sizeof(Demo_Vector));
OpcUa_ReturnErrorIfAllocFailed(pValues);
for (i=0; i<*a_pNoOfValues; i++)
{
Demo_Vector_Initialize(&pValues[i]);
pValue = (Demo_Vector*) a_pVariant->Value.Array.Value.ExtensionObjectArray[i].Body.EncodeableObject.Object;
if (a_bDetach)
{
pValues[i] = *pValue;
Demo_Vector_Initialize((Demo_Vector*) a_pVariant->Value.Array.Value.ExtensionObjectArray[i].Body.EncodeableObject.Object);
OpcUa_ExtensionObject_Clear(&a_pVariant->Value.Array.Value.ExtensionObjectArray[i]);
}
else
{
Demo_Vector_CopyTo(pValue, &pValues[i]);
}
}
*a_ppValues = pValues;
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
OpcUa_FinishErrorHandling;
}
/*============================================================================
* Demo_Vector_ArrayFromVariant
*===========================================================================*/
OPCUA_EXPORT OpcUa_StatusCode Demo_Vector_ArrayToVariant(OpcUa_Int32 *a_pNoOfValues, Demo_Vector **a_ppValues, OpcUa_Variant* a_pVariant, OpcUa_Boolean a_bAttach)
{
OpcUa_Int32 i;
Demo_Vector *pValue;
OpcUa_InitializeStatus(OpcUa_Module_ProxyStub, "Demo_Vector_ArrayToVariant");
OpcUa_ReturnErrorIfArgumentNull(a_pNoOfValues);
OpcUa_ReturnErrorIfArgumentNull(a_ppValues);
OpcUa_ReturnErrorIfArgumentNull(*a_ppValues);
OpcUa_ReturnErrorIfArgumentNull(a_pVariant);
OpcUa_Variant_Initialize(a_pVariant);
a_pVariant->Datatype = OpcUaType_ExtensionObject;
a_pVariant->ArrayType = OpcUa_VariantArrayType_Array;
a_pVariant->Value.Array.Length = *a_pNoOfValues;
if (*a_pNoOfValues > 0)
{
a_pVariant->Value.Array.Value.ExtensionObjectArray = (OpcUa_ExtensionObject*) OpcUa_Alloc(*a_pNoOfValues * sizeof (OpcUa_ExtensionObject));
OpcUa_ReturnErrorIfAllocFailed(a_pVariant->Value.Array.Value.ExtensionObjectArray);
for (i=0; i<*a_pNoOfValues; i++)
{
OpcUa_ExtensionObject_Initialize(&a_pVariant->Value.Array.Value.ExtensionObjectArray[i]);
OpcUa_EncodeableObject_CreateExtension(&Demo_Vector_EncodeableType, &a_pVariant->Value.Array.Value.ExtensionObjectArray[i], (OpcUa_Void**)&pValue);
if (a_bAttach)
{
OpcUa_MemCpy(pValue, sizeof (Demo_Vector), (*a_ppValues)+i, sizeof(Demo_Vector));
}
else
{
Demo_Vector_CopyTo(a_ppValues[i], pValue);
}
}
if (a_bAttach)
{
OpcUa_Free(*a_ppValues);
*a_pNoOfValues = 0;
*a_ppValues = OpcUa_Null;
}
}
OpcUa_ReturnStatusCode;
OpcUa_BeginErrorHandling;
OpcUa_FinishErrorHandling;
}
/*============================================================================
* Demo_Vector_EncodeableType
*===========================================================================*/
struct _OpcUa_EncodeableType Demo_Vector_EncodeableType =
{
#if !OPCUA_ENCODEABLE_OBJECT_OMIT_TYPE_NAME
"Vector",
#endif /* !OPCUA_ENCODEABLE_OBJECT_OMIT_TYPE_NAME */
Demo_VectorId,
Demo_Vector_Encoding_DefaultBinary,
Demo_Vector_Encoding_DefaultXml,
Demo_NamespaceUri1,
sizeof(Demo_Vector),
(OpcUa_EncodeableObject_PfnInitialize*)Demo_Vector_Initialize,
(OpcUa_EncodeableObject_PfnClear*)Demo_Vector_Clear,
(OpcUa_EncodeableObject_PfnGetSize*)Demo_Vector_GetSize,
(OpcUa_EncodeableObject_PfnEncode*)Demo_Vector_Encode,
(OpcUa_EncodeableObject_PfnDecode*)Demo_Vector_Decode
#if OPCUA_ENCODEABLE_OBJECT_COMPARE_SUPPORTED
,(OpcUa_EncodeableObject_PfnCompare*)Demo_Vector_Compare
#endif /* OPCUA_ENCODEABLE_OBJECT_COMPARE_SUPPORTED */
#if OPCUA_ENCODEABLE_OBJECT_COPY_SUPPORTED
,(OpcUa_EncodeableObject_PfnCopy*)Demo_Vector_Copy,
(OpcUa_EncodeableObject_PfnCopyTo*)Demo_Vector_CopyTo
#endif /* OPCUA_ENCODEABLE_OBJECT_COPY_SUPPORTED */
};
#endif /*OPCUA_EXCLUDE_Demo_Vector*/
/*============================================================================
* Table of known types.
*===========================================================================*/
static OpcUa_EncodeableType* g_Demo_KnownEncodeableTypes1[] =
{
#ifndef OPCUA_EXCLUDE_Demo_Vector
&Demo_Vector_EncodeableType,
#endif
OpcUa_Null
};
OpcUa_EncodeableType** Demo_KnownEncodeableTypes1 = g_Demo_KnownEncodeableTypes1;