32 for (std::list<AnalogyDevice*>::iterator i = devices.begin();
43 std::string name = args.front();
45 err = a4l_open(&dsc, name.c_str());
47 ERROR_MSG(
"AnalogyDriver::createDevice : unable to open %s (err=%d).\n",
54 dsc.sbdata = malloc(dsc.sbsize);
55 if (dsc.sbdata == NULL) {
57 ERROR_MSG(
"AnalogyDriver: info buffer allocation failed\n");
62 err = a4l_fill_desc(&dsc);
65 "AnalogyDriver: a4l_fill_desc failed (err=%d)\nPlease run " 66 "rtxi_load_analogy script in scripts directory.\n",
76 for (
int i = 0; i < dsc.nb_subd; i++) {
77 err = a4l_get_subdinfo(&dsc, i, &sbinfo);
80 "AnalogyDriver: a4l_get_subd_info failed, wrong subdevice index %i " 87 if (((sbinfo->flags & A4L_SUBD_TYPES) == A4L_SUBD_AI) && (idx_ai < 0))
89 else if (((sbinfo->flags & A4L_SUBD_TYPES) == A4L_SUBD_AO) && (idx_ao < 0))
91 else if (((sbinfo->flags & A4L_SUBD_TYPES) == A4L_SUBD_DIO)
103 err = a4l_get_subdinfo(&dsc, idx_ai, &sbinfo);
105 count[0] = sbinfo->nb_chan;
106 err = a4l_get_subdinfo(&dsc, idx_ao, &sbinfo);
108 count[1] = sbinfo->nb_chan;
109 err = a4l_get_subdinfo(&dsc, idx_dio, &sbinfo);
111 count[2] = sbinfo->nb_chan;
113 if (!(count[0] + count[1] + count[2] + count[3] + count[4])) {
115 "AnalogyDriver::createDevice : no Analogy device configured on %s.\n",
122 for (
size_t i = 0; i < count[0]; ++i) {
123 std::ostringstream name;
124 name <<
"Analog Input " << i;
125 channel[i].
name = name.str();
126 channel[i].description =
"";
129 for (
size_t i = count[0]; i < count[0] + count[1]; ++i) {
130 std::ostringstream name;
131 name <<
"Analog Output " << i - count[0];
132 channel[i].name = name.str();
133 channel[i].description =
"";
136 for (
size_t i = count[0] + count[1]; i < count[0] + count[1] + count[2]; ++i)
138 std::ostringstream name;
139 name <<
"Digital I/O " << i - count[0] - count[1];
140 channel[i].name = name.str();
141 channel[i].description =
"";
144 for (
size_t i = count[0] + count[1] + count[2];
145 i < count[0] + count[1] + 2 * count[2];
148 std::ostringstream name;
149 name <<
"Digital I/O " << i - count[0] - count[1] - count[2];
150 channel[i].name = name.str();
151 channel[i].description =
"";
154 for (
size_t i = count[0] + count[1] + 2 * count[2];
155 i < count[0] + count[1] + 2 * count[2] + count[3];
158 std::ostringstream name;
159 name <<
"Digital Input " << i - count[0] - count[1] - 2 * count[2];
160 channel[i].name = name.str();
161 channel[i].description =
"";
164 for (
size_t i = count[0] + count[1] + 2 * count[2] + count[3];
165 i < count[0] + count[1] + 2 * count[2] + count[3] + count[4];
168 std::ostringstream name;
169 name <<
"Digital Output " 170 << i - count[0] - count[1] - 2 * count[2] - count[3];
171 channel[i].name = name.str();
172 channel[i].description =
"";
177 &dsc, name, channel, count[0] + count[1] + 2 * count[2]);
178 devices.push_back(dev);
186 for (
size_t i = 0, end = s.loadInteger(
"Num Devices"); i < end; ++i) {
187 std::list<std::string> args;
188 args.push_back(s.loadString(QString::number(i).toStdString()));
191 device->load(s.loadState(QString::number(i).toStdString()));
197 s.saveInteger(
"Num Devices", devices.size());
199 for (std::list<AnalogyDevice*>::const_iterator i = devices.begin(),
204 std::ostringstream str;
206 s.saveString(str.str(), (*i)->getName());
207 s.saveState(str.str(), (*i)->save());
Plugin::Object * createRTXIPlugin(void)
virtual void doLoad(const State &)
virtual ~AnalogyDriver(void)
virtual DAQ::Device * createDevice(const std::list< std::string > &)
virtual void doSave(State &) const
void ERROR_MSG(const std::string &errmsg, Args... args)