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
2854a172
Commit
2854a172
authored
Oct 30, 2018
by
Michael Ott
Browse files
Move DeviceInstance to sensor group, add more debug logging to BACNet plugin
parent
5bfdde71
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/sensors/bacnet/BACnetConfigurator.cpp
View file @
2854a172
...
...
@@ -25,7 +25,6 @@ BACnetConfigurator::~BACnetConfigurator() {
void
BACnetConfigurator
::
sensorBase
(
BACnetSensorBase
&
s
,
CFG_VAL
config
)
{
ADD
{
ATTRIBUTE
(
"deviceInstance"
,
setDeviceInstance
);
ATTRIBUTE
(
"objectInstance"
,
setObjectInstance
);
ATTRIBUTE
(
"objectType"
,
setObjectType
);
ATTRIBUTE
(
"id"
,
setPropertyId
);
...
...
@@ -35,7 +34,7 @@ void BACnetConfigurator::sensorBase(BACnetSensorBase& s, CFG_VAL config) {
void
BACnetConfigurator
::
sensorGroup
(
BACnetSensorGroup
&
s
,
CFG_VAL
config
)
{
ADD
{
//no group attributes currently
ATTRIBUTE
(
"deviceInstance"
,
setDeviceInstance
);
}
s
.
setBACnetClient
(
_bacClient
);
}
...
...
src/sensors/bacnet/BACnetSensorBase.h
View file @
2854a172
...
...
@@ -19,7 +19,6 @@ public:
BACnetSensorBase
(
const
std
::
string
&
name
)
:
SensorBase
(
name
),
_factor
(
1
),
_deviceInstance
(
0
),
_objectInstance
(
0
)
{
_objectType
=
OBJECT_DEVICE
;
_propertyId
=
PROP_PRESENT_VALUE
;
...
...
@@ -29,14 +28,12 @@ public:
virtual
~
BACnetSensorBase
()
{}
double
getFactor
()
const
{
return
_factor
;
}
uint32_t
getDeviceInstance
()
const
{
return
_deviceInstance
;
}
uint32_t
getObjectInstance
()
const
{
return
_objectInstance
;
}
BACNET_OBJECT_TYPE
getObjectType
()
const
{
return
_objectType
;
}
BACNET_PROPERTY_ID
getPropertyId
()
const
{
return
_propertyId
;
}
int32_t
getObjectIndex
()
const
{
return
_objectIndex
;
}
void
setFactor
(
const
std
::
string
&
factor
)
{
_factor
=
std
::
stod
(
factor
);
}
void
setDeviceInstance
(
const
std
::
string
&
deviceInstance
)
{
_deviceInstance
=
stoul
(
deviceInstance
);
}
void
setObjectInstance
(
const
std
::
string
&
objectInstance
)
{
_objectInstance
=
stoul
(
objectInstance
);
}
void
setObjectType
(
const
std
::
string
&
objectType
)
{
_objectType
=
static_cast
<
BACNET_OBJECT_TYPE
>
(
stoul
(
objectType
));
}
void
setPropertyId
(
const
std
::
string
&
property
)
{
_propertyId
=
static_cast
<
BACNET_PROPERTY_ID
>
(
stoul
(
property
));
}
...
...
@@ -44,7 +41,6 @@ public:
protected:
double
_factor
;
uint32_t
_deviceInstance
;
uint32_t
_objectInstance
;
BACNET_OBJECT_TYPE
_objectType
;
BACNET_PROPERTY_ID
_propertyId
;
...
...
src/sensors/bacnet/BACnetSensorGroup.cpp
View file @
2854a172
...
...
@@ -10,9 +10,9 @@
#include
<functional>
BACnetSensorGroup
::
BACnetSensorGroup
(
const
std
::
string
&
name
)
:
SensorGroupTemplate
(
name
)
{
BACnetSensorGroup
::
BACnetSensorGroup
(
const
std
::
string
&
name
)
:
SensorGroupTemplate
(
name
),
_deviceInstance
(
0
)
{
_bacClient
=
nullptr
;
}
BACnetSensorGroup
::~
BACnetSensorGroup
()
{}
...
...
@@ -21,6 +21,17 @@ void BACnetSensorGroup::init(boost::asio::io_service& io) {
SensorGroupTemplate
::
init
(
io
);
if
(
_bacClient
)
{
_bacClient
->
initializeStrand
(
io
);
#ifdef DEBUG
LOG
(
debug
)
<<
" DeviceInstance: "
<<
_deviceInstance
;
LOG
(
debug
)
<<
" "
<<
_sensors
.
size
()
<<
" Sensors:"
;
for
(
auto
s
:
_sensors
)
{
LOG
(
debug
)
<<
" "
<<
s
->
getName
();
LOG
(
debug
)
<<
" ObjectInstance: "
<<
s
->
getObjectInstance
();
LOG
(
debug
)
<<
" ObjectType: "
<<
s
->
getObjectType
();
LOG
(
debug
)
<<
" PropertyId: "
<<
s
->
getPropertyId
();
}
#endif
}
else
{
LOG
(
error
)
<<
"No BACnetClient set for sensor "
<<
_groupName
<<
"! Cannot initialize sensor."
;
}
...
...
@@ -56,7 +67,7 @@ void BACnetSensorGroup::read() {
for
(
auto
s
:
_sensors
)
{
try
{
reading
.
value
=
_bacClient
->
readProperty
(
s
->
getDeviceInstance
(),
s
->
getObjectInstance
(),
s
->
getObjectType
(),
s
->
getPropertyId
())
*
s
->
getFactor
();
reading
.
value
=
_bacClient
->
readProperty
(
getDeviceInstance
(),
s
->
getObjectInstance
(),
s
->
getObjectType
(),
s
->
getPropertyId
())
*
s
->
getFactor
();
}
catch
(
const
std
::
exception
&
e
)
{
LOG
(
error
)
<<
_groupName
<<
"::"
<<
s
->
getName
()
<<
" could not read value: "
<<
e
.
what
();
continue
;
...
...
src/sensors/bacnet/BACnetSensorGroup.h
View file @
2854a172
...
...
@@ -23,12 +23,16 @@ public:
void
setBACnetClient
(
BACnetClient
*
bacClient
)
{
_bacClient
=
bacClient
;
}
BACnetClient
*
const
getBACnetClient
()
const
{
return
_bacClient
;
}
void
setDeviceInstance
(
const
std
::
string
&
deviceInstance
)
{
_deviceInstance
=
stoul
(
deviceInstance
);
}
uint32_t
getDeviceInstance
()
const
{
return
_deviceInstance
;
}
private:
void
read
()
override
;
void
readAsync
()
override
;
BACnetClient
*
_bacClient
;
uint32_t
_deviceInstance
;
};
#endif
/* BACNETSENSORGROUP_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