Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Smart Grid Modell
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Co
Smart Grid Modell
Commits
e4f712e0
Commit
e4f712e0
authored
4 years ago
by
Armin Co
Browse files
Options
Downloads
Patches
Plain Diff
Show more states
parent
9b08b69d
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/apps/smart_grid/SmartOpcServer.cpp
+11
-3
11 additions, 3 deletions
src/apps/smart_grid/SmartOpcServer.cpp
src/apps/smart_grid/SmartOpcServer.hpp
+6
-1
6 additions, 1 deletion
src/apps/smart_grid/SmartOpcServer.hpp
src/smart_grid/SmartGridModel.cpp
+1
-1
1 addition, 1 deletion
src/smart_grid/SmartGridModel.cpp
with
18 additions
and
5 deletions
src/apps/smart_grid/SmartOpcServer.cpp
+
11
−
3
View file @
e4f712e0
...
@@ -44,7 +44,6 @@ private:
...
@@ -44,7 +44,6 @@ private:
void
DataChange
(
uint32_t
handle
,
const
Node
&
node
,
const
Variant
&
val
,
AttributeId
attr
)
override
void
DataChange
(
uint32_t
handle
,
const
Node
&
node
,
const
Variant
&
val
,
AttributeId
attr
)
override
{
{
auto
v
=
val
.
As
<
bool
>
();
auto
v
=
val
.
As
<
bool
>
();
std
::
cout
<<
v
<<
std
::
endl
;
m_state_machine
.
set_sim_mode_enabled
(
v
);
m_state_machine
.
set_sim_mode_enabled
(
v
);
}
}
SmgStateMachine
&
m_state_machine
;
SmgStateMachine
&
m_state_machine
;
...
@@ -70,10 +69,15 @@ void SmartOpcServer::setup_server()
...
@@ -70,10 +69,15 @@ void SmartOpcServer::setup_server()
Node
smart_grid_folder
{
m_objects_folder
.
AddFolder
(
m_idx
,
"smart_grid_model"
)};
Node
smart_grid_folder
{
m_objects_folder
.
AddFolder
(
m_idx
,
"smart_grid_model"
)};
m_state
=
smart_grid_folder
.
AddObject
(
m_idx
,
"state"
);
m_state
=
smart_grid_folder
.
AddObject
(
m_idx
,
"state"
);
m_time
=
m_state
.
AddVariable
(
m_idx
,
"time"
,
Variant
(
m_state_machine
.
m_model
.
get_time
()));
m_sun
=
m_state
.
AddVariable
(
m_idx
,
"sun-Power"
,
Variant
(
m_state_machine
.
m_model
.
get_sun
()));
m_wind
=
m_state
.
AddVariable
(
m_idx
,
"wind_power"
,
Variant
(
m_state_machine
.
m_model
.
get_wind
()));
m_power_production
=
m_state
.
AddVariable
(
m_idx
,
"power_production"
,
Variant
(
m_state_machine
.
m_model
.
get_power_production
()));
m_usage
=
m_state
.
AddVariable
(
m_idx
,
"used_power"
,
Variant
(
m_state_machine
.
m_model
.
get_power_usage
()));
m_excess_power
=
m_state
.
AddVariable
(
m_idx
,
"excess_power"
,
Variant
(
m_state_machine
.
m_model
.
get_excess_power
()));
m_excess_power
=
m_state
.
AddVariable
(
m_idx
,
"excess_power"
,
Variant
(
m_state_machine
.
m_model
.
get_excess_power
()));
m_controls
=
smart_grid_folder
.
AddObject
(
m_idx
,
"controls"
);
m_controls
=
smart_grid_folder
.
AddObject
(
m_idx
,
"controls"
);
m_time
=
m_controls
.
AddVariable
(
m_idx
,
"time"
,
Variant
(
m_state_machine
.
m_model
.
get_time
()));
m_producing
=
m_controls
.
AddVariable
(
m_idx
,
"producing"
,
Variant
(
m_state_machine
.
m_model
.
get_producing_state
()));
m_producing
=
m_controls
.
AddVariable
(
m_idx
,
"producing"
,
Variant
(
m_state_machine
.
m_model
.
get_producing_state
()));
m_sim_mode_enabled
=
m_controls
.
AddVariable
(
m_idx
,
"sim_mode_enabled"
,
Variant
(
m_state_machine
.
is_sim_mode_enabled
()));
m_sim_mode_enabled
=
m_controls
.
AddVariable
(
m_idx
,
"sim_mode_enabled"
,
Variant
(
m_state_machine
.
is_sim_mode_enabled
()));
}
}
...
@@ -100,8 +104,12 @@ void SmartOpcServer::run_server()
...
@@ -100,8 +104,12 @@ void SmartOpcServer::run_server()
m_state_machine
.
run
();
m_state_machine
.
run
();
// update opc objects
// update opc objects
m_time
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_time
()));
m_sun
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_sun
()));
m_wind
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_wind
()));
m_power_production
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_power_production
()));
m_usage
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_power_usage
()));
m_excess_power
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_excess_power
()));
m_excess_power
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_excess_power
()));
m_time
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_time
()));
m_producing
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_producing_state
()));
m_producing
.
SetValue
(
Variant
(
m_state_machine
.
m_model
.
get_producing_state
()));
m_sim_mode_enabled
.
SetValue
(
Variant
(
m_state_machine
.
is_sim_mode_enabled
()));
m_sim_mode_enabled
.
SetValue
(
Variant
(
m_state_machine
.
is_sim_mode_enabled
()));
...
...
This diff is collapsed.
Click to expand it.
src/apps/smart_grid/SmartOpcServer.hpp
+
6
−
1
View file @
e4f712e0
...
@@ -31,10 +31,15 @@ private:
...
@@ -31,10 +31,15 @@ private:
OpcUa
::
Node
m_root_node
;
OpcUa
::
Node
m_root_node
;
OpcUa
::
Node
m_state
;
OpcUa
::
Node
m_state
;
OpcUa
::
Node
m_time
;
OpcUa
::
Node
m_sun
;
OpcUa
::
Node
m_wind
;
OpcUa
::
Node
m_power_production
;
OpcUa
::
Node
m_usage
;
OpcUa
::
Node
m_excess_power
;
OpcUa
::
Node
m_excess_power
;
OpcUa
::
Node
m_controls
;
OpcUa
::
Node
m_controls
;
OpcUa
::
Node
m_time
;
OpcUa
::
Node
m_producing
;
OpcUa
::
Node
m_producing
;
OpcUa
::
Node
m_sim_mode_enabled
;
OpcUa
::
Node
m_sim_mode_enabled
;
...
...
This diff is collapsed.
Click to expand it.
src/smart_grid/SmartGridModel.cpp
+
1
−
1
View file @
e4f712e0
...
@@ -14,7 +14,7 @@ SmartGridModel::SmartGridModel(HardwareControl &modell)
...
@@ -14,7 +14,7 @@ SmartGridModel::SmartGridModel(HardwareControl &modell)
void
SmartGridModel
::
update_wind
()
void
SmartGridModel
::
update_wind
()
{
{
auto
wind_by_sun
=
m_sun
*
9.0
/
100.0
;
// wind by sun should be 5 max.
auto
wind_by_sun
=
m_sun
*
9.0
/
100.0
;
// wind by sun should be 5 max.
auto
random_wind
=
((
std
::
rand
()
*
1.0
)
/
RAND_MAX
)
*
3
.0
;
auto
random_wind
=
((
std
::
rand
()
*
1.0
)
/
RAND_MAX
)
*
1
.0
;
m_wind
=
power_wind
[
static_cast
<
int
>
(
wind_by_sun
+
random_wind
)];
m_wind
=
power_wind
[
static_cast
<
int
>
(
wind_by_sun
+
random_wind
)];
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment