types.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #ifndef __OPC_UA_MAPPING_TYPES_H__
00012 #define __OPC_UA_MAPPING_TYPES_H__
00013 
00014 #include <opc/ua/protocol/enums.h>
00015 #include <opc/ua/protocol/extension_identifiers.h>
00016 #include <opc/ua/protocol/message_identifiers.h>
00017 #include <opc/ua/protocol/object_ids.h>
00018 #include <opc/ua/protocol/nodeid.h>
00019 #include <opc/ua/protocol/datetime.h>
00020 #include <opc/ua/protocol/status_codes.h>
00021 #include <opc/ua/protocol/reference_ids.h>
00022 
00023 #include <memory>
00024 #include <stdint.h>
00025 #include <string>
00026 #include <vector>
00027 #include <atomic>
00028 
00029 
00030 namespace OpcUa
00031 {
00032 
00033   typedef std::string LocaleId;
00034 
00035   struct ByteString
00036   {
00037     std::vector<uint8_t> Data;
00038 
00039     ByteString()
00040     {
00041     }
00042 
00043     explicit ByteString(const std::vector<uint8_t>& val)
00044       : Data(val)
00045     {
00046     }
00047 
00048     bool operator== (const ByteString& str) const
00049     {
00050       return Data == str.Data;
00051     }
00052 
00053     // For tests
00054 
00055   };
00056 
00057   class IntegerId
00058   {
00059   public:
00060     IntegerId();
00061     IntegerId(const IntegerId& id);
00062     explicit IntegerId(uint32_t num);
00063     IntegerId& operator= (const IntegerId& id);
00064     IntegerId& operator= (uint32_t value);
00065     operator uint32_t() const;
00066 
00067   private:
00068     uint32_t Value;
00069   };
00070 
00071   struct QualifiedName
00072   {
00073     uint16_t NamespaceIndex;
00074     std::string Name; // TODO rename to Text
00075 
00076     QualifiedName()
00077       : NamespaceIndex(0)
00078     {
00079     }
00080 
00081     QualifiedName(uint16_t nameSpace, const std::string& name)
00082       : NamespaceIndex(nameSpace)
00083       , Name(name)
00084     {
00085     }
00086 
00087     QualifiedName(const std::string& name, uint16_t nameSpace)
00088       : NamespaceIndex(nameSpace)
00089       , Name(name)
00090     {
00091     }
00092 
00093     explicit QualifiedName(const std::string& name)
00094       : NamespaceIndex(0)
00095       , Name(name)
00096     {
00097     }
00098 
00099     bool operator== (const QualifiedName& name) const
00100     {
00101       return NamespaceIndex == name.NamespaceIndex && Name == name.Name;
00102     }
00103 
00104     bool operator < (const QualifiedName& name) const
00105     {
00106       if (NamespaceIndex != name.NamespaceIndex)
00107       {
00108         return NamespaceIndex < name.NamespaceIndex;
00109       }
00110       return Name < name.Name;
00111     }
00112   };
00113 
00114   struct RelativePathElement
00115   {
00116     NodeId ReferenceTypeId;
00117     bool IsInverse = false;
00118     bool IncludeSubtypes = false;
00119     QualifiedName TargetName;
00120   };
00121 
00122   struct RelativePath
00123   {
00124     std::vector<RelativePathElement> Elements;
00125   };
00126 
00127   // LocalizedText encoding mask
00128   const uint8_t HAS_LOCALE = 1;
00129   const uint8_t HAS_TEXT = 2;
00130 
00131   struct LocalizedText
00132   {
00133     uint8_t Encoding;
00134     std::string Locale;
00135     std::string Text; // TODO rename to Data
00136 
00137     LocalizedText()
00138       : Encoding(0)
00139     {
00140     }
00141 
00142     explicit LocalizedText(const std::string& text)
00143       : Encoding(HAS_TEXT)
00144       , Text(text)
00145     {
00146     }
00147 
00148     explicit LocalizedText(const char* text)
00149       : Encoding(HAS_TEXT)
00150       , Text(text)
00151     {
00152     }
00153 
00154     LocalizedText(const std::string& text, const std::string& locale)
00155       : Encoding(HAS_TEXT | HAS_LOCALE)
00156       , Locale(locale)
00157       , Text(text)
00158     {
00159     }
00160 
00161     LocalizedText(const char* text, char* locale)
00162       : Encoding(HAS_TEXT | HAS_LOCALE)
00163       , Locale(locale)
00164       , Text(text)
00165     {
00166     }
00167 
00168     bool operator== (const LocalizedText& text) const
00169     {
00170       return Encoding == text.Encoding && Locale == text.Locale && Text == text.Text;
00171     }
00172   };
00173 
00174   struct AdditionalHeader
00175   {
00176     ExpandedNodeId TypeId;
00177     uint8_t Encoding;
00178 
00179     AdditionalHeader()
00180       : Encoding(0)
00181     {
00182     }
00183   };
00184 
00185   struct RequestHeader
00186   {
00187     ExpandedNodeId SessionAuthenticationToken;
00188     DateTime UtcTime;
00189     uint32_t RequestHandle = 0;
00190     uint32_t ReturnDiagnostics = 0;
00191     std::string AuditEntryId;
00192     uint32_t Timeout = 0; // in miliseconds
00193     AdditionalHeader Additional;
00194 
00195     RequestHeader();
00196   };
00197 
00198 
00199   enum DiagnosticInfoMask : uint8_t
00200   {
00201     DIM_NONE                  = 0,
00202     DIM_SYMBOLIC_Id           = 0x1,
00203     DIM_NAMESPACE             = 0x2,
00204     DIM_LOCALIZED_TEXT        = 0x4,
00205     DIM_LOCALE                = 0x8,
00206     DIM_ADDITIONAL_INFO       = 0x10,
00207     DIM_INNER_STATUS_CODE     = 0x20,
00208     DIM_INNER_DIAGNOSTIC_INFO = 0x40
00209   };
00210 
00211   struct DiagnosticInfo
00212   {
00213     DiagnosticInfoMask EncodingMask;
00214     int32_t SymbolicId;
00215     int32_t NamespaceURI;
00216     int32_t LocalizedText;
00217     int32_t Locale;
00218     std::string AdditionalInfo;
00219     StatusCode InnerStatusCode;
00220     std::shared_ptr<DiagnosticInfo> InnerDiagnostics;
00221 
00222     DiagnosticInfo()
00223       : EncodingMask(DiagnosticInfoMask::DIM_NONE)
00224       , SymbolicId(0)
00225       , NamespaceURI(0)
00226       , LocalizedText(0)
00227       , Locale(0)
00228       , InnerStatusCode(StatusCode::Good)
00229     {
00230     }
00231 
00232     bool operator== (const DiagnosticInfo& info) const
00233     {
00234       if (
00235         EncodingMask == info.EncodingMask &&
00236         SymbolicId == info.SymbolicId &&
00237         NamespaceURI == info.NamespaceURI &&
00238         LocalizedText == info.LocalizedText &&
00239         Locale == info.Locale &&
00240         InnerStatusCode == info.InnerStatusCode)
00241       {
00242         if (InnerDiagnostics && info.InnerDiagnostics)
00243           return *InnerDiagnostics == *info.InnerDiagnostics;
00244 
00245         return !InnerDiagnostics && !info.InnerDiagnostics;
00246       }
00247       return false;
00248     }
00249   };
00250 
00251   typedef std::vector<DiagnosticInfo> DiagnosticInfoList;
00252 
00253   struct ResponseHeader
00254   {
00255     DateTime Timestamp;
00256     uint32_t RequestHandle = 0;
00257     StatusCode ServiceResult = StatusCode::Good;
00258     DiagnosticInfo InnerDiagnostics;
00259     std::vector<std::string> StringTable;
00260     AdditionalHeader Additional;
00261 
00262     ResponseHeader();
00263   };
00264 
00265   typedef std::vector<uint8_t> CertificateData;
00266 
00267 //   // TODO Serialization, RawSize
00268 //   struct SignatureData
00269 //   {
00270 //     std::vector<uint8_t> Signature;
00271 //     std::string Algorithm;
00272 //   };
00273 
00274   enum ExtensionObjectEncoding : uint8_t
00275   {
00276     NONE = 0,
00277     HAS_BINARY_BODY = 1,
00278     HAS_XML_BODY    = 2,
00279   };
00280 
00281   //TODO serialization tests
00282   struct ExtensionObjectHeader
00283   {
00284     ExpandedNodeId TypeId;
00285     ExtensionObjectEncoding Encoding;
00286 
00287     ExtensionObjectHeader();
00288     ExtensionObjectHeader(ExtensionObjectId objectId, ExtensionObjectEncoding encoding);
00289   };
00290 
00291 } // namespace OpcUa
00292 
00293 #endif // __OPC_UA_MAPPING_TYPES_H__
00294 


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:57