Skip to content

Commit

Permalink
Update dfmux HousekeepingConsumer for mkids firmware (#152)
Browse files Browse the repository at this point in the history
Add optional entries for RF-ICE properties in housekeeping dump.  Also use a different `ReadoutSystem` entry in the wiring frame (`"RF-ICE"` instead of `"ICE"`), for use later in converting timestreams into physical units.

Maintain backwards compatibility with 3G firmware throughout.
  • Loading branch information
arahlin authored Apr 5, 2024
1 parent b4d59d7 commit 2660f2a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 22 deletions.
21 changes: 16 additions & 5 deletions dfmux/include/dfmux/Housekeeping.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class HkChannelInfo : public G3FrameObject
HkChannelInfo() : G3FrameObject(), channel_number(-1), carrier_amplitude(NAN),
carrier_frequency(NAN), dan_accumulator_enable(false), dan_feedback_enable(false),
dan_streaming_enable(false), dan_gain(NAN), demod_frequency(NAN), nuller_amplitude(NAN),
dan_railed(false), rlatched(NAN), rnormal(NAN), rfrac_achieved(NAN), loopgain(NAN) {}
dan_railed(false), rlatched(NAN), rnormal(NAN), rfrac_achieved(NAN), loopgain(NAN),
carrier_phase(NAN), nuller_phase(NAN), demod_phase(NAN) {}

int32_t channel_number; // 1-indexed
double carrier_amplitude;
Expand All @@ -45,20 +46,26 @@ class HkChannelInfo : public G3FrameObject
double rfrac_achieved;
double loopgain;

// hidfmux properties
double carrier_phase;
double nuller_phase;
double demod_phase;

template <class A> void serialize(A &ar, unsigned v);
std::string Description() const;
};

G3_POINTERS(HkChannelInfo);
G3_SERIALIZABLE(HkChannelInfo, 5);
G3_SERIALIZABLE(HkChannelInfo, 6);

class HkModuleInfo : public G3FrameObject
{
public:
HkModuleInfo() : G3FrameObject(), module_number(-1), carrier_gain(-1),
nuller_gain(-1), demod_gain(-1), carrier_railed(false), nuller_railed(false),
demod_railed(false), squid_flux_bias(NAN), squid_current_bias(NAN),
squid_stage1_offset(NAN), squid_p2p(NAN), squid_transimpedance(NAN) {}
squid_stage1_offset(NAN), squid_p2p(NAN), squid_transimpedance(NAN),
nco_frequency(NAN) {}

int32_t module_number; // 1-indexed

Expand All @@ -81,14 +88,16 @@ class HkModuleInfo : public G3FrameObject
std::string squid_feedback;
std::string routing_type;

double nco_frequency;

std::map<int32_t, HkChannelInfo> channels; // 1-indexed

template <class A> void serialize(A &ar, unsigned v);
std::string Description() const;
};

G3_POINTERS(HkModuleInfo);
G3_SERIALIZABLE(HkModuleInfo, 2);
G3_SERIALIZABLE(HkModuleInfo, 3);

class HkMezzanineInfo : public G3FrameObject
{
Expand Down Expand Up @@ -130,6 +139,8 @@ class HkBoardInfo : public G3FrameObject

std::string timestamp_port;
std::string serial;
std::string firmware_version;
std::string firmware_name;
int32_t fir_stage;
bool is128x;

Expand All @@ -144,7 +155,7 @@ class HkBoardInfo : public G3FrameObject
};

G3_POINTERS(HkBoardInfo);
G3_SERIALIZABLE(HkBoardInfo, 2);
G3_SERIALIZABLE(HkBoardInfo, 3);

G3MAP_OF(int32_t, HkBoardInfo, DfMuxHousekeepingMap);

Expand Down
55 changes: 38 additions & 17 deletions dfmux/python/Housekeeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ def ProcessBuffered(self, frame):
# avoid overloading the network on the return

found = False
ismkid = False
for board in self.board_serials:
dat = self.tuber[board].GetReply()[0]['result']

boardhk = self.HousekeepingFromJSON(dat)
if boardhk.firmware_name:
ismkid = ismkid or "mkid" in boardhk.firmware_name.lower()
hkdata[int(boardhk.serial)] = boardhk

ip, crate, slot = self.board_map[board]
Expand All @@ -149,7 +152,7 @@ def ProcessBuffered(self, frame):

