]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/intellibox.cpp
Fix remaining exception class names
[r2c2.git] / source / libr2c2 / intellibox.cpp
1 #include <fcntl.h>
2 #include <termios.h>
3 #include <sys/poll.h>
4 #include <msp/io/print.h>
5 #include <msp/time/units.h>
6 #include <msp/time/utils.h>
7 #include "intellibox.h"
8 #include "tracktype.h"
9 #include "vehicletype.h"
10
11 using namespace std;
12 using namespace Msp;
13
14 namespace R2C2 {
15
16 Intellibox::Intellibox(const string &dev):
17         serial(dev),
18         power(false),
19         halted(false),
20         update_sensors(false),
21         command_sent(false)
22 {
23         static unsigned baud[]= { 2400, 4800, 9600, 19200, 0 };
24
25         serial.set_stop_bits(2);
26
27         bool ok = false;
28         bool p50 = false;
29         for(unsigned i=0; baud[i]; ++i)
30         {
31                 serial.set_baud_rate(baud[i]);
32                 serial.put('\xC4');
33
34                 if(IO::poll(serial, IO::P_INPUT, 500*Time::msec))
35                 {
36                         IO::print("IB detected at %d bits/s\n", baud[i]);
37                         char buf[2];
38                         p50 = (serial.read(buf, 2)==2);
39                         ok = true;
40                         break;
41                 }
42         }
43
44         if(!ok)
45                 throw runtime_error("IB not detected");
46
47         if(p50)
48                 serial.write("xZzA1\r", 6);
49
50         command(CMD_STATUS);
51 }
52
53 void Intellibox::set_power(bool p)
54 {
55         power = p;
56         if(power)
57                 command(CMD_POWER_ON);
58         else
59                 command(CMD_POWER_OFF);
60         signal_power.emit(power);
61 }
62
63 void Intellibox::halt(bool h)
64 {
65         halted = h;
66         if(halted)
67         {
68                 for(map<unsigned, Locomotive>::iterator i=locos.begin(); i!=locos.end(); ++i)
69                         if(i->second.speed)
70                                 set_loco_speed(i->first, 0);
71         }
72
73         signal_halt.emit(halted);
74 }
75
76 const char *Intellibox::enumerate_protocols(unsigned i) const
77 {
78         ++i;
79         if(i==MM)
80                 return "MM";
81         else if(i==MM_27)
82                 return "MM-27";
83         return 0;
84 }
85
86 unsigned Intellibox::get_protocol_speed_steps(const string &proto_name) const
87 {
88         Protocol proto = map_protocol(proto_name);
89         if(proto==MM)
90                 return 14;
91         else if(proto==MM_27)
92                 return 27;
93         return 0;
94 }
95
96 void Intellibox::add_loco(unsigned addr, const string &proto_name, const VehicleType &type)
97 {
98         Protocol proto = map_protocol(proto_name);
99
100         if(!locos.count(addr))
101         {
102                 Locomotive &loco = locos[addr];
103                 loco.protocol = proto;
104                 if(type.get_max_function()>4)
105                 {
106                         loco.ext_func = true;
107                         locos[addr+1].protocol = NONE;
108                 }
109
110                 unsigned char data[2];
111                 data[0] = addr&0xFF;
112                 data[1] = (addr>>8)&0xFF;
113                 command(CMD_LOK_STATUS, addr, data, 2);
114         }
115 }
116
117 void Intellibox::set_loco_speed(unsigned addr, unsigned speed)
118 {
119         Locomotive &loco = locos[addr];
120         if(loco.protocol==NONE)
121                 return;
122
123         if(speed==loco.speed)
124         {
125                 if(loco.pending_half_step)
126                 {
127                         loco.pending_half_step = 0;
128                         loco.half_step_delay = Time::TimeStamp();
129                         signal_loco_speed.emit(addr, speed, loco.reverse);
130                 }
131                 return;
132         }
133         if(speed && halted)
134                 return;
135
136         if(loco.protocol==MM_27)
137         {
138                 if(speed>27)
139                         speed = 27;
140
141                 if(speed>loco.speed && !(speed&1))
142                 {
143                         loco.pending_half_step = -1;
144                         speed |= 1;
145                 }
146                 else if(speed<loco.speed && (speed&1))
147                 {
148                         loco.pending_half_step = 1;
149                         speed &= ~1;
150                 }
151                 else
152                         loco.pending_half_step = 0;
153                 loco.half_step_delay = Time::TimeStamp();
154
155                 loco_command(addr, (speed+1)/2, loco.reverse, loco.funcs, false);
156         }
157         else if(loco.protocol==MM)
158         {
159                 if(speed>14)
160                         speed = 14;
161
162                 loco_command(addr, speed, loco.reverse, loco.funcs, false);
163         }
164         loco.speed = speed;
165 }
166
167 void Intellibox::set_loco_reverse(unsigned addr, bool rev)
168 {
169         Locomotive &loco = locos[addr];
170         if(loco.protocol==NONE || rev==loco.reverse)
171                 return;
172
173         loco.speed = 0;
174         loco.reverse = rev;
175         loco_command(addr, 0, rev, loco.funcs, false);
176 }
177
178 void Intellibox::set_loco_function(unsigned addr, unsigned func, bool state)
179 {
180         Locomotive &loco = locos[addr];
181         if(loco.protocol==NONE)
182                 return;
183
184         if(state)
185                 loco.funcs |= 1<<func;
186         else
187                 loco.funcs &= ~(1<<func);
188         if(func<=4)
189                 loco_command(addr, loco.speed, loco.reverse, loco.funcs, true);
190         else if(loco.ext_func && func<=8)
191                 loco_command(addr+1, 0, false, (loco.funcs>>4)&0x1E, true);
192         signal_loco_function.emit(addr, func, state);
193 }
194
195 void Intellibox::add_turnout(unsigned addr, const TrackType &type)
196 {
197         if(!turnouts.count(addr))
198         {
199                 Turnout &turnout = turnouts[addr];
200                 turnout.bits = type.get_state_bits();
201
202                 unsigned char data[2];
203                 data[0] = addr&0xFF;
204                 data[1] = (addr>>8)&0xFF;
205                 command(CMD_TURNOUT_STATUS, addr, data, 2);
206                 for(unsigned i=1; i<turnout.bits; ++i)
207                 {
208                         turnouts[addr+i].bits = 0;
209
210                         ++data[0];
211                         if(!data[0])
212                                 ++data[1];
213                         command(CMD_TURNOUT_STATUS, addr+i, data, 2);
214                 }
215         }
216 }
217
218 void Intellibox::set_turnout(unsigned addr, unsigned state)
219 {
220         Turnout &turnout = turnouts[addr];
221         unsigned mask = (1<<turnout.bits)-1;
222         if(((state^turnout.state)&mask)==0 || ((state^turnout.pending)&mask)==0 || !turnout.synced)
223         {
224                 turnout.state = state;
225                 turnout.pending = state;
226                 signal_turnout.emit(addr, state);
227                 return;
228         }
229
230         turnout.state = (turnout.state&mask) | (state&~mask);
231         turnout.pending = state;
232         turnout.active = true;
233         turnout.off_timeout = Time::TimeStamp();
234
235         for(unsigned i=0; i<turnout.bits; ++i)
236                 if((state^turnout.state)&(1<<i))
237                         turnout_command(addr+i, !(state&(1<<i)), true);
238 }
239
240 unsigned Intellibox::get_turnout(unsigned addr) const
241 {
242         map<unsigned, Turnout>::const_iterator i = turnouts.find(addr);
243         if(i!=turnouts.end())
244                 return i->second.state;
245         return 0;
246 }
247
248 void Intellibox::add_sensor(unsigned addr)
249 {
250         if(!sensors.count(addr))
251         {
252                 sensors[addr];
253                 update_sensors = true;
254         }
255 }
256
257 bool Intellibox::get_sensor(unsigned addr) const
258 {
259         map<unsigned, Sensor>::const_iterator i = sensors.find(addr);
260         if(i!=sensors.end())
261                 return i->second.state;
262         return false;
263 }
264
265 void Intellibox::tick()
266 {
267         const Time::TimeStamp t = Time::now();
268
269         if(t>next_event_query)
270         {
271                 next_event_query = t+200*Time::msec;
272                 command(CMD_EVENT);
273         }
274
275         for(map<unsigned, Locomotive>::iterator i=locos.begin(); i!=locos.end(); ++i)
276                 if(i->second.protocol==MM_27 && i->second.pending_half_step && i->second.half_step_delay && t>i->second.half_step_delay)
277                 {
278                         i->second.speed += i->second.pending_half_step;
279                         i->second.pending_half_step = 0;
280                         i->second.half_step_delay = Time::TimeStamp();
281                         loco_command(i->first, (i->second.speed+1)/2, i->second.reverse, i->second.funcs, false);
282                 }
283
284         for(map<unsigned, Turnout>::iterator i=turnouts.begin(); i!=turnouts.end(); ++i)
285                 if(i->second.active && i->second.off_timeout && t>i->second.off_timeout)
286                 {
287                         i->second.active = false;
288                         i->second.off_timeout = Time::TimeStamp();
289                         for(unsigned j=0; j<i->second.bits; ++j)
290                                 turnout_command(i->first+j, !(i->second.state&(1<<j)), false);
291                 }
292
293         for(map<unsigned, Sensor>::iterator i=sensors.begin(); i!=sensors.end(); ++i)
294                 if(i->second.off_timeout && t>i->second.off_timeout)
295                 {
296                         i->second.state = false;
297                         i->second.off_timeout = Time::TimeStamp();
298                         signal_sensor.emit(i->first, false);
299                 }
300
301         if(update_sensors)
302         {
303                 unsigned max_addr = (--sensors.end())->first;
304                 unsigned char data[2];
305                 data[0] = 0;
306                 data[1] = (max_addr+7)/8;
307                 command(CMD_SENSOR_PARAM_SET, data, 2);
308                 command(CMD_SENSOR_REPORT);
309                 update_sensors = false;
310         }
311
312         if(!queue.empty() && command_sent)
313         {
314                 if(IO::poll(serial, IO::P_INPUT, Time::zero))
315                 {
316                         process_reply(t);
317                         queue.erase(queue.begin());
318                         command_sent = false;
319                 }
320                 else
321                         return;
322         }
323
324         if(!queue.empty())
325         {
326                 const CommandSlot &slot = queue.front();
327                 serial.write(reinterpret_cast<const char *>(slot.data), slot.length);
328                 command_sent = true;
329         }
330 }
331
332 void Intellibox::flush()
333 {
334         for(list<CommandSlot>::iterator i=queue.begin(); i!=queue.end(); ++i)
335         {
336                 serial.write(reinterpret_cast<const char *>(i->data), i->length);
337                 bool first = true;
338                 while(first ? IO::poll(serial, IO::P_INPUT) : IO::poll(serial, IO::P_INPUT, Time::zero))
339                 {
340                         char data[16];
341                         serial.read(data, 16);
342                         first = false;
343                 }
344         }
345
346         queue.clear();
347         command_sent = false;
348 }
349
350 Intellibox::Protocol Intellibox::map_protocol(const string &name) const
351 {
352         if(name=="MM")
353                 return MM;
354         else if(name=="MM-27")
355                 return MM_27;
356         else
357                 throw invalid_argument("Intellibox::map_protocol");
358 }
359
360 void Intellibox::command(Command cmd)
361 {
362         command(cmd, 0, 0);
363 }
364
365 void Intellibox::command(Command cmd, const unsigned char *data, unsigned len)
366 {
367         command(cmd, 0, data, len);
368 }
369
370 void Intellibox::command(Command cmd, unsigned addr, const unsigned char *data, unsigned len)
371 {
372         CommandSlot slot;
373         slot.cmd = cmd;
374         slot.addr = addr;
375         slot.data[0] = cmd;
376         copy(data, data+len, slot.data+1);
377         slot.length = 1+len;
378         queue.push_back(slot);
379 }
380
381 void Intellibox::loco_command(unsigned addr, unsigned speed, bool rev, unsigned funcs, bool setf)
382 {
383         unsigned char data[4];
384         data[0] = addr&0xFF;
385         data[1] = (addr>>8)&0xFF;
386
387         if(speed==0)
388                 data[2] = 0;
389         else if(speed==1)
390                 data[2] = 2;
391         else
392                 data[2] = (speed*19-18)/2;
393         
394         data[3] = (rev ? 0 : 0x20) | ((funcs&1) ? 0x10 : 0);
395
396         if(setf)
397                 data[3] |= 0x80 | ((funcs>>1)&0xF);
398
399         command(CMD_LOK, addr, data, 4);
400 }
401
402 void Intellibox::turnout_command(unsigned addr, bool state, bool active)
403 {
404         unsigned char data[2];
405         data[0] = addr&0xFF;
406         data[1] = ((addr>>8)&0x7) | (active ? 0x40 : 0) | (state ? 0x80 : 0);
407         command(CMD_TURNOUT, addr, data, 2);
408 }
409
410 void Intellibox::process_reply(const Time::TimeStamp &t)
411 {
412         Command cmd = queue.front().cmd;
413
414         if(cmd==CMD_STATUS)
415         {
416                 unsigned char status;
417                 read_all(&status, 1);
418                 power = status&0x08;
419                 signal_power.emit(power);
420         }
421         else if(cmd==CMD_EVENT)
422         {
423                 for(unsigned i=0;; ++i)
424                 {
425                         unsigned char byte;
426                         read_all(&byte, 1);
427
428                         if(i==0)
429                         {
430                                 if(byte&0x01)
431                                         command(CMD_EVENT_LOK);
432                                 if(byte&0x20)
433                                         command(CMD_EVENT_TURNOUT);
434                                 if(byte&0x04)
435                                         command(CMD_EVENT_SENSOR);
436                         }
437                         else if(i==1)
438                         {
439                                 if(byte&0x40)
440                                         command(CMD_STATUS);
441                         }
442
443                         if(!(byte&0x80))
444                                 break;
445                 }
446         }
447         else if(cmd==CMD_EVENT_LOK)
448         {
449                 while(1)
450                 {
451                         unsigned char data[5];
452                         read_all(data, 1);
453                         if(data[0]==0x80)
454                                 break;
455                         read_all(data+1, 4);
456                 }
457         }
458         else if(cmd==CMD_EVENT_TURNOUT)
459         {
460                 unsigned char count;
461                 read_all(&count, 1);
462                 for(unsigned i=0; i<count; ++i)
463                 {
464                         unsigned char data[2];
465                         read_all(data, 2);
466
467                         unsigned addr = data[0]+((data[1]&7)<<8);
468                         unsigned mask = 1;
469                         for(; !turnouts[addr].bits; --addr, mask<<=1) ;
470                         Turnout &turnout = turnouts[addr];
471
472                         unsigned bit = !(data[1]&0x80);
473                         turnout.state = (turnout.state&~mask) | (bit*mask);
474                         turnout.pending = turnout.state;
475                         signal_turnout.emit(addr, turnout.state);
476                 }
477         }
478         else if(cmd==CMD_EVENT_SENSOR)
479         {
480                 while(1)
481                 {
482                         unsigned char mod;
483                         read_all(&mod, 1);
484                         if(!mod)
485                                 break;
486
487                         unsigned char data[2];
488                         read_all(data, 2);
489                         for(unsigned i=0; i<16; ++i)
490                         {
491                                 unsigned addr = mod*16+i-15;
492                                 bool state = (data[i/8]>>(7-i%8))&1;
493
494                                 Sensor &sensor = sensors[addr];
495                                 if(state)
496                                 {
497                                         sensor.off_timeout = Time::TimeStamp();
498                                         if(!sensor.state)
499                                         {
500                                                 sensor.state = state;
501                                                 signal_sensor(addr, state);
502                                         }
503                                 }
504                                 else if(sensor.state)
505                                         sensor.off_timeout = t+700*Time::msec;
506                         }
507                 }
508         }
509         else if(cmd==CMD_LOK)
510         {
511                 Error err;
512                 read_status(&err);
513
514                 if(err==ERR_NO_ERROR)
515                 {
516                         unsigned addr = queue.front().addr;
517                         Locomotive &loco = locos[addr];
518                         if(loco.protocol)
519                         {
520                                 signal_loco_speed.emit(addr, loco.speed+loco.pending_half_step, loco.reverse);
521                                 if(loco.pending_half_step)
522                                         loco.half_step_delay = Time::now()+500*Time::msec;
523                         }
524                 }
525                 else
526                         error(cmd, err);
527         }
528         else if(cmd==CMD_TURNOUT)
529         {
530                 Error err;
531                 read_status(&err);
532
533                 unsigned addr = queue.front().addr;
534                 unsigned mask = 1;
535                 for(; !turnouts[addr].bits; --addr, mask<<=1) ;
536                 Turnout &turnout = turnouts[addr];
537
538                 if(err==ERR_NO_ERROR)
539                 {
540                         turnout.state = (turnout.state&~mask) | (turnout.pending&mask);
541                         if(turnout.active)
542                         {
543                                 if(turnout.state==turnout.pending)
544                                         signal_turnout.emit(addr, turnout.state);
545                                 turnout.off_timeout = t+500*Time::msec;
546                         }
547                 }
548                 else if(err==ERR_NO_I2C_SPACE)
549                         queue.push_back(queue.front());
550                 else
551                 {
552                         turnout.pending = (turnout.pending&~mask) | (turnout.state&mask);
553                         error(cmd, err);
554                 }
555         }
556         else if(cmd==CMD_TURNOUT_STATUS)
557         {
558                 Error err;
559                 read_status(&err);
560
561                 if(err==ERR_NO_ERROR)
562                 {
563                         unsigned char data;
564                         read_all(&data, 1);
565
566                         unsigned addr = queue.front().addr;
567                         unsigned mask = 1;
568                         for(; !turnouts[addr].bits; --addr, mask<<=1) ;
569                         Turnout &turnout = turnouts[addr];
570
571                         bool bit = !(data&0x04);
572                         if(bit!=((turnout.state&mask)!=0))
573                         {
574                                 turnout.state = (turnout.state&~mask) | (bit*mask);
575                                 turnout.pending = turnout.state;
576                                 signal_turnout.emit(addr, turnout.state);
577                         }
578
579                         turnout.synced = true;
580                 }
581                 else
582                         error(cmd, err);
583         }
584         else if(cmd==CMD_LOK_STATUS)
585         {
586                 Error err;
587                 read_status(&err);
588
589                 if(err==ERR_NO_ERROR)
590                 {
591                         unsigned char data[3];
592                         read_all(data, 3);
593
594                         unsigned addr = queue.front().addr;
595                         Locomotive &loco = locos[addr];
596
597                         unsigned speed = (data[0]<=1 ? 0 : data[0]*2/19+1);
598                         bool reverse = !(data[1]&0x20);
599                         bool speed_changed = (speed!=loco.speed || reverse!=loco.reverse);
600
601                         loco.speed = speed;
602                         loco.reverse = reverse;
603
604                         unsigned funcs = (data[1]&0xF)<<1;
605                         if(data[1]&0x10)
606                                 funcs |= 1;
607                         unsigned funcs_changed = loco.funcs^funcs;
608                         loco.funcs = funcs;
609
610                         if(speed_changed)
611                                 signal_loco_speed.emit(addr, loco.speed, loco.reverse);
612                         for(unsigned i=0; i<5; ++i)
613                                 if(funcs_changed&(1<<i))
614                                         signal_loco_function.emit(addr, i, loco.funcs&(1<<i));
615                 }
616                 else
617                         error(cmd, err);
618         }
619         else
620         {
621                 unsigned expected_bytes = 0;
622                 if(cmd==CMD_FUNC_STATUS)
623                         expected_bytes = 1;
624                 if(cmd==CMD_TURNOUT_GROUP_STATUS)
625                         expected_bytes = 2;
626                 if(cmd==CMD_LOK_CONFIG)
627                         expected_bytes = 4;
628
629                 Error err;
630                 read_status(&err);
631
632                 if(err==ERR_NO_ERROR)
633                 {
634                         unsigned char data[8];
635                         read_all(data, expected_bytes);
636                 }
637                 else
638                         error(cmd, err);
639         }
640 }
641
642 unsigned Intellibox::read_all(unsigned char *buf, unsigned len)
643 {
644         unsigned pos = 0;
645         while(pos<len)
646                 pos += serial.read(reinterpret_cast<char *>(buf+pos), len-pos);
647
648         return pos;
649 }
650
651 unsigned Intellibox::read_status(Error *err)
652 {
653         unsigned char c;
654         unsigned ret = read_all(&c, 1);
655         *err = static_cast<Error>(c);
656         return ret;
657 }
658
659 void Intellibox::error(Command cmd, Error err)
660 {
661         const char *cmd_str = 0;
662         switch(cmd)
663         {
664         case CMD_LOK: cmd_str = "CMD_LOK"; break;
665         case CMD_LOK_STATUS: cmd_str = "CMD_LOK_STATUS"; break;
666         case CMD_LOK_CONFIG: cmd_str = "CMD_LOK_CONFIG"; break;
667         case CMD_FUNC: cmd_str = "CMD_FUNC"; break;
668         case CMD_FUNC_STATUS: cmd_str = "CMD_FUNC_STATUS"; break;
669         case CMD_TURNOUT: cmd_str = "CMD_TURNOUT"; break;
670         case CMD_TURNOUT_FREE: cmd_str = "CMD_TURNOUT_FREE"; break;
671         case CMD_TURNOUT_STATUS: cmd_str = "CMD_TURNOUT_STATUS"; break;
672         case CMD_TURNOUT_GROUP_STATUS: cmd_str = "CMD_TURNOUT_GROUP_STATUS"; break;
673         case CMD_SENSOR_STATUS: cmd_str = "CMD_SENSOR_STATUS"; break;
674         case CMD_SENSOR_REPORT: cmd_str = "CMD_SENSOR_REPORT"; break;
675         case CMD_SENSOR_PARAM_SET: cmd_str = "CMD_SENSOR_PARAM_SET"; break;
676         case CMD_STATUS: cmd_str = "CMD_STATUS"; break;
677         case CMD_POWER_OFF: cmd_str = "CMD_POWER_OFF"; break;
678         case CMD_POWER_ON: cmd_str = "CMD_POWER_ON"; break;
679         case CMD_NOP: cmd_str = "CMD_NOP"; break;
680         case CMD_EVENT: cmd_str = "CMD_EVENT"; break;
681         case CMD_EVENT_LOK: cmd_str = "CMD_EVENT_LOK"; break;
682         case CMD_EVENT_TURNOUT: cmd_str = "CMD_EVENT_TURNOUT"; break;
683         case CMD_EVENT_SENSOR: cmd_str = "CMD_EVENT_SENSOR"; break;
684         default: cmd_str = "(unknown command)";
685         }
686
687         const char *err_str = 0;
688         switch(err)
689         {
690         case ERR_NO_ERROR: err_str = "ERR_NO_ERROR"; break;
691         case ERR_SYS_ERROR: err_str = "ERR_SYS_ERROR"; break;
692         case ERR_BAD_PARAM: err_str = "ERR_BAD_PARAM"; break;
693         case ERR_POWER_OFF: err_str = "ERR_POWER_OFF"; break;
694         case ERR_NO_LOK_SPACE: err_str = "ERR_NO_LOK_SPACE"; break;
695         case ERR_NO_TURNOUT_SPACE: err_str = "ERR_NO_TURNOUT_SPACE"; break;
696         case ERR_NO_DATA: err_str = "ERR_NO_DATA"; break;
697         case ERR_NO_SLOT: err_str = "ERR_NO_SLOT"; break;
698         case ERR_BAD_LOK_ADDR: err_str = "ERR_BAD_LOK_ADDR"; break;
699         case ERR_LOK_BUSY: err_str = "ERR_LOK_BUSY"; break;
700         case ERR_BAD_TURNOUT_ADDR: err_str = "ERR_BAD_TURNOUT_ADDR"; break;
701         case ERR_BAD_SO_VALUE: err_str = "ERR_BAD_SO_VALUE"; break;
702         case ERR_NO_I2C_SPACE: err_str = "ERR_NO_I2C_SPACE"; break;
703         case ERR_LOW_TURNOUT_SPACE: err_str = "ERR_LOW_TURNOUT_SPACE"; break;
704         case ERR_LOK_HALTED: err_str = "ERR_LOK_HALTED"; break;
705         case ERR_LOK_POWER_OFF: err_str = "ERR_LOK_POWER_OFF"; break;
706         default: cmd_str = "(unknown error)";
707         }
708
709         IO::print("Error: %s: %s\n", cmd_str, err_str);
710 }
711
712
713 Intellibox::Locomotive::Locomotive():
714         ext_func(false),
715         speed(0),
716         reverse(false),
717         funcs(0)
718 { }
719
720
721 Intellibox::Turnout::Turnout():
722         bits(1),
723         state(0),
724         active(false),
725         synced(false),
726         pending(0)
727 { }
728
729
730 Intellibox::Sensor::Sensor():
731         state(false)
732 { }
733
734 } // namespace R2C2