]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/centralstation.cpp
2e605ba3500d92b7ce91cfd594d997789ee93d17
[r2c2.git] / source / libr2c2 / centralstation.cpp
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #include <algorithm>
9 #include <msp/core/refptr.h>
10 #include <msp/io/print.h>
11 #include <msp/net/resolve.h>
12 #include <msp/strings/utils.h>
13 #include <msp/time/units.h>
14 #include <msp/time/utils.h>
15 #include "centralstation.h"
16 #include "tracktype.h"
17 #include "vehicletype.h"
18
19 using namespace std;
20 using namespace Msp;
21
22 namespace R2C2 {
23
24 CentralStation::CentralStation(const string &host):
25         socket(Net::INET),
26         pending_commands(0),
27         power(false),
28         halted(false),
29         locos_synced(false),
30         turnouts_synced(false),
31         sensors_synced(false)
32 {
33         RefPtr<Net::SockAddr> addr = Net::resolve(host+":15471");
34         socket.connect(*addr);
35
36         IO::print("Connected to central station at %s\n", addr->str());
37
38         command("get(1, status)");
39         command("request(1, view)");
40         command("queryObjects(10, addr, name)");
41         command("queryObjects(11, addr)");
42         command("queryObjects(26)");
43 }
44
45 CentralStation::~CentralStation()
46 {
47         command("release(1, view)", true);
48         for(LocoMap::iterator i=locos.begin(); (i!=locos.end() && !(i->first&0x10000)); ++i)
49                 command(format("release(%d, view, control)", i->first));
50         for(TurnoutMap::iterator i=turnouts.begin(); (i!=turnouts.end() && !(i->first&0x10000)); ++i)
51                 command(format("release(%d, view, control)", i->first));
52         while(IO::poll(socket, IO::P_INPUT, 100*Time::msec))
53                 while(receive()) ;
54 }
55
56 void CentralStation::set_power(bool p)
57 {
58         power = p;
59         command(format("set(1, %s)", (power ? "go" : "stop")));
60 }
61
62 void CentralStation::halt(bool h)
63 {
64         halted = h;
65         if(halted)
66         {
67                 for(LocoMap::iterator i=locos.begin(); i!=locos.end(); ++i)
68                         if(i->second.speed)
69                                 set_loco_speed(i->first, 0);
70         }
71
72         signal_halt.emit(halted);
73 }
74
75 const char *CentralStation::enumerate_protocols(unsigned index) const
76 {
77         if(index==MM)
78                 return "MM";
79         else if(index==MM_27)
80                 return "MM-27";
81         else if(index==MFX)
82                 return "MFX";
83         else
84                 return 0;
85 }
86
87 unsigned CentralStation::get_protocol_speed_steps(const string &name) const
88 {
89         switch(map_protocol(name))
90         {
91         case MM: return 14;
92         case MM_27: return 27;
93         case MFX: return 126;
94         default: return 0;
95         }
96 }
97
98 void CentralStation::add_loco(unsigned addr, const string &proto_name, const VehicleType &type)
99 {
100         Protocol proto = map_protocol(proto_name);
101
102         unsigned id = map_address(locos, loco_addr, addr);
103         if(!id)
104         {
105                 Locomotive &loco = locos[addr|0x10000];
106                 loco.name = type.get_name();
107                 loco.protocol = proto;
108                 loco.address = addr;
109
110                 const VehicleType::FunctionMap &type_funcs = type.get_functions();
111                 for(VehicleType::FunctionMap::const_iterator i=type_funcs.begin(); i!=type_funcs.end(); ++i)
112                         loco.func_mask |= 1<<i->first;
113
114                 if(locos_synced && proto!=MFX)
115                         command("create(10)");
116         }
117         else
118                 command(format("request(%d, view, control, force)", id));
119 }
120
121 void CentralStation::set_loco_speed(unsigned addr, unsigned speed)
122 {
123         if(speed && halted)
124                 return;
125
126         unsigned id = map_address(locos, loco_addr, addr);
127         if(id)
128         {
129                 Locomotive &loco = locos[id];
130                 if(loco.protocol==MFX && speed)
131                         ++speed;
132                 command(format("set(%d, speedstep[%d])", id, speed));
133         }
134 }
135
136 void CentralStation::set_loco_reverse(unsigned addr, bool rev)
137 {
138         unsigned id = map_address(locos, loco_addr, addr);
139         if(id)
140                 command(format("set(%d, dir[%d])", id, rev));
141 }
142
143 void CentralStation::set_loco_function(unsigned addr, unsigned func, bool state)
144 {
145         unsigned id = map_address(locos, loco_addr, addr);
146         if(id)
147                 command(format("set(%d, func[%d, %d])", id, func, state));
148 }
149
150 void CentralStation::add_turnout(unsigned addr, const TrackType &type)
151 {
152         bool left = false;
153         bool right = false;
154         bool cross = false;
155
156         const vector<TrackPart> &parts = type.get_parts();
157         for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
158         {
159                 TrackPoint start = i->get_point(0);
160                 TrackPoint end = i->get_point(i->get_length());
161                 if(end.dir>start.dir+0.01)
162                         left = true;
163                 else if(end.dir<start.dir-0.01)
164                         right = true;
165                 else if(start.dir<-0.01 || start.dir>0.01)
166                         cross = true;
167         }
168
169         unsigned symbol = Turnout::LEFT;
170         if(cross)
171                 symbol = Turnout::DOUBLESLIP;
172         else if(left && right)
173                 symbol = Turnout::THREEWAY;
174         else if(left)
175                 symbol = Turnout::LEFT;
176         else if(right)
177                 symbol = Turnout::RIGHT;
178
179         unsigned id = map_address(turnouts, turnout_addr, addr);
180         if(!id)
181         {
182                 id = addr|0x10000;
183
184                 Turnout &turnout = turnouts[id];
185                 turnout.address = addr;
186                 turnout.bits = type.get_state_bits();
187                 turnout.symbol = symbol;
188
189                 turnout_addr[addr] = id;
190
191                 if(turnouts_synced)
192                         command("create(11, append)");
193         }
194         else
195         {
196                 Turnout &turnout = turnouts[id];
197                 command(format("request(%d, view, control)", id));
198                 if(turnout.symbol!=symbol)
199                         command(format("set(%d, symbol[%d])", symbol));
200         }
201 }
202
203 void CentralStation::set_turnout(unsigned addr, unsigned state)
204 {
205         unsigned id = map_address(turnouts, turnout_addr, addr);
206         if(id)
207         {
208                 Turnout &turnout = turnouts[id];
209                 unsigned mask = (1<<turnout.bits)-1;
210
211                 if(((state^turnout.state)&mask)==0 || !turnout.synced)
212                 {
213                         turnout.state = state;
214                         signal_turnout.emit(addr, turnout.state);
215                         return;
216                 }
217
218                 turnout.state = (turnout.state&mask) | (state&~mask);
219
220                 command(format("set(%d, state[%d])", id, state&mask));
221         }
222 }
223
224 unsigned CentralStation::get_turnout(unsigned addr) const
225 {
226         unsigned id = map_address(turnouts, turnout_addr, addr);
227         if(id)
228         {
229                 TurnoutMap::const_iterator i = turnouts.find(id);
230                 if(i!=turnouts.end())
231                         return i->second.state;
232         }
233         return 0;
234 }
235
236 void CentralStation::add_sensor(unsigned addr)
237 {
238         sensors.insert(SensorMap::value_type(addr, Sensor()));
239
240         if(sensors_synced)
241         {
242                 if(addr>s88.size()*16)
243                         command("create(26, add[0])");
244         }
245 }
246
247 bool CentralStation::get_sensor(unsigned addr) const
248 {
249         SensorMap::const_iterator i = sensors.find(addr);
250         if(i!=sensors.end())
251                 return i->second.state;
252         return false;
253 }
254
255 void CentralStation::tick()
256 {
257         while(Message msg = receive())
258         {
259                 if(msg.footer.code)
260                         IO::print("\033[31m*** ERROR: %s: %d %s ***\033[0m\n", msg.header.value, msg.footer.code, msg.footer.value);
261
262                 if(msg.header.type=="REPLY")
263                         process_reply(msg);
264                 else if(msg.header.type=="EVENT")
265                         process_event(msg);
266         }
267 }
268
269 void CentralStation::flush()
270 {
271 }
272
273 void CentralStation::command(const string &cmd, bool force)
274 {
275         if(pending_commands<10 || force)
276         {
277                 socket.write(cmd+"\r\n");
278                 ++pending_commands;
279         }
280         else
281                 cmd_queue.push_back(cmd);
282 }
283
284 CentralStation::Message CentralStation::receive()
285 {
286         while(IO::poll(socket, IO::P_INPUT, Time::zero))
287         {
288                 char rbuf[1024];
289                 unsigned len = socket.read(rbuf, sizeof(rbuf));
290                 if(!len)
291                         return Message();
292
293                 in_buffer.append(rbuf, len);
294         }
295
296         if(!in_buffer.empty())
297         {
298                 string::iterator iter = in_buffer.begin();
299                 if(Message msg = parse_message(iter, in_buffer.end()))
300                 {
301                         skip(iter, in_buffer.end(), "\r\n");
302                         in_buffer.erase(in_buffer.begin(), iter);
303
304                         if(msg.header.type=="REPLY" && pending_commands>0)
305                         {
306                                 --pending_commands;
307                                 if(!cmd_queue.empty())
308                                 {
309                                         command(cmd_queue.front());
310                                         cmd_queue.pop_front();
311                                 }
312                         }
313
314                         return msg;
315                 }
316         }
317
318         return Message();
319 }
320
321 void CentralStation::process_reply(const Message &msg)
322 {
323         if(!msg.header.value.compare(0, 4, "get("))
324         {
325                 for(Message::ObjectMap::const_iterator i=msg.content.begin(); i!=msg.content.end(); ++i)
326                 {
327                         if(turnouts.count(i->first))
328                                 turnouts[i->first].synced = true;
329
330                         process_object(i->first, i->second);
331                 }
332         }
333         else if(!msg.header.value.compare(0, 16, "queryObjects(10,"))
334         {
335                 for(Message::ObjectMap::const_iterator i=msg.content.begin(); i!=msg.content.end(); ++i)
336                 {
337                         LocoMap::iterator j = locos.find(i->first);
338                         if(j==locos.end())
339                         {
340                                 bool found = false;
341                                 Message::AttribMap::const_iterator k = i->second.find("addr");
342                                 if(k!=i->second.end())
343                                 {
344                                         unsigned addr = lexical_cast<unsigned>(k->second);
345
346                                         j = locos.find(addr|0x10000);
347                                         if(j!=locos.end())
348                                         {
349                                                 command(format("request(%d, view, control, force)", i->first));
350                                                 string cmd = format("get(%d, dir", i->first);
351                                                 for(unsigned l=0; j->second.func_mask>>l; ++l)
352                                                         if((j->second.func_mask>>l)&1)
353                                                                 cmd += format(", func[%d]", l);
354                                                 cmd += ')';
355                                                 command(cmd);
356
357                                                 locos.insert(LocoMap::value_type(i->first, j->second));
358                                                 locos.erase(j);
359
360                                                 found = true;
361                                         }
362                                 }
363
364                                 if(!found)
365                                         locos.insert(LocoMap::value_type(i->first, Locomotive()));
366                         }
367
368                         process_object(i->first, i->second);
369                 }
370
371                 locos_synced = true;
372
373                 if(locos.lower_bound(0x10000)!=locos.end())
374                         command("create(10)");
375         }
376         else if(!msg.header.value.compare(0, 16, "queryObjects(11,"))
377         {
378                 for(Message::ObjectMap::const_iterator i=msg.content.begin(); i!=msg.content.end(); ++i)
379                 {
380                         TurnoutMap::iterator j = turnouts.find(i->first);
381                         if(j==turnouts.end())
382                         {
383                                 bool found = false;
384                                 Message::AttribMap::const_iterator k = i->second.find("addr");
385                                 if(k!=i->second.end())
386                                 {
387                                         unsigned addr = lexical_cast<unsigned>(k->second);
388
389                                         j = turnouts.find(addr|0x10000);
390                                         if(j!=turnouts.end())
391                                         {
392                                                 command(format("request(%d, view, control)", i->first));
393                                                 command(format("set(%d, symbol[%d])", i->first, j->second.symbol));
394                                                 command(format("get(%d, state)", i->first));
395
396                                                 turnouts.insert(TurnoutMap::value_type(i->first, j->second));
397                                                 turnouts.erase(j);
398
399                                                 found = true;
400                                         }
401                                 }
402
403                                 if(!found)
404                                         turnouts.insert(TurnoutMap::value_type(i->first, Turnout()));
405                         }
406
407                         process_object(i->first, i->second);
408                 }
409
410                 turnouts_synced = true;
411
412                 for(TurnoutMap::const_iterator i=turnouts.lower_bound(0x10000); i!=turnouts.end(); ++i)
413                         command("create(11, append)");
414         }
415         else if(msg.header.value=="queryObjects(26)")
416         {
417                 s88.clear();
418                 for(Message::ObjectMap::const_iterator i=msg.content.begin(); i!=msg.content.end(); ++i)
419                 {
420                         s88.push_back(i->first);
421                         command(format("request(%d, view)", i->first));
422                         command(format("get(%d, state)", i->first));
423                 }
424
425                 sensors_synced = true;
426
427                 if(!sensors.empty())
428                 {
429                         unsigned high_addr = (--sensors.end())->first;
430                         if(high_addr>16*s88.size())
431                                 command("create(26, add[0])");
432                 }
433         }
434         else if(msg.header.value=="create(10)")
435         {
436                 Message::ObjectMap::const_iterator i = msg.content.find(10);
437                 if(i!=msg.content.end())
438                 {
439                         Message::AttribMap::const_iterator j = i->second.find("id");
440                         if(j!=i->second.end())
441                         {
442                                 unsigned id = lexical_cast<unsigned>(j->second);
443                                 LocoMap::iterator k = locos.lower_bound(0x10000);
444                                 if(k!=locos.end())
445                                 {
446                                         command(format("request(%d, view, control)", id));
447                                         command(format("set(%d, addr[%d], protocol[%s], name[\"%s\"])",
448                                                 id, k->second.address, (k->second.protocol==MM_27 ? "MM27" : "MM14"), k->second.name));
449                                         command("create(10, append)");
450
451                                         locos.insert(LocoMap::value_type(id, k->second));
452                                         locos.erase(k);
453                                 }
454                         }
455                 }
456
457                 if(locos.lower_bound(0x10000)!=locos.end())
458                         command("create(10)");
459         }
460         else if(!msg.header.value.compare(0, 10, "create(11,"))
461         {
462                 Message::ObjectMap::const_iterator i = msg.content.find(11);
463                 if(i!=msg.content.end())
464                 {
465                         Message::AttribMap::const_iterator j = i->second.find("id");
466                         if(j!=i->second.end())
467                         {
468                                 unsigned id = lexical_cast<unsigned>(j->second);
469                                 TurnoutMap::iterator k = turnouts.lower_bound(0x10000);
470                                 if(k!=turnouts.end())
471                                 {
472                                         command(format("request(%d, view, control)", id));
473                                         command(format("set(%d, addr[%d], symbol[%d], name1[\"Switch\"], name2[\"%d\"], name3[\"\"])",
474                                                 id, k->second.address, k->second.symbol, k->second.address));
475                                         command(format("set(%d, state[%d])", id, k->second.state&((1<<k->second.bits)-1)));
476
477                                         k->second.synced = true;
478                                         turnouts.insert(TurnoutMap::value_type(id, k->second));
479                                         turnouts.erase(k);
480                                 }
481                         }
482                 }
483         }
484         else if(!msg.header.value.compare(0, 10, "create(26,"))
485                 command("queryObjects(26)");
486 }
487
488 void CentralStation::process_event(const Message &msg)
489 {
490         for(Message::ObjectMap::const_iterator i=msg.content.begin(); i!=msg.content.end(); ++i)
491                 process_object(i->first, i->second);
492 }
493
494 void CentralStation::process_object(unsigned id, const Message::AttribMap &attribs)
495 {
496         if(id==1)
497         {
498                 for(Message::AttribMap::const_iterator i=attribs.begin(); i!=attribs.end(); ++i)
499                         if(i->first=="status")
500                         {
501                                 power = (i->second=="GO");
502                                 signal_power.emit(power);
503                         }
504         }
505         else if(locos.count(id))
506         {
507                 Locomotive &loco = locos[id];
508                 bool speed_changed = false;
509                 unsigned funcs_changed = 0;
510                 for(Message::AttribMap::const_iterator i=attribs.begin(); i!=attribs.end(); ++i)
511                 {
512                         if(i->first=="name")
513                                 loco.name = i->second.substr(1, i->second.size()-2);
514                         else if(i->first=="addr")
515                         {
516                                 loco_addr.erase(loco.address);
517                                 loco.address = lexical_cast<unsigned>(i->second);
518                                 loco_addr[loco.address] = id;
519                         }
520                         else if(i->first=="protocol")
521                         {
522                                 if(i->second=="MM")
523                                         loco.protocol = MM;
524                                 else if(i->second=="MM27")
525                                         loco.protocol = MM_27;
526                                 else if(i->second=="MFX")
527                                         loco.protocol = MFX;
528                         }
529                         else if(i->first=="speedstep")
530                         {
531                                 loco.speed = lexical_cast<unsigned>(i->second);
532                                 if(loco.protocol==MFX && loco.speed)
533                                         --loco.speed;
534                                 speed_changed = true;
535                         }
536                         else if(i->first=="dir")
537                         {
538                                 loco.reverse = i->second[0]!='0';
539                                 speed_changed = true;
540                         }
541                         else if(i->first=="func")
542                         {
543                                 vector<string> parts = split(i->second, ", ");
544                                 unsigned func = lexical_cast<unsigned>(parts[0]);
545                                 bool value = lexical_cast<unsigned>(parts[1]);
546                                 loco.funcs &= ~(1<<func);
547                                 if(value)
548                                         loco.funcs |= 1<<func;
549                                 funcs_changed |= 1<<func;
550                         }
551                         else if(i->first=="msg")
552                         {
553                                 if(i->second=="CONTROL_LOST")
554                                         command(format("request(%d, control, force)", id));
555                         }
556                 }
557
558                 if(speed_changed)
559                         signal_loco_speed.emit(loco.address, loco.speed, loco.reverse);
560                 for(unsigned i=0; funcs_changed>>i; ++i)
561                         if(funcs_changed&(1<<i))
562                                 signal_loco_function.emit(loco.address, i, loco.funcs&(1<<i));
563         }
564         else if(turnouts.count(id))
565         {
566                 Turnout &turnout = turnouts[id];
567                 bool state_changed = false;
568                 for(Message::AttribMap::const_iterator i=attribs.begin(); i!=attribs.end(); ++i)
569                 {
570                         if(i->first=="addr")
571                         {
572                                 turnout_addr.erase(turnout.address);
573                                 turnout.address = lexical_cast<unsigned>(i->second);
574                                 turnout_addr[turnout.address] = id;
575                         }
576                         else if(i->first=="state")
577                         {
578                                 unsigned state = lexical_cast<unsigned>(i->second);
579                                 unsigned mask = (1<<turnout.bits)-1;
580                                 turnout.state = (turnout.state&~mask) | (state&mask);
581                                 state_changed = true;
582                         }
583                 }
584
585                 if(state_changed)
586                         signal_turnout.emit(turnout.address, turnout.state);
587         }
588         else if(find(s88.begin(), s88.end(), id)!=s88.end())
589         {
590                 unsigned base = 0;
591                 for(; (base<s88.size() && s88[base]!=id); ++base) ;
592
593                 for(Message::AttribMap::const_iterator i=attribs.begin(); i!=attribs.end(); ++i)
594                 {
595                         if(i->first=="state")
596                         {
597                                 unsigned state = lexical_cast<unsigned>(i->second, "%i");
598                                 for(unsigned j=0; j<16; ++j)
599                                 {
600                                         unsigned addr = base*16+j+1;
601                                         Sensor &sensor = sensors[addr];
602                                         bool s = state&(1<<j);
603                                         if(s!=sensor.state)
604                                         {
605                                                 sensor.state = s;
606                                                 signal_sensor.emit(addr, sensor.state);
607                                         }
608                                 }
609                         }
610                 }
611         }
612 }
613
614 CentralStation::Protocol CentralStation::map_protocol(const string &name) const
615 {
616         if(name=="MM")
617                 return MM;
618         else if(name=="MM-27")
619                 return MM_27;
620         else if(name=="MFX")
621                 return MFX;
622         else
623                 throw InvalidParameterValue("Unknown protocol");
624 }
625
626 template<typename T>
627 unsigned CentralStation::map_address(const map<unsigned, T> &omap, const AddressMap &amap, unsigned addr) const
628 {
629         if(omap.count(addr))
630                 return addr;
631         else
632         {
633                 AddressMap::const_iterator i = amap.find(addr);
634                 if(i!=amap.end())
635                         return i->second;
636                 else
637                         return 0;
638         }
639 }
640
641 void CentralStation::skip(string::iterator &iter, const string::iterator &end, const string &what) const
642 {
643         for(; (iter!=end && what.find(*iter)!=string::npos); ++iter) ;
644 }
645
646 string CentralStation::parse_token(string::iterator &iter, const string::iterator &end, const string &stop) const
647 {
648         vector<char> parens;
649         bool quote = false;
650         string token;
651
652         skip(iter, end, stop);
653
654         for(; iter!=end; ++iter)
655         {
656                 if(stop.find(*iter)!=string::npos && parens.empty() && !quote)
657                         break;
658                 else if(*iter=='(' || *iter=='[')
659                         parens.push_back(*iter);
660                 else if((*iter==')' || *iter==']') && !parens.empty())
661                 {
662                         if((*iter==')' && parens.back()!='(') || (*iter==']' && parens.back()!='['))
663                                 IO::print("Mismatched parentheses\n");
664                         parens.pop_back();
665                 }
666                 else if(*iter=='"')
667                         quote = !quote;
668
669                 token += *iter;
670         }
671
672         return token;
673 }
674
675 CentralStation::Tag CentralStation::parse_tag(string::iterator &iter, const string::iterator &end) const
676 {
677         Tag tag;
678
679         for(; (iter!=end && *iter!='<'); ++iter) ;
680         if(iter==end)
681                 return Tag();
682
683         tag.type = parse_token(++iter, end, " >");
684         if(tag.type=="END")
685         {
686                 string code = parse_token(iter, end, " >");
687                 tag.code = lexical_cast<unsigned>(code);
688         }
689         skip(iter, end, " ");
690         tag.value = parse_token(iter, end, ">");
691         if(iter==end)
692                 return Tag();
693         ++iter;
694
695         return tag;
696 }
697
698 CentralStation::Message CentralStation::parse_message(string::iterator &iter, const string::iterator &end) const
699 {
700         Message msg;
701
702         msg.header = parse_tag(iter, end);
703
704         while(iter!=end)
705         {
706                 skip(iter, end, "\r\n");
707                 if(*iter=='<')
708                         break;
709
710                 string id = parse_token(iter, end, " \r\n<");
711                 Message::AttribMap &attribs = msg.content[lexical_cast<unsigned>(id)];
712                 while(iter!=end && *iter!='\n' && *iter!='\r')
713                 {
714                         string attr = parse_token(iter, end, " \r\n<");
715                         string::size_type open_bracket = attr.find('[');
716                         if(open_bracket!=string::npos)
717                         {
718                                 string::size_type close_bracket = attr.rfind(']');
719                                 string attr_name = attr.substr(0, open_bracket);
720                                 string attr_value = attr.substr(open_bracket+1, close_bracket-open_bracket-1);
721                                 attribs.insert(Message::AttribMap::value_type(attr_name, attr_value));
722                         }
723                         else
724                                 attribs.insert(Message::AttribMap::value_type(attr, string()));
725                 }
726         }
727
728         msg.footer = parse_tag(iter, end);
729         if(msg.footer.type.empty())
730                 return Message();
731
732         return msg;
733 }
734
735
736 CentralStation::Tag::Tag():
737         code(0)
738 { }
739
740 CentralStation::Tag::operator bool() const
741 {
742         return !type.empty();
743 }
744
745
746 CentralStation::Message::operator bool() const
747 {
748         return header && footer;
749 }
750
751
752 CentralStation::Locomotive::Locomotive():
753         address(0),
754         speed(0),
755         reverse(false),
756         func_mask(0),
757         funcs(0),
758         control(false)
759 { }
760
761
762 CentralStation::Turnout::Turnout():
763         address(0),
764         symbol(0),
765         state(0),
766         bits(0),
767         synced(false)
768 { }
769
770
771 CentralStation::Sensor::Sensor():
772         state(false)
773 { }
774
775 } // namespace R2C2