hwmf = core.G3Frame(core.G3FrameType.Wiring)
hwmf['WiringMap'] = hwm
hwmf['ReadoutSystem'] = 'ICE'
hwmf['ReadoutSystem'] = 'RF-ICE' if ismkid else 'ICE'

if self.hwmf is None:
self.hwmf = hwmf
Expand Down Expand Up @@ -213,6 +216,9 @@ def HousekeepingFromJSON(cls, dat):

boardhk.timestamp_port = str(dat['timestamp_port'])
boardhk.serial = str(dat['serial'])
if 'firmware_name' in dat:
boardhk.firmware_name = str(dat['firmware_name'])
boardhk.firmware_version = str(dat['firmware_version'])
boardhk.fir_stage = dat['fir_stage']
for i in dat['currents'].items():
boardhk.currents[str(i[0])] = i[1]
Expand All @@ -227,16 +233,20 @@ def HousekeepingFromJSON(cls, dat):
mezzhk.present = mezz['present']
mezzhk.power = mezz['power']
if mezzhk.present:
mezzhk.serial = str(mezz['ipmi']['product']['serial_number'])
mezzhk.part_number = str(mezz['ipmi']['product']['part_number'])
mezzhk.revision = str(mezz['ipmi']['product']['version_number'])
for i in mezz['currents'].items():
mezzhk.currents[str(i[0])] = i[1]
for i in mezz['voltages'].items():
mezzhk.voltages[str(i[0])] = i[1]
if 'ipmi' in mezz:
mezzhk.serial = str(mezz['ipmi']['product']['serial_number'])
mezzhk.part_number = str(mezz['ipmi']['product']['part_number'])
mezzhk.revision = str(mezz['ipmi']['product']['version_number'])
if 'currents' in mezz:
for i in mezz['currents'].items():
mezzhk.currents[str(i[0])] = i[1]
if 'voltages' in mezz:
for i in mezz['voltages'].items():
mezzhk.voltages[str(i[0])] = i[1]

if mezzhk.present and mezzhk.power:
mezzhk.temperature = mezz['temperature']
if 'temperature' in mezz:
mezzhk.temperature = mezz['temperature']
# these parameters are not in the 64x housekeeping tuber
mezzhk.squid_heater = mezz.get('squid_heater', 0.0)
mezzhk.squid_controller_power = mezz.get('squid_controller_power', False)
Expand All @@ -261,6 +271,8 @@ def HousekeepingFromJSON(cls, dat):
modhk.squid_current_bias = mod['squid_flux_bias']
if 'squid_feedback' in mod:
modhk.squid_feedback = str(mod['squid_feedback'])
if 'nco_frequency' in mod:
modhk.nco_frequency = mod['nco_frequency'] * core.G3Units.Hz

if 'squid_tuning' in mod and mod['squid_tuning'] is not None:
modhk.squid_state = str(mod['squid_tuning']['state'])
Expand All @@ -272,15 +284,23 @@ def HousekeepingFromJSON(cls, dat):
chanhk.channel_number = k+1
chanhk.carrier_amplitude = chan['carrier_amplitude']
chanhk.nuller_amplitude = chan['nuller_amplitude']
chanhk.dan_gain = chan['dan_gain']
chanhk.dan_streaming_enable = chan['dan_streaming_enable']
if boardhk.is128x:
chanhk.carrier_frequency = chan['frequency']*core.G3Units.Hz
chanhk.demod_frequency = chan['frequency']*core.G3Units.Hz
if 'dan_gain' in chan:
chanhk.dan_gain = chan['dan_gain']
if 'dan_streaming_enable' in chan:
chanhk.dan_streaming_enable = chan['dan_streaming_enable']
if 'frequency' in chan:
chanhk.carrier_frequency = chan['frequency'] * core.G3Units.Hz
chanhk.demod_frequency = chan['frequency'] * core.G3Units.Hz
else:
chanhk.carrier_frequency = chan['carrier_frequency']*core.G3Units.Hz
chanhk.demod_frequency = chan['demod_frequency']*core.G3Units.Hz
chanhk.carrier_frequency = chan['carrier_frequency'] * core.G3Units.Hz
chanhk.demod_frequency = chan['demod_frequency'] * core.G3Units.Hz
if 'carrier_phase' in chan:
chanhk.carrier_phase = chan['carrier_phase'] * core.G3Units.deg
chanhk.nuller_phase = chan['nuller_phase'] * core.G3Units.deg
chanhk.demod_phase = chan['demod_phase'] * core.G3Units.deg
if 'dan_accumulator_enable' in chan:
chanhk.dan_accumulator_enable = chan['dan_accumulator_enable']
if 'dan_feedback_enable' in chan:
chanhk.dan_feedback_enable = chan['dan_feedback_enable']
if 'dan_railed' in chan:
chanhk.dan_railed = chan['dan_railed']
Expand Down Expand Up @@ -316,6 +336,7 @@ def WiringFromJSON(cls, dat, ip, crate, slot):
serial = int(dat['serial'])
for imezz, mezz in enumerate(dat['mezzanines']):
for imod, mod in enumerate(mezz['modules']):
module = imod + len(mezz['modules']) * imezz
for ichan, chan in enumerate(mod['channels']):
name = (chan.get('tuning', {}) or {}).get('name', None)
if not name:
Expand All @@ -325,7 +346,7 @@ def WiringFromJSON(cls, dat, ip, crate, slot):
mapping.board_serial = serial
mapping.board_slot = slot
mapping.crate_serial = crate
mapping.module = imod + 4 * imezz
mapping.module = module
mapping.channel = ichan
try:
name = str(name)
Expand Down
27 changes: 27 additions & 0 deletions dfmux/src/Housekeeping.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ template <class A> void HkChannelInfo::serialize(A &ar, unsigned v)
if (v > 4) {
ar & make_nvp("loopgain", loopgain);
}

