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
Compare revisions
c4ff11e2aadaee5456f85d49322bd579bbaeb440 to 562f55e0dfa46a697e444624e9d3a1121b35e3ee
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
detectors/dssc/icbm
Select target project
No results found
562f55e0dfa46a697e444624e9d3a1121b35e3ee
Select Git revision
Branches
feat/multipe_pods
main
test/simple_power_procedure
Tags
0.0.0-test
1.0.0-test
Swap
Target
detectors/dssc/icbm
Select target project
detectors/dssc/icbm
1 result
c4ff11e2aadaee5456f85d49322bd579bbaeb440
Select Git revision
Branches
feat/multipe_pods
main
test/simple_power_procedure
Tags
0.0.0-test
1.0.0-test
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (5)
Run web server on separate core
· 063a109d
Cyril Danilevski
authored
2 weeks ago
063a109d
Ignore REST requests when ramping
· b151c9d1
Cyril Danilevski
authored
2 weeks ago
b151c9d1
Wait for environment to be ok first time before monitoring
· f65dac67
Cyril Danilevski
authored
4 days ago
f65dac67
Add complete mpod status route
· 8e1e6c4a
Cyril Danilevski
authored
4 days ago
8e1e6c4a
Clarify intended behaviour when skipping iteration on stale data
· 562f55e0
Cyril Danilevski
authored
4 days ago
562f55e0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
icbm.ino
+56
-8
56 additions, 8 deletions
icbm.ino
mpod.cpp
+7
-1
7 additions, 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
+33
-2
33 additions, 2 deletions
rest.cpp
rest.hpp
+1
-0
1 addition, 0 deletions
rest.hpp
with
99 additions
and
11 deletions
icbm.ino
View file @
562f55e0
...
...
@@ -7,6 +7,9 @@ unsigned long start;
extern
bool
eth_connected
;
extern
SNMP
::
Manager
snmp
;
TaskHandle_t
restServerTask
;
TaskHandle_t
powerProcedureTask
;
void
setup
()
{
Serial
.
begin
(
115200
);
...
...
@@ -20,8 +23,15 @@ 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
);
}
enum
{
...
...
@@ -37,13 +47,51 @@ void serialLoop() {
}
}
void
loop
()
{
isr_check_loop
();
snmp
.
loop
();
restServer
.
handleClient
();
toggle_status_led
();
serialLoop
();
if
(
eth_connected
)
{
// We may be triggered, but disconnected from the network.
powerOffCheckLoop
();
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
());
while
(
true
)
{
restServer
.
handleClient
();
}
}
void
mainLoop
(
void
*
pvParameters
)
{
Serial
.
print
(
"Main loop running on core "
);
Serial
.
println
(
xPortGetCoreID
());
waitEnvOk
();
while
(
true
)
{
isr_check_loop
();
snmp
.
loop
();
toggle_status_led
();
serialLoop
();
if
(
eth_connected
)
{
// We may be triggered, but disconnected from the network.
powerOffCheckLoop
();
}
}
}
void
loop
()
{}
This diff is collapsed.
Click to expand it.
mpod.cpp
View file @
562f55e0
...
...
@@ -260,6 +260,12 @@ void setChannelStateAndWait(const IPAddress *ipAddr, const uint16_t channel, con
delay
(
MPOD_UPDATE_LATENCY
);
snmp
.
loop
();
if
(
mpod
.
getChannel
()
!=
channel
)
{
// We have stale information, because MPOD swallowed UDP request.
// Skip this update check and go for next iteration, where data will be requested
// or request resent.
continue
;
}
loopCount
+=
1
;
ramping
=
(
mpod
.
isRampingUp
()
||
mpod
.
isRampingDown
());
if
(
!
ramping
)
{
...
...
@@ -267,7 +273,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
View file @
562f55e0
...
...
@@ -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
View file @
562f55e0
...
...
@@ -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
View file @
562f55e0
...
...
@@ -25,6 +25,8 @@ void initializeRoutes() {
restServer
.
on
(
"/"
,
panel
);
restServer
.
on
(
"/poll"
,
pollMPODChannel
);
restServer
.
on
(
"/mpodstatus"
,
getMpodStatus
);
restServer
.
on
(
"/power"
,
powerGroup
);
restServer
.
on
(
"/alloff"
,
powerAllOff
);
...
...
@@ -82,9 +84,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
}"
;
...
...
@@ -131,6 +133,10 @@ enum {
};
void
sendSNMP
()
{
if
(
PINS
.
ramping
)
{
restServer
.
send
(
403
,
"text/json"
,
"{
\"
success
\"
: 0,
\"
reason
\"
:
\"
ramping ongoing
\"
}"
);
return
;
}
uint8_t
output
=
NONE
;
uint16_t
channel
=
0
;
bool
success
=
false
;
...
...
@@ -177,7 +183,20 @@ void sendSNMP() {
restServer
.
send
(
success
?
200
:
406
,
"text/json"
,
http_msg
);
}
void
getMpodStatus
()
{
if
(
PINS
.
ramping
)
{
restServer
.
send
(
403
,
"text/json"
,
"{
\"
success
\"
: 0,
\"
reason
\"
:
\"
ramping ongoing
\"
}"
);
return
;
}
restServer
.
send
(
200
,
"text/json"
,
pproc
.
toJSON
());
}
void
powerGroup
()
{
if
(
PINS
.
ramping
)
{
restServer
.
send
(
403
,
"text/json"
,
"{
\"
success
\"
: 0,
\"
reason
\"
:
\"
ramping ongoing
\"
}"
);
return
;
}
String
output
;
String
group
;
String
ret
;
...
...
@@ -202,11 +221,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
"
;
...
...
@@ -224,6 +251,10 @@ void powerGroup() {
}
void
powerAllOff
()
{
if
(
PINS
.
ramping
)
{
restServer
.
send
(
403
,
"text/json"
,
"{
\"
success
\"
: 0,
\"
reason
\"
:
\"
ramping ongoing
\"
}"
);
return
;
}
String
group
;
String
groups
;
bool
success
=
false
;
...
...
This diff is collapsed.
Click to expand it.
rest.hpp
View file @
562f55e0
...
...
@@ -13,3 +13,4 @@ void panel(); // / show a status page
void
pollMPODChannel
();
// /poll?ch=1
void
powerGroup
();
// /power?group=ASICS&output=on
void
powerAllOff
();
// /alloff?token=CWH
void
getMpodStatus
();
// /mpodstatus
This diff is collapsed.
Click to expand it.