upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bacnetutil.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <string>
27 #include <map>
28 #include <vector>
29 
30 #include "bacnetmstp.hpp"
31 
32 namespace upm {
33 
50  class BACNETUTIL {
51  public:
52 
57  BACNETUTIL(uint32_t targetDeviceObjectID);
58 
62  virtual ~BACNETUTIL();
63 
93  virtual void initMaster(std::string port, int baudRate,
94  int deviceInstanceNumber,
95  int macAddr, int maxMaster=DEFAULT_MAX_MASTER,
96  int maxInfoFrames=1);
97 
104  virtual void setDebug(bool enable);
105 
118  virtual float getAnalogValue(uint32_t objInstance);
119 
127  virtual void setAnalogValue(uint32_t objInstance,
128  float value);
129 
142  virtual float getAnalogInput(uint32_t objInstance);
143 
156  virtual std::string getAnalogValueUnits(uint32_t objInstance);
157 
170  virtual std::string getAnalogInputUnits(uint32_t objInstance);
171 
184  virtual bool getBinaryInput(uint32_t objInstance);
185 
202  virtual std::string lookupBinaryInputText(uint32_t objInstance, bool value);
203 
213  virtual std::string getBinaryInputText(uint32_t objInstance);
214 
227  virtual bool getBinaryValue(uint32_t objInstance);
228 
236  virtual void setBinaryValue(uint32_t objInstance,
237  bool value);
238 
255  virtual std::string lookupBinaryValueText(uint32_t objInstance, bool value);
256 
266  virtual std::string getBinaryValueText(uint32_t objInstance);
267 
280  virtual unsigned int getMultiStateValue(uint32_t objInstance);
281 
298  virtual std::string lookupMultiStateValueText(uint32_t objInstance,
299  unsigned int value);
300 
311  virtual std::string getMultiStateValueText(uint32_t objInstance);
312 
321  virtual unsigned int getMultiStateValueMaxStates(uint32_t objInstance);
322 
333  virtual void setMultiStateValue(uint32_t objInstance,
334  unsigned int value);
335 
360  virtual void checkReliability(bool enable)
361  {
362  m_checkReliability = enable;
363  };
364 
372  virtual std::string getDeviceDescription();
373 
381  virtual std::string getDeviceLocation();
382 
391  virtual bool setDeviceLocation(std::string location);
392 
401  virtual std::string getDeviceName();
402 
412  virtual bool setDeviceName(std::string name);
413 
421  virtual std::string getAllErrorString();
422 
431  virtual BACNETMSTP::BACERR_TYPE_T getErrorType();
432 
438  virtual uint8_t getRejectReason();
439 
445  virtual std::string getRejectString();
446 
452  virtual uint8_t getAbortReason();
453 
459  virtual std::string getAbortString();
460 
466  virtual BACNET_ERROR_CLASS getErrorClass();
467 
473  virtual BACNET_ERROR_CODE getErrorCode();
474 
481  virtual std::string getErrorString();
482 
489  virtual std::string getUPMErrorString();
490 
491  protected:
492  // update our stored info for an MSV
493  virtual void updateMultiStateValueInfo(uint32_t objInstance);
494  // delete our stored info for an MSV
495  virtual void deleteMultiStateValueInfo(uint32_t objInstance);
496 
497  // update our stored info for a BV
498  virtual void updateBinaryValueInfo(uint32_t objInstance);
499  // delete our stored info for a BV
500  virtual void deleteBinaryValueInfo(uint32_t objInstance);
501 
502  // update our stored info for a BI
503  virtual void updateBinaryInputInfo(uint32_t objInstance);
504  // delete our stored info for a BI
505  virtual void deleteBinaryInputInfo(uint32_t objInstance);
506 
507  // also enable mstp debugging in BACNETMSTP
508  bool m_debugging;
509 
510  // whether or not to verify reliability before reading a value.
511  bool m_checkReliability;
512 
513  // our target Device Object ID
514  uint32_t m_targetDeviceObjectID;
515 
516  // a copy of the BACNETMSTP singleton instance pointer
517  BACNETMSTP* m_instance;
518 
519  // are we initialized?
520  bool m_initialized;
521 
522  // storage for Binary Input and Binary Value Data. This will
523  // generate SWIG warnings which can be ignored as we do not expose
524  // this struct outside the class.
525  typedef struct {
526  std::string inactiveText;
527  std::string activeText;
528  } binaryData_t;
529 
530  typedef std::map<uint32_t, binaryData_t> binaryInfo_t;
531 
532  // storage for binary input/value information
533  binaryInfo_t m_bvInfo;
534  binaryInfo_t m_biInfo;
535 
536  // storage for multi-state data. This will generate SWIG
537  // warnings which can be ignored as we do not expose this struct
538  // outside the class.
539  typedef struct {
540  unsigned int numStates;
541  std::vector<std::string>stateList;
543 
544  // our information storage for MSV's
545  typedef std::map<uint32_t, multiStateData_t> multiStateInfo_t;
546 
547  multiStateInfo_t m_msvInfo;
548 
549  // Unit cache for AV
550  typedef std::map<uint32_t, std::string> avCacheMap_t;
551  avCacheMap_t m_avUnitCache;
552 
553  // Unit cache for AI
554  typedef std::map<uint32_t, std::string> aiCacheMap_t;
555  aiCacheMap_t m_aiUnitCache;
556 
557  private:
558  };
559 }
virtual ~BACNETUTIL()
Definition: bacnetutil.cxx:69
virtual bool getBinaryInput(uint32_t objInstance)
Definition: bacnetutil.cxx:236
UPM API for BACNETMSTP.
Definition: bacnetmstp.hpp:104
virtual void initMaster(std::string port, int baudRate, int deviceInstanceNumber, int macAddr, int maxMaster=DEFAULT_MAX_MASTER, int maxInfoFrames=1)
Definition: bacnetutil.cxx:73
virtual void setBinaryValue(uint32_t objInstance, bool value)
Definition: bacnetutil.cxx:336
virtual unsigned int getMultiStateValue(uint32_t objInstance)
Definition: bacnetutil.cxx:385
virtual std::string getUPMErrorString()
Definition: bacnetutil.cxx:800
virtual bool getBinaryValue(uint32_t objInstance)
Definition: bacnetutil.cxx:286
virtual void setMultiStateValue(uint32_t objInstance, unsigned int value)
Definition: bacnetutil.cxx:570
Definition: bacnetutil.hpp:525
virtual std::string getDeviceName()
Definition: bacnetutil.cxx:888
virtual std::string lookupBinaryInputText(uint32_t objInstance, bool value)
Definition: bacnetutil.cxx:729
virtual BACNETMSTP::BACERR_TYPE_T getErrorType()
Definition: bacnetutil.cxx:765
virtual uint8_t getRejectReason()
Definition: bacnetutil.cxx:770
virtual std::string getAllErrorString()
Definition: bacnetutil.cxx:810
virtual std::string getAnalogValueUnits(uint32_t objInstance)
Definition: bacnetutil.cxx:167
virtual std::string getBinaryValueText(uint32_t objInstance)
Definition: bacnetutil.cxx:758
virtual void checkReliability(bool enable)
Definition: bacnetutil.hpp:360
virtual uint8_t getAbortReason()
Definition: bacnetutil.cxx:780
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
virtual std::string lookupMultiStateValueText(uint32_t objInstance, unsigned int value)
Definition: bacnetutil.cxx:519
virtual std::string getMultiStateValueText(uint32_t objInstance)
Definition: bacnetutil.cxx:563
virtual std::string getErrorString()
Definition: bacnetutil.cxx:805
BACNETUTIL(uint32_t targetDeviceObjectID)
Definition: bacnetutil.cxx:38
virtual unsigned int getMultiStateValueMaxStates(uint32_t objInstance)
Definition: bacnetutil.cxx:555
virtual std::string getDeviceLocation()
Definition: bacnetutil.cxx:853
virtual bool setDeviceName(std::string name)
Definition: bacnetutil.cxx:903
virtual float getAnalogInput(uint32_t objInstance)
Definition: bacnetutil.cxx:192
virtual BACNET_ERROR_CODE getErrorCode()
Definition: bacnetutil.cxx:795
virtual std::string lookupBinaryValueText(uint32_t objInstance, bool value)
Definition: bacnetutil.cxx:747
Definition: bacnetutil.hpp:539
virtual bool setDeviceLocation(std::string location)
Definition: bacnetutil.cxx:868
virtual std::string getAbortString()
Definition: bacnetutil.cxx:785
virtual BACNET_ERROR_CLASS getErrorClass()
Definition: bacnetutil.cxx:790
UPM Utility API for BACnet.
Definition: bacnetutil.hpp:50
virtual std::string getRejectString()
Definition: bacnetutil.cxx:775
virtual float getAnalogValue(uint32_t objInstance)
Definition: bacnetutil.cxx:100
virtual std::string getBinaryInputText(uint32_t objInstance)
Definition: bacnetutil.cxx:740
virtual std::string getDeviceDescription()
Definition: bacnetutil.cxx:838
virtual void setDebug(bool enable)
Definition: bacnetutil.cxx:92
virtual void setAnalogValue(uint32_t objInstance, float value)
Definition: bacnetutil.cxx:145
virtual std::string getAnalogInputUnits(uint32_t objInstance)
Definition: bacnetutil.cxx:360