@@ -169,7 +169,7 @@ void COpenWebNet::MonitorFrames()
169
169
170
170
for (vector<bt_openwebnet>::iterator iter = responses.begin (); iter != responses.end (); iter++) {
171
171
if (iter->IsNormalFrame ()) {
172
- AddDeviceIfNotExits (iter->Extract_chi (), iter->Extract_dove ());
172
+ AddDeviceIfNotExits (iter->Extract_who (), iter->Extract_where ());
173
173
}
174
174
_log.Log (LOG_STATUS, " COpenWebNet : received=%s" , frameToString (*iter).c_str ());
175
175
}
@@ -182,33 +182,33 @@ void COpenWebNet::MonitorFrames()
182
182
183
183
bool COpenWebNet:: WriteToHardware(const char *pdata, const unsigned char length)
184
184
{
185
- tRBUF *pCmd = (tRBUF*)pdata;
185
+ _tGeneralSwitch *pCmd = (_tGeneralSwitch*)pdata;
186
+
187
+ unsigned char packetlength = pCmd->len ;
188
+ unsigned char packettype = pCmd->type ;
189
+ unsigned char subtype = pCmd->subtype ;
186
190
187
- unsigned char packetlength = pCmd->ICMND .packetlength ;
188
- unsigned char packettype = pCmd->ICMND .packettype ;
189
- unsigned char subtype = pCmd->ICMND .subtype ;
190
- unsigned char seqnbr = pCmd->ICMND .seqnbr ;
191
191
192
192
int who;
193
193
int what;
194
194
int where;
195
195
196
- if (packettype == pTypeBlinds && subtype == sTypeBlindsT12 ){
196
+ if (packettype == pTypeGeneralSwitch && subtype == sSwitchBlindsT1 ){
197
197
// Blinds/Window command
198
- int blindId = pCmd->BLINDS1 . id1 ;
198
+ int blindId = pCmd->unitcode ;
199
199
200
200
who = WHO_AUTOMATION;
201
201
where = blindId;
202
202
203
- if (pCmd->BLINDS1 . cmnd == blinds_sOpen )
203
+ if (pCmd->cmnd == gswitch_sOff )
204
204
{
205
205
what = AUTOMATION_WHAT_UP;
206
206
}
207
- else if (pCmd->BLINDS1 . cmnd == blinds_sClose )
207
+ else if (pCmd->cmnd == gswitch_sOn )
208
208
{
209
209
what = AUTOMATION_WHAT_DOWN;
210
210
}
211
- else if (pCmd->BLINDS1 . cmnd == blinds_sStop )
211
+ else if (pCmd->cmnd == gswitch_sStop )
212
212
{
213
213
what = AUTOMATION_WHAT_STOP;
214
214
}
@@ -351,8 +351,8 @@ bool COpenWebNet::AddDeviceIfNotExits(string who, string where)
351
351
352
352
switch (atoi (who.c_str ())) {
353
353
case WHO_AUTOMATION:
354
- devType = pTypeBlinds ;
355
- subType = sTypeBlindsT12 ;
354
+ devType = pTypeGeneralSwitch ;
355
+ subType = sSwitchBlindsT1 ;
356
356
switchType = STYPE_Blinds;
357
357
devname = OPENWEBNET_AUTOMATION;
358
358
devname += " " + where;
@@ -397,8 +397,8 @@ bool COpenWebNet::FindDevice(int who, int where, int* used)
397
397
398
398
switch (who) {
399
399
case WHO_AUTOMATION :
400
- devType = pTypeBlinds ;
401
- subType = sTypeBlindsT12 ;
400
+ devType = pTypeGeneralSwitch ;
401
+ subType = sSwitchBlindsT1 ;
402
402
break ;
403
403
default :
404
404
return " " ;
@@ -464,46 +464,46 @@ string COpenWebNet::frameToString(bt_openwebnet& frame)
464
464
{
465
465
frameStr << " NORMAL FRAME" ;
466
466
467
- if (frame.estesa ) {
467
+ if (frame.extended ) {
468
468
frameStr << " - EXTENDED" ;
469
469
}
470
470
471
- frameStr << " - who=" << frame.Extract_chi ( );
472
- frameStr << " - what=" << frame.Extract_cosa ( );
473
- frameStr << " - where=" << frame.Extract_dove ();
474
- if (!frame.Extract_quando ().empty ()) {
475
- frameStr << " - when=" << frame.Extract_quando ();
471
+ frameStr << " - who=" << getWhoDescription ( frame.Extract_who () );
472
+ frameStr << " - what=" << getWhatDescription ( frame.Extract_who (), frame. Extract_what () );
473
+ frameStr << " - where=" << frame.Extract_where ();
474
+ if (!frame.Extract_when ().empty ()) {
475
+ frameStr << " - when=" << frame.Extract_when ();
476
476
}
477
- if (!frame.Extract_livello ().empty ()) {
478
- frameStr << " - level=" << frame.Extract_livello ();
477
+ if (!frame.Extract_level ().empty ()) {
478
+ frameStr << " - level=" << frame.Extract_level ();
479
479
}
480
- if (!frame.Extract_interfaccia ().empty ()) {
481
- frameStr << " - interface=" << frame.Extract_interfaccia ();
480
+ if (!frame.Extract_interface ().empty ()) {
481
+ frameStr << " - interface=" << frame.Extract_interface ();
482
482
}
483
- if (!frame.Extract_grandezza ().empty ()) {
484
- frameStr << " - dimension=" << frame.Extract_grandezza ();
483
+ if (!frame.Extract_dimension ().empty ()) {
484
+ frameStr << " - dimension=" << frame.Extract_dimension ();
485
485
}
486
486
487
- string indirizzo = frame.Extract_indirizzo (0 );
487
+ string indirizzo = frame.Extract_address (0 );
488
488
if (!indirizzo.empty ()) {
489
489
int i = 1 ;
490
490
frameStr << " - address=" ;
491
491
while (!indirizzo.empty ()) {
492
492
frameStr << indirizzo;
493
- indirizzo = frame.Extract_indirizzo (i++);
493
+ indirizzo = frame.Extract_address (i++);
494
494
if (!indirizzo.empty ()) {
495
495
frameStr << " , " ;
496
496
}
497
497
}
498
498
}
499
499
500
- string valori = frame.Extract_valori (0 );
500
+ string valori = frame.Extract_value (0 );
501
501
if (!valori.empty ()) {
502
502
int i = 1 ;
503
503
frameStr << " - value=" ;
504
504
while (!valori.empty ()) {
505
505
frameStr << valori;
506
- indirizzo = frame.Extract_valori (i++);
506
+ indirizzo = frame.Extract_value (i++);
507
507
if (!valori.empty ()) {
508
508
frameStr << " , " ;
509
509
}
@@ -512,4 +512,151 @@ string COpenWebNet::frameToString(bt_openwebnet& frame)
512
512
}
513
513
514
514
return frameStr.str ();
515
+ }
516
+
517
+ string COpenWebNet::getWhoDescription (string who)
518
+ {
519
+ if (who == " 0" ) {
520
+ return " Scenario" ;
521
+ }
522
+ if (who == " 1" ) {
523
+ return " Lighting" ;
524
+ }
525
+ if (who == " 2" ) {
526
+ return " Automation" ;
527
+ }
528
+ if (who == " 3" ) {
529
+ return " Load control" ;
530
+ }
531
+ if (who == " 4" ) {
532
+ return " Temperature control" ;
533
+ }
534
+ if (who == " 5" ) {
535
+ return " Burglar alarm" ;
536
+ }
537
+ if (who == " 6" ) {
538
+ return " Door entry system" ;
539
+ }
540
+ if (who == " 7" ) {
541
+ return " Multimedia" ;
542
+ }
543
+ if (who == " 9" ) {
544
+ return " Auxiliary" ;
545
+ }
546
+ if (who == " 13" ) {
547
+ return " Gateway interfaces management" ;
548
+ }
549
+ if (who == " 14" ) {
550
+ return " Light shutter actuator lock" ;
551
+ }
552
+ if (who == " 15" ) {
553
+ return " Scenario Scheduler Switch" ;
554
+ }
555
+ if (who == " 16" ) {
556
+ return " Audio" ;
557
+ }
558
+ if (who == " 17" ) {
559
+ return " Scenario programming" ;
560
+ }
561
+ if (who == " 18" ) {
562
+ return " Energy management" ;
563
+ }
564
+ if (who == " 24" ) {
565
+ return " Lighting management" ;
566
+ }
567
+ if (who == " 25" ) {
568
+ return " Scenario scheduler buttons" ;
569
+ }
570
+ if (who == " 1000" ) {
571
+ return " Diagnostic" ;
572
+ }
573
+ if (who == " 1001" ) {
574
+ return " Automation diagnostic" ;
575
+ }
576
+ if (who == " 1004" ) {
577
+ return " Thermoregulation diagnostic failure" ;
578
+ }
579
+ if (who == " 1013" ) {
580
+ return " Device diagnostic" ;
581
+ }
582
+
583
+ return who;
584
+ }
585
+
586
+ string COpenWebNet::getWhatDescription (string who, string what)
587
+ {
588
+ if (who == " 0" ) {
589
+ // "Scenario";
590
+ }
591
+ if (who == " 1" ) {
592
+ // "Lighting";
593
+ }
594
+ if (who == " 2" ) {
595
+ // "Automation";
596
+ if (what == " 0" ) {
597
+ return " Stop" ;
598
+ }
599
+ if (what == " 1" ) {
600
+ return " Up" ;
601
+ }
602
+ if (what == " 2" ) {
603
+ return " Down" ;
604
+ }
605
+ }
606
+ if (who == " 3" ) {
607
+ // "Load control";
608
+ }
609
+ if (who == " 4" ) {
610
+ // "Temperature control";
611
+ }
612
+ if (who == " 5" ) {
613
+ // "Burglar alarm";
614
+ }
615
+ if (who == " 6" ) {
616
+ // "Door entry system";
617
+ }
618
+ if (who == " 7" ) {
619
+ // "Multimedia";
620
+ }
621
+ if (who == " 9" ) {
622
+ // "Auxiliary";
623
+ }
624
+ if (who == " 13" ) {
625
+ // "Gateway interfaces management";
626
+ }
627
+ if (who == " 14" ) {
628
+ // "Light shutter actuator lock";
629
+ }
630
+ if (who == " 15" ) {
631
+ // "Scenario Scheduler Switch";
632
+ }
633
+ if (who == " 16" ) {
634
+ // "Audio";
635
+ }
636
+ if (who == " 17" ) {
637
+ // "Scenario programming";
638
+ }
639
+ if (who == " 18" ) {
640
+ // "Energy management";
641
+ }
642
+ if (who == " 24" ) {
643
+ // "Lighting management";
644
+ }
645
+ if (who == " 25" ) {
646
+ // "Scenario scheduler buttons";
647
+ }
648
+ if (who == " 1000" ) {
649
+ // "Diagnostic";
650
+ }
651
+ if (who == " 1001" ) {
652
+ // "Automation diagnostic";
653
+ }
654
+ if (who == " 1004" ) {
655
+ // "Thermoregulation diagnostic failure";
656
+ }
657
+ if (who == " 1013" ) {
658
+ // "Device diagnostic";
659
+ }
660
+
661
+ return what;
515
662
}
0 commit comments