Added PSU DS messages

Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
2025-10-28 18:19:07 +00:00
parent 9bb3196a23
commit 1764a7b8da
2 changed files with 36 additions and 23 deletions

View File

@@ -55,10 +55,7 @@ const float32 DAC_RANGE = 20.0;
PSUCommunicatorTX::PSUCommunicatorTX() : DataSourceI(), MessageI() { PSUCommunicatorTX::PSUCommunicatorTX() : DataSourceI(), MessageI() {
// boardFileDescriptor = -1; // boardFileDescriptor = -1;
triggerSet = false; triggerSet = false;
uint32 n; isTriggered = false;
// for (n = 0u; n < ATCA_IOP_MAX_DAC_CHANNELS; n++) {
// dacEnabled[n] = false;
//}
communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_IDLE; communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_IDLE;
// channelsMemory = NULL_PTR(float32 *); // channelsMemory = NULL_PTR(float32 *);
currentValue = 0.0; // NULL_PTR(float32 *); currentValue = 0.0; // NULL_PTR(float32 *);
@@ -335,15 +332,26 @@ bool PSUCommunicatorTX::CreateCurrentPacket() {
uint16 nc = ~pc; uint16 nc = ~pc;
packet[0] = (char8)(0x0000 | ((nc & 0x03C0) >> 5) | ((pc & 0x0007) << 5)); packet[0] = (char8)(0x0000 | ((nc & 0x03C0) >> 5) | ((pc & 0x0007) << 5));
packet[1] = (char8)(0x0001 | ((pc & 0x03F8) >> 2)); packet[1] = (char8)(0x0001 | ((pc & 0x03F8) >> 2));
nc = (uint16)packet[1];
nc <<= 8;
nc &= 0xFF00;
nc |= packet[0];
REPORT_ERROR_PARAMETERS(ErrorManagement::Information, "CurrentPacket %d 0x%x",
pointOfCurrent, nc); // packet[0]);
// packet[1]);
return ok; return ok;
} }
bool PSUCommunicatorTX::SendMessage() { bool PSUCommunicatorTX::SendMessage() {
bool ok = true; bool ok = true;
// REPORT_ERROR_PARAMETERS(ErrorManagement::Information, "SendMessage %d %d",
// packet[0], packet[1]);
// packet[0], packet[1]);
serial.Write(packet, 2); serial.Write(packet, 2);
return ok; return ok;
} }
bool PSUCommunicatorTX::CommunicatorOnline() { bool PSUCommunicatorTX::CommunicatorOnline() {
bool ok = true; bool ok = true;
switch (communicatorOnlineStage) { switch (communicatorOnlineStage) {
@@ -351,6 +359,7 @@ bool PSUCommunicatorTX::CommunicatorOnline() {
// Log the entry on this stage // Log the entry on this stage
// if(this->communicatorOnlineIdleCount++ == 0) // if(this->communicatorOnlineIdleCount++ == 0)
// AssertErrorCondition(Information, "[FACom] COMMUNICATOR_ONLINE_IDLE"); // AssertErrorCondition(Information, "[FACom] COMMUNICATOR_ONLINE_IDLE");
isTriggered = false;
break; break;
// Wait for the CODAC trigger // Wait for the CODAC trigger
case FA_COMMUNICATOR_ONLINE_WAIT_CODAC_TRIGGER: case FA_COMMUNICATOR_ONLINE_WAIT_CODAC_TRIGGER:
@@ -360,21 +369,20 @@ bool PSUCommunicatorTX::CommunicatorOnline() {
// AssertErrorCondition(Information, "[FACom] // AssertErrorCondition(Information, "[FACom]
// COMMUNICATOR_ONLINE_WAIT_CODAC_TRIGGER"); // COMMUNICATOR_ONLINE_WAIT_CODAC_TRIGGER");
// if(IsTriggered) if (isTriggered) {
//{ // Send Start Operation message
// Send Start Operation message // this->SendMessage(FA_STARTOP_MESSAGE_1, FA_STARTOP_MESSAGE_2);
// this->SendMessage(FA_STARTOP_MESSAGE_1, FA_STARTOP_MESSAGE_2); packet[0] = FA_STARTOP_MESSAGE_1;
packet[0] = FA_STARTOP_MESSAGE_1; packet[1] = FA_STARTOP_MESSAGE_2;
packet[1] = FA_STARTOP_MESSAGE_2; SendMessage();
SendMessage();
// Increase attempts counter // Increase attempts counter
// this->communicatorOnlineStartOperationAttempts++; // this->communicatorOnlineStartOperationAttempts++;
// Change online state // Change online state
communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_DISCHARGE; communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_DISCHARGE;
// this->communicatorOnlineWaitTriggerCount = 0; // this->communicatorOnlineWaitTriggerCount = 0;
//} }
break; break;
case FA_COMMUNICATOR_ONLINE_DISCHARGE: case FA_COMMUNICATOR_ONLINE_DISCHARGE:
@@ -390,12 +398,13 @@ bool PSUCommunicatorTX::CommunicatorOnline() {
// CreateCurrentPacket(CurrentToSendCopy, packet1, packet2); // CreateCurrentPacket(CurrentToSendCopy, packet1, packet2);
CreateCurrentPacket(); CreateCurrentPacket();
ok = SendMessage(); ok = SendMessage();
communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_STOP_OPERATION; // communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_STOP_OPERATION;
break; break;
case FA_COMMUNICATOR_ONLINE_STOP_OPERATION: case FA_COMMUNICATOR_ONLINE_STOP_OPERATION:
packet[0] = FA_STARTOP_MESSAGE_1; packet[0] = FA_STARTOP_MESSAGE_1;
packet[1] = FA_STARTOP_MESSAGE_2; packet[1] = FA_STARTOP_MESSAGE_2;
ok = SendMessage(); ok = SendMessage();
communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_IDLE;
break; break;
case FA_COMMUNICATOR_ONLINE_ERROR: case FA_COMMUNICATOR_ONLINE_ERROR:
@@ -420,9 +429,9 @@ bool PSUCommunicatorTX::Synchronise() {
// if (channelsMemory != NULL_PTR(float32 *)) { // if (channelsMemory != NULL_PTR(float32 *)) {
// value = channelsMemory[0] / DAC_RANGE; // value = channelsMemory[0] / DAC_RANGE;
REPORT_ERROR_PARAMETERS(ErrorManagement::Information, CommunicatorOnline();
"Synchronise called. value: %f", currentValue); // REPORT_ERROR_PARAMETERS(ErrorManagement::Information,
// w = SetDacReg(i, value); // "Synchronise called. value: %f", currentValue);
// char8 *data = reinterpret_cast<char8 *>(&ser_value); // char8 *data = reinterpret_cast<char8 *>(&ser_value);
// serial.Write(data, sizeof(int32)); // serial.Write(data, sizeof(int32));
// serial.Write(text, 4); // serial.Write(text, 4);
@@ -438,7 +447,8 @@ ErrorManagement::ErrorType PSUCommunicatorTX::GoOnlineIdle() {
ErrorManagement::ErrorType err; ErrorManagement::ErrorType err;
REPORT_ERROR(ErrorManagement::Information, REPORT_ERROR(ErrorManagement::Information,
"PSUCommunicatorTX::GoOnlineIdle. Got Message!"); "PSUCommunicatorTX::GoOnlineIdle. Got Message!");
communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_IDLE; communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_STOP_OPERATION;
// communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_IDLE;
return err; return err;
} }
@@ -451,10 +461,12 @@ ErrorManagement::ErrorType PSUCommunicatorTX::GoWaitTrigger() {
return err; return err;
} }
ErrorManagement::ErrorType PSUCommunicatorTX::TriggerPSU() { ErrorManagement::ErrorType PSUCommunicatorTX::TriggerPSU() {
isTriggered = true;
ErrorManagement::ErrorType err; ErrorManagement::ErrorType err;
REPORT_ERROR(ErrorManagement::Information, REPORT_ERROR(ErrorManagement::Information,
"PSUCommunicatorTX::TriggerPSU. Got Message!"); "PSUCommunicatorTX::TriggerPSU. Got Message!");
communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_DISCHARGE; // communicatorOnlineStage = FA_COMMUNICATOR_ONLINE_DISCHARGE;
return err; return err;
} }

View File

@@ -234,6 +234,7 @@ private:
float32 pointOfZeroCurrent; float32 pointOfZeroCurrent;
// Communicator online behaviour // Communicator online behaviour
uint32 communicatorOnlineStage; uint32 communicatorOnlineStage;
bool isTriggered;
/** /**
* Filter to receive the RPC which allows to change the... * Filter to receive the RPC which allows to change the...