Skip to content

Commit

Permalink
Add interlock query (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
willeccles authored Oct 30, 2024
2 parents 71d2a39 + 7401e0e commit b042467
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/bci/abs/CInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,19 @@ int AbsScpiClient_ClearErrors(AbsScpiClientHandle handle);
*/
int AbsScpiClient_GetAlarms(AbsScpiClientHandle handle, uint32_t* alarms_out);

/**
* @brief Query the system interlock state. When in interlock, the unit will be
* put into its PoR state and cannot be controlled until the interlock is
* lifted.
*
* @param[in] handle SCPI client
* @param[out] interlock_out pointer to the interlock state
*
* @return 0 on success or a negative error code.
*/
int AbsScpiClient_GetInterlockState(AbsScpiClientHandle handle,
bool* interlock_out);

/**
* @brief Assert the software interlock (a recoverable alarm).
*
Expand Down
9 changes: 9 additions & 0 deletions include/bci/abs/ScpiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ class ScpiClient {
*/
Result<std::uint32_t> GetAlarms() const;

/**
* @brief Get the system interlock state. When in interlock, the unit will be
* put into its PoR state and cannot be controlled until the interlock is
* lifted.
*
* @return Result containing the interlock state or an error code.
*/
Result<bool> GetInterlockState() const;

/**
* @brief Assert the software interlock.
*
Expand Down
5 changes: 5 additions & 0 deletions src/CInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ int AbsScpiClient_GetAlarms(AbsScpiClientHandle handle, uint32_t* alarms_out) {
return WrapGet(&sc::GetAlarms, handle, alarms_out);
}

int AbsScpiClient_GetInterlockState(AbsScpiClientHandle handle,
bool* interlock_out) {
return WrapGet(&sc::GetInterlockState, handle, interlock_out);
}

int AbsScpiClient_AssertSoftwareInterlock(AbsScpiClientHandle handle) {
return WrapSet(&sc::AssertSoftwareInterlock, handle);
}
Expand Down
4 changes: 4 additions & 0 deletions src/ScpiClient_System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ Result<std::uint32_t> ScpiClient::GetAlarms() const {
.and_then(scpi::ParseIntResponse<std::uint32_t>);
}

Result<bool> ScpiClient::GetInterlockState() const {
return SendAndRecv("SYST:INT?\r\n").and_then(scpi::ParseBoolResponse);
}

ErrorCode ScpiClient::AssertSoftwareInterlock() const {
return Send("SYST:ALARM:RAISE\r\n");
}
Expand Down

0 comments on commit b042467

Please sign in to comment.