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
f65dac67
Commit
f65dac67
authored
5 days ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Wait for environment to be ok first time before monitoring
parent
b151c9d1
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
icbm.ino
+29
-2
29 additions, 2 deletions
icbm.ino
mpod.cpp
+1
-1
1 addition, 1 deletion
mpod.cpp
pins.cpp
+1
-0
1 addition, 0 deletions
pins.cpp
pins.hpp
+1
-0
1 addition, 0 deletions
pins.hpp
rest.cpp
+10
-2
10 additions, 2 deletions
rest.cpp
with
42 additions
and
5 deletions
icbm.ino
+
29
−
2
View file @
f65dac67
...
...
@@ -23,11 +23,13 @@ void setup() {
PINS
.
last_triggered
=
millis
();
PINS
.
stage
=
""
;
PINS
.
ramping
=
false
;
PINS
.
canDoPowerFromREST
=
false
;
start
=
millis
();
// Run the web interface on core 0
xTaskCreatePinnedToCore
(
webInterfaceLoop
,
"Web Interface"
,
10000
,
NULL
,
1
,
&
restServerTask
,
0
);
// Run the power procedure and interrupt handling on core 1, the default core
xTaskCreatePinnedToCore
(
mainLoop
,
"PowerProcedure Task"
,
10000
,
NULL
,
1
,
&
powerProcedureTask
,
1
);
}
...
...
@@ -45,6 +47,28 @@ void serialLoop() {
}
}
void
waitEnvOk
()
{
// Poll port expander on initialiation to wait until environment all ok
// If the ICBM is booted before the detector is up, as it should be,
// then the environment will always be incorrect, creating a power down
PINS
.
stage
=
"Waiting for environment to be okay first time"
;
uint32_t
lastIteration
=
millis
();
while
(
true
)
{
serialLoop
();
if
(
millis
()
-
lastIteration
>=
200
)
{
// ms, faster polling makes for erroneous readings.
poll_port_expander
();
if
(
PINS
.
sib
&&
PINS
.
plc
&&
PINS
.
ups
)
{
break
;
}
lastIteration
=
millis
();
}
}
PINS
.
stage
=
""
;
PINS
.
canDoPowerFromREST
=
true
;
}
void
webInterfaceLoop
(
void
*
pvParameters
)
{
Serial
.
print
(
"Web loop running on core "
);
Serial
.
println
(
xPortGetCoreID
());
...
...
@@ -54,8 +78,11 @@ void webInterfaceLoop(void* pvParameters) {
}
void
mainLoop
(
void
*
pvParameters
)
{
Serial
.
print
(
"
m
ain loop running on core "
);
Serial
.
print
(
"
M
ain loop running on core "
);
Serial
.
println
(
xPortGetCoreID
());
waitEnvOk
();
while
(
true
)
{
isr_check_loop
();
snmp
.
loop
();
...
...
This diff is collapsed.
Click to expand it.
mpod.cpp
+
1
−
1
View file @
f65dac67
...
...
@@ -267,7 +267,7 @@ void setChannelStateAndWait(const IPAddress *ipAddr, const uint16_t channel, con
settingChannelState
=
false
;
}
else
if
(
loopCount
>=
5
)
{
// There were no changes in 5 reads, it might be that the command (UDP)
// got swallowed by the MPOD controller while doing something else.
// got swallowed by the MPOD controller while
it was
doing something else.
Serial
.
print
(
"!Resend command to "
);
Serial
.
println
(
channel
);
SNMP
::
Message
*
snmp_msg
=
mpod
.
setChannelState
(
channel
,
output
);
...
...
This diff is collapsed.
Click to expand it.
pins.cpp
+
1
−
0
View file @
f65dac67
...
...
@@ -72,6 +72,7 @@ void isr_check_loop() {
// If not all ok, set the power down flag, later handled.
if
(
!
(
PINS
.
sib
&&
PINS
.
plc
&&
PINS
.
ups
))
{
PERFORM_PROCEDURE_FROM_INTERRUPT
=
1
;
PINS
.
canDoPowerFromREST
=
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
pins.hpp
+
1
−
0
View file @
f65dac67
...
...
@@ -26,6 +26,7 @@ struct pins {
int
last_triggered
;
String
stage
;
bool
ramping
;
bool
canDoPowerFromREST
;
};
extern
struct
pins
PINS
;
...
...
This diff is collapsed.
Click to expand it.
rest.cpp
+
10
−
2
View file @
f65dac67
...
...
@@ -82,9 +82,9 @@ void identify() {
message
+=
"
\"
ramping
\"
:"
;
message
+=
PINS
.
ramping
;
message
+=
",
\n
"
;
message
+=
"
\"
stage
\"
:"
;
message
+=
"
\"
stage
\"
:
\"
"
;
message
+=
PINS
.
stage
;
message
+=
"
,
\n
"
;
message
+=
"
\"
\n
"
;
message
+=
"
\n
}"
;
message
+=
"
\n
}"
;
...
...
@@ -210,11 +210,19 @@ void powerGroup() {
}
if
(
output
&&
group
)
{
PINS
.
ramping
=
true
;
PINS
.
stage
=
group
;
if
(
output
==
"on"
)
{
PINS
.
stage
+=
" going up"
;
success
=
pproc
.
powerOn
(
group
);
}
else
if
(
output
==
"off"
)
{
PINS
.
stage
+=
" going down"
;
success
=
pproc
.
powerOff
(
group
);
}
PINS
.
ramping
=
false
;
PINS
.
stage
=
""
;
}
String
http_msg
=
"{
\n
"
;
...
...
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