Skip to content

Commit

Permalink
Adding NaN, Infinity, and negative Infinity (#2131)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch authored Jul 17, 2023
1 parent be4088d commit 8498e4f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Ref/Top/RefPackets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@
<channel name="typeDemo.ExtraChoicesCh"/>
<channel name="typeDemo.ChoicePairCh"/>
<channel name="typeDemo.ChoiceSlurryCh"/>
<channel name="typeDemo.Float1Ch"/>
<channel name="typeDemo.Float2Ch"/>
<channel name="typeDemo.Float3Ch"/>
<channel name="typeDemo.FloatSet"/>
</packet>

<!-- Ignored packets -->
Expand Down
12 changes: 12 additions & 0 deletions Ref/TypeDemo/TypeDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,16 @@ void TypeDemo ::DUMP_TYPED_PARAMETERS_cmdHandler(const FwOpcodeType opCode, cons
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}

void TypeDemo ::DUMP_FLOATS_cmdHandler(const FwOpcodeType opCode, const U32 cmdSeq) {
Ref::FloatSet invalid;
invalid[0] = std::numeric_limits<float>::infinity();
invalid[1] = -1 * std::numeric_limits<float>::infinity();
invalid[2] = (std::numeric_limits<float>::has_quiet_NaN) ? std::numeric_limits<float>::quiet_NaN() : 0.0f;
this->log_ACTIVITY_HI_FloatEv(invalid[0], invalid[1], invalid[2], invalid);
this->tlmWrite_Float1Ch(invalid[0]);
this->tlmWrite_Float2Ch(invalid[1]);
this->tlmWrite_Float3Ch(invalid[2]);
this->tlmWrite_FloatSet(invalid);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
} // end namespace Ref
25 changes: 25 additions & 0 deletions Ref/TypeDemo/TypeDemo.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ module Ref {
choicePair: ChoicePair
}

@ Set of floating points to emit
array FloatSet = [3] F32;

@ Component to demonstrate multiple type configurations
passive component TypeDemo {
#####
Expand Down Expand Up @@ -192,6 +195,28 @@ module Ref {
@ Dump the typed parameters
sync command DUMP_TYPED_PARAMETERS()

#####
# FloatSet outputs
#####
@ A set of floats in an event
event FloatEv(float1: F32, float2: F32, float3: F32, floats: FloatSet) severity activity high \
format "Floats: {} {} {} as a set: {}"

@ Float output channel 1
telemetry Float1Ch: F32

@ Float output channel 2
telemetry Float2Ch: F32

@ Float output channel 3
telemetry Float3Ch: F32

@ Float set output channel
telemetry FloatSet: FloatSet

@ Dump the float values
sync command DUMP_FLOATS()

# ----------------------------------------------------------------------
# Special ports
# ----------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions Ref/TypeDemo/TypeDemo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ class TypeDemo : public TypeDemoComponentBase {
void DUMP_TYPED_PARAMETERS_cmdHandler(const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq /*!< The command sequence number*/
);

//! Implementation for DUMP_FLOATS command handler
//!
void DUMP_FLOATS_cmdHandler(const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq /*!< The command sequence number*/
);
};

} // end namespace Ref
Expand Down

0 comments on commit 8498e4f

Please sign in to comment.