Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
dcdb
dcdb
Commits
e3fd0ec5
Commit
e3fd0ec5
authored
Apr 14, 2018
by
Micha Mueller
Browse files
Add template files for upcoming BACnet plugin
parent
6f7a286b
Changes
6
Hide whitespace changes
Inline
Side-by-side
config/bacnet.conf
0 → 100644
View file @
e3fd0ec5
global
{
mqttPrefix
/
FF112233445566778899FFFFFFFF
}
SensorTemplate
{
sensor
def0
{
interval
1000
mqttsuffix
0000
minValues
3
}
}
sensors
{
sensor
bac0
{
default
def1
interval
1000
minValue
1
mqttsuffix
0000
deviceInstance
1234
;
objectType
8
;
objectInstance
1234
;
property
85
}
sensor
bac1
{
deviceInstance
4321
interval
1000
mqttsuffix
0001
}
}
config/global.conf
View file @
e3fd0ec5
...
...
@@ -29,4 +29,9 @@ plugins {
config
}
;
plugin
bacnet
{
;
path
./
;
config
; }
}
src/sensors/bacnet/BACnetConfigurator.cpp
0 → 100644
View file @
e3fd0ec5
/*
* BACnetConfigurator.cpp
*
* Created on: 14.04.2018
* Author: Micha Mueller
*/
#include
"BACnetConfigurator.h"
BACnetConfigurator
::
BACnetConfigurator
()
{
// TODO Auto-generated constructor stub
}
BACnetConfigurator
::~
BACnetConfigurator
()
{
for
(
auto
s
:
_sensors
)
{
delete
s
;
}
}
std
::
vector
<
Sensor
*>&
BACnetConfigurator
::
readConfig
(
std
::
string
cfgPath
)
{
//TODO
return
_sensors
;
}
void
BACnetConfigurator
::
readSensor
(
BACnetSensor
&
sensor
,
boost
::
property_tree
::
iptree
&
config
)
{
//TODO
}
src/sensors/bacnet/BACnetConfigurator.h
0 → 100644
View file @
e3fd0ec5
/*
* BACnetConfigurator.h
*
* Created on: 14.04.2018
* Author: Micha Mueller
*/
#ifndef BACNETCONFIGURATOR_H_
#define BACNETCONFIGURATOR_H_
#include
"BACnetSensor.h"
#include
"../../Configurator.h"
#include
<string>
#include
<vector>
#include
<map>
#include
<boost/property_tree/ptree.hpp>
class
BACnetConfigurator
:
public
Configurator
{
typedef
std
::
map
<
std
::
string
,
BACnetSensor
>
sensorMap_t
;
public:
BACnetConfigurator
();
virtual
~
BACnetConfigurator
();
/**
* Read in the configuration for BACnet-sensors.
* @param cfgPath Path + name of the config-file
*/
std
::
vector
<
Sensor
*>&
readConfig
(
std
::
string
cfgPath
);
private:
/**
* Set the variables of sensor according to the values specified in config.
* @param sensor The sensor to be configured
* @param config A property(sub)tree containing the values
*/
void
readSensor
(
BACnetSensor
&
sensor
,
boost
::
property_tree
::
iptree
&
config
);
std
::
vector
<
Sensor
*>
_sensors
;
sensorMap_t
_templateSensors
;
};
extern
"C"
Configurator
*
create
()
{
return
new
BACnetConfigurator
;
}
extern
"C"
void
destroy
(
Configurator
*
c
)
{
delete
c
;
}
#endif
/* BACNETCONFIGURATOR_H_ */
src/sensors/bacnet/BACnetSensor.cpp
0 → 100644
View file @
e3fd0ec5
/*
* BACnetSensor.cpp
*
* Created on: 14.04.2018
* Author: Micha Mueller
*/
#include
"BACnetSensor.h"
#include
"timestamp.h"
#include
<functional>
extern
volatile
int
keepRunning
;
BACnetSensor
::
BACnetSensor
(
const
std
::
string
&
name
)
:
Sensor
(
name
)
{
_deviceInstance
=
0
;
}
BACnetSensor
::~
BACnetSensor
()
{
// TODO Auto-generated destructor stub
}
void
BACnetSensor
::
read
()
{
//TODO
}
void
BACnetSensor
::
readAsync
()
{
uint64_t
now
=
getTimestamp
();
read
();
if
(
_timer
!=
NULL
&&
keepRunning
)
{
uint64_t
next
=
now
+
MS_TO_NS
(
_interval
);
_timer
->
expires_at
(
timestamp2ptime
(
next
));
_timer
->
async_wait
(
std
::
bind
(
&
BACnetSensor
::
readAsync
,
this
));
}
}
void
BACnetSensor
::
startPolling
(
boost
::
asio
::
io_service
&
io
)
{
if
(
!
_readingQueue
)
{
_readingQueue
=
new
boost
::
lockfree
::
spsc_queue
<
reading_t
>
(
1024
);
}
_timer
=
new
boost
::
asio
::
deadline_timer
(
io
,
boost
::
posix_time
::
seconds
(
0
));
_timer
->
async_wait
(
std
::
bind
(
&
BACnetSensor
::
readAsync
,
this
));
}
src/sensors/bacnet/BACnetSensor.h
0 → 100644
View file @
e3fd0ec5
/*
* BACnetSensor.h
*
* Created on: 14.04.2018
* Author: Micha Mueller
*/
#ifndef BACNETSENSOR_H_
#define BACNETSENSOR_H_
#include
"../../Sensor.h"
class
BACnetSensor
:
public
Sensor
{
public:
BACnetSensor
(
const
std
::
string
&
name
);
virtual
~
BACnetSensor
();
uint32_t
getDeviceInstance
()
const
{
return
_deviceInstance
;
}
void
setDeviceInstance
(
uint32_t
deviceInstance
)
{
_deviceInstance
=
deviceInstance
;
}
void
read
();
void
readAsync
();
void
startPolling
(
boost
::
asio
::
io_service
&
io
);
private:
uint32_t
_deviceInstance
;
};
#endif
/* BACNETSENSOR_H_ */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment