Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICBM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
detectors
DSSC
ICBM
Commits
f47b91f1
Commit
f47b91f1
authored
1 month ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Configurable power stages
parent
d80b9d93
No related branches found
No related tags found
No related merge requests found
Pipeline
#163113
passed
1 month ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
powerproc.cpp
+13
-11
13 additions, 11 deletions
powerproc.cpp
powerproc.hpp
+5
-2
5 additions, 2 deletions
powerproc.hpp
with
18 additions
and
13 deletions
powerproc.cpp
+
13
−
11
View file @
f47b91f1
...
...
@@ -3,7 +3,9 @@
#include
"mpod.hpp"
PowerProcedure
::
PowerProcedure
(
const
IPAddress
&
ipAddr
)
:
ipAddr
(
ipAddr
),
currentStage
(
""
),
currentChannel
(
-
1
)
{
:
ipAddr
(
ipAddr
),
stagesCount
(
STAGESCOUNT
),
currentStage
(
""
),
currentChannel
(
-
1
)
{
stages
=
new
Stage
[
stagesCount
];
stages
[
0
].
name
=
"ASICS"
;
stages
[
0
].
size
=
4
;
stages
[
0
].
channels
=
new
int
[
stages
[
0
].
size
]{
1
,
2
,
3
,
8
};
...
...
@@ -14,10 +16,10 @@ PowerProcedure::PowerProcedure(const IPAddress& ipAddr)
}
PowerProcedure
::~
PowerProcedure
()
{
size_t
stagesCount
=
sizeof
(
stages
)
/
sizeof
(
stages
[
0
]);
for
(
size_t
stageIdx
=
0
;
stageIdx
<
stagesCount
;
stageIdx
++
)
{
delete
[]
stages
[
stageIdx
].
channels
;
}
delete
[]
stages
;
}
String
PowerProcedure
::
toJSON
()
{
...
...
@@ -25,9 +27,9 @@ String PowerProcedure::toJSON() {
json
+=
"
\"
target
\"
:
\"
"
+
ipAddr
.
toString
()
+
"
\"
,
\n
"
;
json
+=
"
\"
groups
\"
: [
\n
"
;
Stage
*
currentStage
=
stages
;
Stage
*
las
tStage
=
stages
+
sizeof
(
stages
)
/
sizeof
(
stages
[
0
])
;
for
(
currentStage
;
currentStage
<
lastStage
;
currentStage
++
)
{
for
(
size_t
stageIdx
=
0
;
stageIdx
<
stagesCount
;
stageIdx
++
)
{
Stage
*
curren
tStage
=
&
stages
[
stageIdx
]
;
json
+=
"{
\"
name
\"
:
\"
"
+
currentStage
->
name
+
"
\"
,"
;
json
+=
"
\"
channels
\"
:[
\n
"
;
...
...
@@ -47,17 +49,18 @@ String PowerProcedure::toJSON() {
json
+=
"]
\n
"
;
json
+=
"},
\n
"
;
}
json
.
remove
(
json
.
lastIndexOf
(
','
),
1
);
// Remove trailing comma of last entry
json
+=
"]
\n
"
;
// groups body
json
+=
"}"
;
// json body
return
json
;
}
bool
PowerProcedure
::
powerOn
(
const
String
&
stage
)
{
Stage
*
currentStage
=
stages
;
Stage
*
lastStage
=
stages
+
sizeof
(
stages
)
/
sizeof
(
stages
[
0
]);
for
(
currentStage
;
currentStage
<
lastStage
;
currentStage
++
)
{
for
(
size_t
stageIdx
=
0
;
stageIdx
<
stagesCount
;
stageIdx
++
)
{
Stage
*
currentStage
=
&
stages
[
stageIdx
];
if
(
currentStage
->
name
==
stage
)
{
for
(
size_t
chIdx
=
0
;
chIdx
<
currentStage
->
size
;
chIdx
++
)
{
setChannelAndWait
(
&
ipAddr
,
currentStage
->
channels
[
chIdx
],
1
);
// 1 == ON
...
...
@@ -69,9 +72,8 @@ bool PowerProcedure::powerOn(const String& stage) {
}
bool
PowerProcedure
::
powerOff
(
const
String
&
stage
)
{
Stage
*
currentStage
=
stages
;
Stage
*
lastStage
=
stages
+
sizeof
(
stages
)
/
sizeof
(
stages
[
0
]);
for
(
currentStage
;
currentStage
<
lastStage
;
currentStage
++
)
{
for
(
size_t
stageIdx
=
0
;
stageIdx
<
stagesCount
;
stageIdx
++
)
{
Stage
*
currentStage
=
&
stages
[
stageIdx
];
if
(
currentStage
->
name
==
stage
)
{
for
(
int
chIdx
=
currentStage
->
size
-
1
;
chIdx
>=
0
;
chIdx
--
)
{
setChannelAndWait
(
&
ipAddr
,
currentStage
->
channels
[
chIdx
],
0
);
// 0 == OFF
...
...
This diff is collapsed.
Click to expand it.
powerproc.hpp
+
5
−
2
View file @
f47b91f1
#pragma once
#include
<Arduino.h>
#define STAGESCOUNT 2
class
PowerProcedure
{
private:
String
currentStage
;
// Stores the current stage name
int
currentChannel
;
// Stores the current channel
uint8_t
stagesCount
;
// Stores the quantity of power stages
struct
Stage
{
String
name
;
// Name of the stage (e.g., "ASICS")
int
*
channels
;
// Pointer to dynamically allocated channel array
size_t
size
;
// Number of channels in the stage
};
Stage
stages
[
2
];
// Array to hold stages
Stage
*
stages
;
// Array to hold stages
public
:
const
IPAddress
ipAddr
;
// Stores the IP address
const
IPAddress
ipAddr
;
// Stores the IP address
PowerProcedure
(
const
IPAddress
&
ipAddr
);
~
PowerProcedure
();
...
...
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