Skip to content

Commit 92ebcee

Browse files
kwang428yuyichao
authored andcommitted
[awg/backend] Putting in Analog Streams capabilities
1 parent 62b9e34 commit 92ebcee

1 file changed

Lines changed: 45 additions & 19 deletions

File tree

lib/nacs-seq/awg/backend.cpp

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ enum class Backend::ChnType : uint8_t
5050
{
5151
Freq,
5252
Amp,
53-
Phase
53+
Phase,
54+
Analog
5455
};
5556

5657
struct Backend::ChannelInfo {
@@ -181,23 +182,35 @@ void Backend::add_channel(uint32_t chn_id, const std::string &_chn_name)
181182
Backend::ChnType chn_type;
182183
if (!starts_with(phys_chn_str, "OUT"))
183184
throw std::runtime_error("Physical channel should be specified with OUT");
184-
if (!starts_with(chn_num_str, "CHN"))
185-
throw std::runtime_error("Virtual channel should be specified with CHN");
185+
bool is_chn = starts_with(chn_num_str, "CHN");
186+
bool is_analog = starts_with(chn_num_str, "A");
187+
if (!is_chn && !is_analog)
188+
throw std::runtime_error("Virtual channel should be specified with CHN or A");
186189
phys_chn_str = phys_chn_str.substr(3);
187-
chn_num_str = chn_num_str.substr(3);
188-
if (phys_chn_str.getAsInteger(10, phys_chn_num))
189-
throw std::runtime_error("Physical output for AWG must be a number.");
190-
if (chn_num_str.getAsInteger(10, chn_num))
191-
throw std::runtime_error("Channel for AWG must be a number.");
192-
if (type_str == "FREQ")
193-
chn_type = Backend::ChnType::Freq;
194-
else if (type_str == "AMP")
195-
chn_type = Backend::ChnType::Amp;
196-
else if (type_str == "PHASE")
197-
chn_type = Backend::ChnType::Phase;
190+
if (is_chn) {
191+
chn_num_str = chn_num_str.substr(3);
192+
if (chn_num_str.getAsInteger(10, chn_num))
193+
throw std::runtime_error("Channel for AWG must be a number.");
194+
if (type_str == "FREQ")
195+
chn_type = Backend::ChnType::Freq;
196+
else if (type_str == "AMP")
197+
chn_type = Backend::ChnType::Amp;
198+
else if (type_str == "PHASE")
199+
chn_type = Backend::ChnType::Phase;
200+
else {
201+
throw std::runtime_error("Unknown name for channel. Use FREQ, AMP, PHASE");
202+
}
203+
}
198204
else {
199-
throw std::runtime_error("Unknown name for channel. Use FREQ, AMP, PHASE");
205+
// A1, A2, A3,...
206+
chn_num_str = chn_num_str.substr(1);
207+
if (chn_num_str.getAsInteger(10, chn_num))
208+
throw std::runtime_error("Analog channel for AWG must be a number.");
209+
chn_type = Backend::ChnType::Analog;
200210
}
211+
if (phys_chn_str.getAsInteger(10, phys_chn_num))
212+
throw std::runtime_error("Physical output for AWG must be a number.");
213+
201214
m_chn_map.try_emplace(chn_id, phys_chn_num, chn_num, chn_type);
202215
auto it = out_chns.begin();
203216
for (; it != out_chns.end(); ++it) {
@@ -218,7 +231,7 @@ static unsigned get_vector_size()
218231

219232
void Backend::sort_channels()
220233
{
221-
// assignment of linear channel id
234+
// assignment of linear channel id. Sorting is based on the order in Backend::ChnType. Doesn't really matter...
222235
auto nchn = (uint32_t)m_chn_map.size();
223236
m_linear_chns.resize(nchn);
224237
auto it = m_chn_map.begin();
@@ -756,9 +769,13 @@ uint8_t Backend::get_pulse_type(Backend::ChnType type, bool is_fn, bool is_vecto
756769
// FreqSet, 4
757770
// FreqFn, 5
758771
// FreqVecFn, 6
759-
// ModChn, // add or delete channels
760-
// Phase,
761-
// _MAX = Phase // keeps track of how many CmdType options there are
772+
// ModChn, 7 // add or delete channels
773+
// Phase, 8
774+
// AnalogModChn, 9
775+
// AnalogSet, 10
776+
// AnalogFn, 11
777+
// AnalogVecFn, 12
778+
// _MAX = AnalogVecFn // keeps track of how many CmdType options there are
762779
// };
763780
//auto type = chn_info.m_chn_type;
764781
if (type == Backend::ChnType::Phase) {
@@ -767,6 +784,15 @@ uint8_t Backend::get_pulse_type(Backend::ChnType type, bool is_fn, bool is_vecto
767784
}
768785
return 8;
769786
}
787+
if (type == Backend::ChnType::Analog) {
788+
if (is_fn) {
789+
if (is_vector) {
790+
return 12; // AnalogVecFn
791+
}
792+
return 11; // AnalogFn
793+
}
794+
return 10; // AnalogSet
795+
}
770796
uint8_t base = 0;
771797
if (type == Backend::ChnType::Freq) {
772798
base = 4;

0 commit comments

Comments
 (0)