Fledge
An open source edge computing platform for industrial users
linkedlookup.h
1 #ifndef _LINKEDLOOKUP_H
2 #define _LINKEDLOOKUP_H
3 typedef enum {
4  OMFBT_UNKNOWN, OMFBT_DOUBLE64, OMFBT_DOUBLE32, OMFBT_INTEGER16,
5  OMFBT_INTEGER32, OMFBT_INTEGER64, OMFBT_UINTEGER16, OMFBT_UINTEGER32,
6  OMFBT_UINTEGER64, OMFBT_STRING, OMFBT_FLEDGEASSET
7 } OMFBaseType;
8 
12 #define LAL_ASSET_SENT 0x01 // We have sent the asset
13 #define LAL_LINK_SENT 0x02 // We have sent the link to the base type
14 #define LAL_CONTAINER_SENT 0x04 // We have sent the container
15 #define LAL_AFLINK_SENT 0x08 // We have sent the link to the AF location
16 
28 class LALookup {
29  public:
30  LALookup() { m_sentState = 0; m_baseType = OMFBT_UNKNOWN; };
31  bool assetState(const std::string& tagName)
32  {
33  return ((m_sentState & LAL_ASSET_SENT) != 0)
34  && (m_tagName.compare(tagName) == 0);
35  };
36  bool linkState(const std::string& tagName)
37  {
38  return ((m_sentState & LAL_LINK_SENT) != 0)
39  && (m_tagName.compare(tagName) == 0);
40  };
41  bool containerState(const std::string& tagName)
42  {
43  return ((m_sentState & LAL_CONTAINER_SENT) != 0)
44  && (m_tagName.compare(tagName) == 0);
45  };
46  bool afLinkState() { return (m_sentState & LAL_AFLINK_SENT) != 0; };
47  void setBaseType(const std::string& baseType);
48  OMFBaseType getBaseType() { return m_baseType; };
49  std::string getBaseTypeString();
50  void assetSent(const std::string& tagName)
51  {
52  if (m_tagName.compare(tagName))
53  {
54  m_sentState = LAL_ASSET_SENT;
55  m_tagName = tagName;
56  }
57  else
58  {
59  m_sentState |= LAL_ASSET_SENT;
60  }
61  };
62  void linkSent(const std::string& tagName)
63  {
64  if (m_tagName.compare(tagName))
65  {
66  // Force the container to resend if the tagName changes
67  m_tagName = tagName;
68  m_sentState &= ~LAL_CONTAINER_SENT;
69  }
70  m_sentState |= LAL_LINK_SENT;
71  };
72  void afLinkSent() { m_sentState |= LAL_AFLINK_SENT; };
73  void containerSent(const std::string& tagName, const std::string& baseType);
74  void containerSent(const std::string& tagName, OMFBaseType baseType);
75  private:
76  uint8_t m_sentState;
77  OMFBaseType m_baseType;
78  std::string m_tagName;
79 };
80 #endif
Linked Asset Information class.
Definition: linkedlookup.h:28
std::string getBaseTypeString()
Get a string representation of the base type that was sent.
Definition: linkdata.cpp:682
void containerSent(const std::string &tagName, const std::string &baseType)
The container has been sent with the specific base type.
Definition: linkdata.cpp:667
void setBaseType(const std::string &baseType)
Set the base type by passing the string of the base type.
Definition: linkdata.cpp:617