if (v > 5) {
ar & make_nvp("carrier_phase", carrier_phase);
ar & make_nvp("nuller_phase", nuller_phase);
ar & make_nvp("demod_phase", demod_phase);
}
}

std::string HkModuleInfo::Description() const
Expand Down Expand Up @@ -83,6 +89,10 @@ template <class A> void HkModuleInfo::serialize(A &ar, unsigned v)
ar & make_nvp("squid_p2p", squid_p2p);
ar & make_nvp("squid_transimpedance", squid_transimpedance);
}

if (v >= 3) {
ar & make_nvp("nco_frequency", nco_frequency);
}
}

std::string HkMezzanineInfo::Description() const
Expand Down Expand Up @@ -146,6 +156,11 @@ template <class A> void HkBoardInfo::serialize(A &ar, unsigned v)
if (v >= 2) {
ar & make_nvp("is128x", is128x);
}

if (v >= 3) {
ar & make_nvp("firmware_version", firmware_version);
ar & make_nvp("firmware_name", firmware_name);
}
}

G3_SERIALIZABLE_CODE(HkChannelInfo);
Expand Down Expand Up @@ -197,6 +212,12 @@ PYBINDINGS("dfmux") {
.def_readwrite("loopgain", &HkChannelInfo::loopgain,
"Measured loopgain of the detector as stored by the "
"control software tuning script.")
.def_readwrite("carrier_phase", &HkChannelInfo::carrier_phase,
"Carrier phase in standard angle units (mkid only)")
.def_readwrite("nuller_phase", &HkChannelInfo::nuller_phase,
"Nuller phase in standard angle units (mkid only)")
.def_readwrite("demod_phase", &HkChannelInfo::demod_phase,
"Demodulator phase in standard angle units (mkid only)")
;
register_map<std::map<int, HkChannelInfo> >("HkChannelInfoMap",
"Mapping of channel number (1-indexed) to channel status "
Expand Down Expand Up @@ -233,6 +254,8 @@ PYBINDINGS("dfmux") {
"tuning script to describe SQUID state")
.def_readwrite("squid_feedback", &HkModuleInfo::squid_feedback,
"SQUID feedback mechanism employed")
.def_readwrite("nco_frequency", &HkModuleInfo::nco_frequency,
"NCO frequency in standard frequency units (mkid only)")
.def_readwrite("routing_type", &HkModuleInfo::routing_type,
"Whether DAC are routed directly to ADCs or to the cryostat")
.def_readwrite("channels", &HkModuleInfo::channels,
Expand Down Expand Up @@ -288,6 +311,10 @@ PYBINDINGS("dfmux") {
"faster and grow by factors of two with each decrement")
.def_readwrite("is128x", &HkBoardInfo::is128x,
"Boolean for whether 128x firmware is running")
.def_readwrite("firmware_version", &HkBoardInfo::firmware_version,
"Firmware version")
.def_readwrite("firmware_name", &HkBoardInfo::firmware_name,
"Firmware name")
.def_readwrite("currents", &HkBoardInfo::currents,
"Dictionary of data from on-board current sensors")
.def_readwrite("voltages", &HkBoardInfo::voltages,
Expand Down

0 comments on commit 2660f2a

Please sign in to comment.