mrDarker
6 天以前 829fe6c6bc33d53fda9c31fd45a37e1df87befff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
#include "stdafx.h"
#include "CBonder.h"
 
 
namespace SERVO {
    CBonder::CBonder() : CEquipment()
    {
        m_nIndex = 0;
    }
 
    CBonder::~CBonder()
    {
 
    }
 
    const char* CBonder::getClassName()
    {
        static char* pszName = "CBonder";
        return pszName;
    }
 
    void CBonder::init()
    {
        CEquipment::init();
    }
 
    void CBonder::term()
    {
        CEquipment::term();
    }
 
    // 必须要实现的虚函数,在此初始化Pin列表
    void CBonder::initPins()
    {
        // 加入Pin初始化代码
        LOGI("<CBonder>initPins");
        addPin(SERVO::PinType::INPUT, _T("In1"));
        addPin(SERVO::PinType::INPUT, _T("In2"));
        addPin(SERVO::PinType::OUTPUT, _T("Out"));
    }
 
    void CBonder::initSteps()
    {
        CEquipment::initSteps();
 
 
        {
            // eq mode
            CEqModeStep* pStep = new CEqModeStep();
            pStep->setName(STEP_MODE);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x340 : 0x640);
            pStep->setModeDev(m_nIndex == 0 ? 0x9d7d : 0xdd7d);
            if (addStep(STEP_ID_EQMODE_CHANGED, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // eq status
            CEqStatusStep* pStep = new CEqStatusStep();
            pStep->setName(STEP_STATUS);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x341 : 0x641);
            pStep->setStatusDev(m_nIndex == 0 ? 0x9d59 : 0xdd59);
            if (addStep(STEP_ID_EQSTATUS_CHANGED, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // Eq Alarm
            static char* pszName[] = { STEP_ALARM_BLOCK1, STEP_ALARM_BLOCK2, STEP_ALARM_BLOCK3, STEP_ALARM_BLOCK4, STEP_ALARM_BLOCK5 };
            static int dev[2][5] = { { 0x9f0e , 0x9f3b, 0x9f68, 0x9f95, 0x9fc2 },
                { 0xdf0e , 0xdf3b, 0xdf68, 0xdf95, 0xdfc2 } };
            static int writeSignalDev[2][5] = { { 0x342, 0x343, 0x344, 0x345, 0x346 },
                { 0x642, 0x643, 0x644, 0x645, 0x646 } };
            static int addr[] = { STEP_ID_EQALARM1, STEP_ID_EQALARM2, STEP_ID_EQALARM3, STEP_ID_EQALARM4, STEP_ID_EQALARM5 };
 
            for (int i = 0; i < 5; i++) {
                CEqAlarmStep* pStep = new CEqAlarmStep();
                pStep->setName(pszName[i]);
                pStep->setWriteSignalDev(writeSignalDev[m_nIndex][i]);
                pStep->setAlarmDev(dev[m_nIndex][i]);
                if (addStep(addr[i], pStep) != 0) {
                    delete pStep;
                }
            }
 
        }
 
        {
            CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0xab55 : 0xeb55), 538 * 2,
                [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                    if (code == ROK && pszData != nullptr && size > 0) {
                        decodeProcessDataReport((CStep*)pFrom, pszData, size);
                    }
                    return -1;
                });
            pStep->setName(STEP_PROCESS);
            pStep->setWriteSignalDev((m_nIndex == 0 ? 0x347 : 0x647));
            if (addStep(STEP_ID_PROCESS_DATA_REPORT, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // eq cim mode change
            CEqCimModeChangeStep* pStep = new CEqCimModeChangeStep();
            pStep->setName(STEP_CIM_MODE_CHANGE);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x360 : 0x660);
            pStep->setCimModeDev(m_nIndex == 0 ? 0x965 : 0x12b5);
            if (addStep(STEP_ID_CIMMODE_CHANGED_CMD_REPLY, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // eq cim message cmd
            CEqCimMessageCmdStep* pStep = new CEqCimMessageCmdStep();
            pStep->setName(STEP_CIM_MESSAGE_CMD);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x361 : 0x661);
            pStep->setCimMessageDev(m_nIndex == 0 ? 0x950 : 0x12a0);
            if (addStep(STEP_ID_CIM_MSG_SET_CMD_REPLY, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // eq current recipe change
            CEqCurrentRecipeChangeStep* pStep = new CEqCurrentRecipeChangeStep();
            pStep->setName(STEP_EQ_RURRENT_RECIPE_CHANGE);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x348 : 0x648);
            pStep->setDataDev(m_nIndex == 0 ? 0xa850 : 0xe850);
            if (addStep(STEP_ID_CURRENT_RECIPE_CHANGE_REPORT, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // CIM Message Confirm
            // 要将int32的值拆分为两个short, 分别为msg id和panel id
            // 65538, 2为msg id, 1为panel id
            CEqReadIntStep* pStep = new CEqReadIntStep(__INT32, m_nIndex == 0 ? 0x9d80 : 0xdd80);
            pStep->setName(STEP_EQ_CIM_MESSAGE_CONFIRM);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x349 : 0x649);
            if (addStep(STEP_ID_CIM_MSG_CONFIRM_REPORT, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            CEqCimMessageClearStep* pStep = new CEqCimMessageClearStep();
            pStep->setName(STEP_CIM_MESSAGE_CLEAR);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x362 : 0x662);
            pStep->setClearCimMessageDev(m_nIndex == 0 ? 0x963 : 0x12b3);
            if (addStep(STEP_ID_CIM_MSG_CLEAR_CMD_REPLY, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            CEqDateTimeSetCmdStep* pStep = new CEqDateTimeSetCmdStep();
            pStep->setName(STEP_DATETIME_SET_CMD);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x363 : 0x663);
            pStep->setDateTimeDev(m_nIndex == 0 ? 0x966 : 0x12b6);
            if (addStep(STEP_ID_DATETIME_SET_CMD_REPLY, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            CEqModeChangeStep* pStep = new CEqModeChangeStep();
            pStep->setName(STEP_EQ_MODE_CHANGE);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x365 : 0x665);
            pStep->setEqModeDev(m_nIndex == 0 ? 0x96E : 0x12be);
            if (addStep(STEP_ID_EQMODE_CHANGE_CMD_REPLY, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // 请求主配方列表的step
            CEqWriteStep* pStep = new CEqWriteStep();
            pStep->setName(STEP_EQ_MASTER_RECIPE_LIST_REQ);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x366 : 0x666);
            pStep->setDataDev(m_nIndex == 0 ? 0x125a : 0x1baa);
            if (addStep(STEP_ID_MASTER_RECIPE_LIST_CMD_REPLY, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // master recipe list report
            CEqReadStep* pStep = new CEqReadStep(m_nIndex == 0 ? 0xa955 : 0xe955, 255 * 2,
                [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                    CEqReadStep* pTmpStep = (CEqReadStep*)pFrom;
                    short ret = MRLRC_OK;
                    if (code == ROK && pszData != nullptr && size > 0) {
                        // 此处解释配方数据
                        ret = decodeRecipeListReport(pszData, size);
                    }
                    pTmpStep->setReturnCode(ret);
                    return -1;
                });
            pStep->setName(STEP_EQ_MASTER_RECIPE_LIST);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x34b : 0x64b);
            pStep->setReturnDev(m_nIndex == 0 ? 0x126d : 0x1bbd);
            if (addStep(STEP_ID_MASTER_RECIPE_LIST_REPORT, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // 请求配方参数
            CEqWriteStep* pStep = new CEqWriteStep();
            pStep->setName(STEP_EQ_RECIPE_PARAMETER_REQ);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x367 : 0x667);
            pStep->setDataDev(m_nIndex == 0 ? 0x125b : 0x1bab);
            if (addStep(STEP_ID_RECIPE_PARAMETER_CMD_REPLY, pStep) != 0) {
                delete pStep;
            }
        }
 
        {
            // recipe parameter report
            CEqReadStep* pStep = new CEqReadStep(m_nIndex == 0 ? 0xaa54 : 0xea54, 257 * 2,
                [&, pStep](void* pFrom, int code, const char* pszData, size_t size) -> int {
                    CEqReadStep* pTmpStep = (CEqReadStep*)pFrom;
                    short ret = MRLRC_OK;
                    if (code == ROK && pszData != nullptr && size > 0) {
                        // 此处解释配方数据
                        ret = decodeRecipeParameterReport(pszData, size);
                    }
                    pTmpStep->setReturnCode(ret);
                    return -1;
                });
            pStep->setName(STEP_EQ_RECIPE_PARAMETER);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x34c : 0x64c);
            pStep->setReturnDev(m_nIndex == 0 ? 0x126c : 0x1bbc);
            if (addStep(STEP_ID_RECIPE_PARAMETER_REPORT, pStep) != 0) {
                delete pStep;
            }
        }
 
        // 使用CEqReadStep替换CEqJobEventStep
        {
            // Received Job Report Upstream #1~9
            char szBuffer[256];
            for (int i = 0; i < 2; i++) {
                CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0x8c90 : 0xcc90) + 320 * i, 320 * 2,
                    [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                        if (code == ROK && pszData != nullptr && size > 0) {
                            int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port");
                            if (port > 0) {
                                decodeReceivedJobReport((CStep*)pFrom, port, pszData, size);
                            }
                        }
                        return -1;
                    });
                sprintf_s(szBuffer, "%s%d", STEP_EQ_RECEIVED_JOB_UPSn, i + 1);
                pStep->setName(szBuffer);
                pStep->setProp("Port", (void*)(__int64)(i + 1));
                pStep->setWriteSignalDev((m_nIndex == 0 ? 0x300 : 0x600) + i);
                if (addStep(STEP_ID_RECIVE_JOB_UPS1 + i, pStep) != 0) {
                    delete pStep;
                }
            }
        }
 
        {
            // Sent Out Job Report Downstream #1~9
            char szBuffer[256];
            for (int i = 0; i < 2; i++) {
                CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0x8000 : 0xc000) + 320 * i, 320 * 2,
                    [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                        if (code == ROK && pszData != nullptr && size > 0) {
                            int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port");
                            if (port > 0) {
                                decodeSentOutJobReport((CStep*)pFrom, port, pszData, size);
                            }
                        }
                        return -1;
                    });
                sprintf_s(szBuffer, "%s%d", STEP_EQ_SENT_OUT_JOB_DOWNSn, i + 1);
                pStep->setName(szBuffer);
                pStep->setProp("Port", (void*)(__int64)(i + 1));
                pStep->setWriteSignalDev((m_nIndex == 0 ? 0x30a : 0x60a) + i);
                if (addStep(STEP_ID_SENT_OUT_JOB_DOWNS1 + i, pStep) != 0) {
                    delete pStep;
                }
            }
        }
 
        {
            // Fetched Out Job Report #1~15
            char szBuffer[256];
            for (int i = 0; i < 2; i++) {
                CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0x9c31 : 0xdc31) + 18 * i, 18 * 2,
                    [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                        if (code == ROK && pszData != nullptr && size > 0) {
                            int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port");
                            if (port > 0) {
                                decodeFetchedOutJobReport((CStep*)pFrom, port, pszData, size);
                            }
                        }
                        return -1;
                    });
                sprintf_s(szBuffer, "%s%d", STEP_EQ_FETCHED_OUT_JOBn, i + 1);
                pStep->setName(szBuffer);
                pStep->setProp("Port", (void*)(__int64)(i + 1));
                pStep->setWriteSignalDev((m_nIndex == 0 ? 0x323 : 0x623) + i);
                if (addStep(STEP_ID_FETCHED_OUT_JOB_REPORT1 + i, pStep) != 0) {
                    delete pStep;
                }
            }
        }
 
        {
            // Stored Job Report #1~15
            char szBuffer[256];
            for (int i = 0; i < 2; i++) {
                CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0x9b23 : 0xdb23) + 18 * i, 18 * 2,
                    [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                        if (code == ROK && pszData != nullptr && size > 0) {
                            int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port");
                            if (port > 0) {
                                decodeStoredJobReport((CStep*)pFrom, port, pszData, size);
                            }
                        }
                        return -1;
                    });
                sprintf_s(szBuffer, "%s%d", STEP_EQ_STORED_JOBn, i + 1);
                pStep->setName(szBuffer);
                pStep->setProp("Port", (void*)(__int64)(i + 1));
                pStep->setWriteSignalDev((m_nIndex == 0 ? 0x314 : 0x614) + i);
                if (addStep(STEP_ID_STORE_JOB_REPORT1 + i, pStep) != 0) {
                    delete pStep;
                }
            }
        }
 
        {
            // Indexer Operation Mode Change
            CEqWriteStep* pStep = new CEqWriteStep();
            pStep->setName(STEP_EQ_IN_OP_MODE_CHANGE);
            pStep->setWriteSignalDev(0x370);
            pStep->setDataDev(0x923);
            pStep->setRetDataDev(0xa00e, 2);
            if (addStep(STEP_ID_IN_OP_CMD_REPLY, pStep) != 0) {
                delete pStep;
            }
        }
 
        // FAC Data Report
        addFacDataReportStep(m_nIndex == 0 ? 0xA589 : 0xE589,
            m_nIndex == 0 ? 0x34d : 0x64d, 1);
        /*
        {
            CEqReadStep* pStep = new CEqReadStep(m_nIndex == 0 ? 0xA589 : 0xE589, 133 * 2,
                [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                    if (code == ROK && pszData != nullptr && size > 0) {
                        decodeFacDataReport((CStep*)pFrom, pszData, size);
                    }
                    return -1;
                });
            pStep->setName(STEP_EQ_FAC_DATA_REPORT);
            pStep->setProp("Port", (void*)1);
            pStep->setWriteSignalDev(0x34d);
            if (addStep(STEP_ID_FAC_DATA_REPORT, pStep) != 0) {
                delete pStep;
            }
        }
        */
 
        // process start/end report
        {
            CEqReadStep* pStep = new CEqReadStep(m_nIndex == 0 ? 0x9D3F : 0xDD3F, 13 * 2,
                [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                    if (code == ROK && pszData != nullptr && size > 0) {
                        decodeJobProcessStartReport((CStep*)pFrom, pszData, size);
                    }
                    return -1;
                });
            pStep->setName(STEP_EQ_JOB_PROCESS_START_REPORT);
            pStep->setProp("Port", (void*)1);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x333 : 0x633);
            if (addStep(STEP_ID_JOB_PROCESS_START_REPORT, pStep) != 0) {
                delete pStep;
            }
        }
        {
            CEqReadStep* pStep = new CEqReadStep(m_nIndex == 0 ? 0x9D4C : 0xDD4C, 13 * 2,
                [&](void* pFrom, int code, const char* pszData, size_t size) -> int {
                    if (code == ROK && pszData != nullptr && size > 0) {
                        decodeJobProcessEndReport((CStep*)pFrom, pszData, size);
                    }
                    return -1;
                });
            pStep->setName(STEP_EQ_JOB_PROCESS_END_REPORT);
            pStep->setProp("Port", (void*)1);
            pStep->setWriteSignalDev(m_nIndex == 0 ? 0x334 : 0x634);
            if (addStep(STEP_ID_JOB_PROCESS_END_REPORT, pStep) != 0) {
                delete pStep;
            }
        }
    }
 
    // 必须要实现的虚函数,在此初始化Slot信息
    void CBonder::initSlots()
    {
        m_slot[0].enable();
        m_slot[0].setPosition(m_nID);
        m_slot[0].setNo(1);
        m_slot[0].setName("Slot 1(G2)");
        m_slot[0].setLinkSignalPath(0);
        m_slot[0].setType(MaterialsType::G2);
        m_slot[1].enable();
        m_slot[1].setPosition(m_nID);
        m_slot[1].setNo(2);
        m_slot[1].setName("Slot 2(G1)");
        m_slot[1].setLinkSignalPath(1);
        m_slot[1].setType(MaterialsType::G1);
    }
 
    void CBonder::onTimer(UINT nTimerid)
    {
        CEquipment::onTimer(nTimerid);
 
        // test     
        /*
        static int i[2] = { 0, 0 };
        i[m_nIndex]++;
        if (m_nIndex == 0 && i[m_nIndex] % 20 == 0) {
            if (m_listener.onAlarm != nullptr) {
                m_listener.onAlarm(this, 1,
                    i[m_nIndex],
                    getID(),
                    1);
            }
        }
        */
    }
 
    void CBonder::serialize(CArchive& ar)
    {
        CEquipment::serialize(ar);
    }
 
    void CBonder::getAttributeVector(CAttributeVector& attrubutes)
    {
        __super::getAttributeVector(attrubutes);
    }
 
    int CBonder::recvIntent(CPin* pPin, CIntent* pIntent)
    {
        return __super::recvIntent(pPin, pIntent);
    }
 
    void CBonder::setIndex(unsigned int index)
    {
        m_nIndex = index;
    }
 
    unsigned int CBonder::getIndex()
    {
        return m_nIndex;
    }
 
    BOOL CBonder::hasBondGlass()
    {
        CGlass* pGlass = (CGlass*)m_slot[1].getContext();
        if (pGlass == nullptr) return FALSE;
        CGlass* pBuddy = pGlass->getBuddy();
        return pBuddy != nullptr;
    }
 
    BOOL CBonder::hasG2Glass()
    {
        CGlass* pGlass = (CGlass*)m_slot[0].getContext();
        return (pGlass != nullptr);
    }
 
    int CBonder::onProcessData(CProcessData* pProcessData)
    {
        CEquipment::onProcessData(pProcessData);
 
 
        return 0;
    }
 
    int CBonder::onProcessStateChanged(int slotNo, PROCESS_STATE prevState, PROCESS_STATE state)
    {
        CEquipment::onProcessStateChanged(slotNo, prevState, state);
 
        if (state == PROCESS_STATE::Complete) {
            // 检查数据,当前两片玻璃,一片为G1, 一片为G2, 且pProcessData中的id能匹配G1或G2
            Lock();
            CGlass* pGlass2 = getGlassFromSlot(1);
            CGlass* pGlass1 = getGlassFromSlot(2);
            if (pGlass1 == nullptr || pGlass2 == nullptr) {
                LOGE("<CBonder-%s>onProcessData,错误!不满足两片玻璃且分别为G1与G2的条件,请检查数据是否正确!", m_strName.c_str());
                Unlock();
                return -1;
            }
            if (pGlass1->getBuddy() != nullptr) {
                LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被绑定,请检查数据是否正确!", m_strName.c_str());
                Unlock();
                return -1;
            }
 
            if (pGlass1->getType() != MaterialsType::G1 || pGlass2->getType() != MaterialsType::G2) {
                LOGE("<CBonder-%s>onProcessData,错误!两片玻璃未匹配,必须分别为G1和G2类型,请检查数据是否正确!", m_strName.c_str());
                Unlock();
                return -1;
            }
 
            pGlass1->setBuddy(pGlass2);
            getSlot(0)->setContext(nullptr);
            LOGE("<CBonder-%s>onProcessStateChanged,%s和%s已贴合!", m_strName.c_str(),
                pGlass1->getID().c_str(), pGlass2->getID().c_str());
            Unlock();
        }
 
        return 0;
    }
 
    int CBonder::getIndexerOperationModeBaseValue()
    {
        return m_nIndex == 0 ? 15000 : 20000;
    }
 
    int CBonder::parsingParams(const char* pszData, size_t size, std::vector<CParam>& params)
    {
        ASSERT(pszData);
        if (size < 250) return 0;
        int i = 0, v;
 
 
        // 1.校正对位延时
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("校正对位延时", "", this->getName().c_str(), v * 0.01f));
        i += 2;
 
        // 2.保压时间
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("保压时间", "", this->getName().c_str(), v * 0.01f));
        i += 2;
 
        // 3.腔体破真空延时
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("腔体破真空延时", "", this->getName().c_str(), v * 0.01f));
        i += 2;
 
        // 4.腔体分子泵启动延时
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("腔体分子泵启动延时", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 5.腔体贴附抽真空延时
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("腔体贴附抽真空延时", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 6.加热等待延时
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("加热等待延时", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 7.气囊压力设定
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("气囊压力设定", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 8.气囊加压速率
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("气囊加压速率", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 9.气囊泄压速率
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("气囊泄压速率", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 10.贴附压力上限
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("贴附压力上限", "", this->getName().c_str(), v * 0.1f));
        i += 4;
 
        // 11.Z轴转矩速度设定
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("上腔Z轴转矩速度设定", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 12.上腔温度设定
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("上腔温度设定", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 13.下腔温度设定
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("下腔温度设定", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 14.上腔Z轴预贴合位速度
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("上腔Z轴预贴合位速度", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 15.上腔Z轴贴附位速度
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("上腔Z轴贴附位速度", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 16.上腔Z上腔加热位间距
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("上腔Z上腔加热位间距", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 17.上腔贴附位压入量
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("上腔贴附位压入量", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 18.上腔Z轴破真空距离
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("上腔Z轴破真空距离", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 19.下顶Pin破真空距离
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("下顶Pin破真空距离", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 20.下顶Pin加热位间距
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("下顶Pin加热位间距", "", this->getName().c_str(), v * 0.001f));
        i += 4;
 
        // 21.腔体真空泵真空规设定值
        params.push_back(CParam("腔体真空泵真空规设定值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
        i += 4;
 
        // 22.腔体分子泵到达设定值
        params.push_back(CParam("腔体分子泵到达设定值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
        i += 4;
 
 
        return (int)params.size();
    }
 
    int CBonder::parsingProcessData(const char* pszData, size_t size, std::vector<CParam>& params)
    {
        return parsingParams(pszData, size, params);
    }
 
    int CBonder::parsingSVData(const char* pszData, size_t size, std::vector<CParam>& params)
    {
        /*
        1    工艺运行步骤    1Word    123456
            2    气囊压力当前    2Word    12345.6
            3    上腔压力合计    1Word    1234.56
            4    管道真空规值    FLOAT    123.456
            5    腔体真空规值    FLOAT    123.456
            6    上腔温度1    1Word    12345.6
            7    上腔温度2    1Word    12345.6
            8    上腔温度3    1Word    12345.6
            9    上腔温度4    1Word    12345.6
            10    上腔温度5    1Word    12345.6
            11    上腔温度6    1Word    12345.6
            12    下腔温度1    1Word    12345.6
            13    下腔温度2    1Word    12345.6
            14    下腔温度3    1Word    12345.6
            15    下腔温度4    1Word    12345.6
            16    下腔温度5    1Word    12345.6
            17    下腔温度6    1Word    12345.6
            18    压合剩余时间    1Word    1234.56
*/
 
        ASSERT(pszData);
        if (size < 125) return 0;
        int i = 0, v;
 
 
        // 1.工艺运行步骤
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("工艺运行步骤", "", this->getName().c_str(), v));
        i += 2;
 
        // 2.气囊压力当前
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8 | (pszData[i + 2] & 0xff) << 16 | (pszData[i + 3] & 0xff) << 24;
        params.push_back(CParam("气囊压力当前", "", this->getName().c_str(), v * 0.1f));
        i += 4;
 
        // 3.上腔压力合计
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("上腔压力合计", "", this->getName().c_str(), ((short)v) * 0.01f));
        i += 2;
 
        // 4.管道真空规值
        params.push_back(CParam("管道真空规值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
        i += 4;
 
        // 5.腔体真空规值
        params.push_back(CParam("腔体真空规值", "", this->getName().c_str(), (double)toFloat(&pszData[i])));
        i += 4;
 
        // 6.上腔温度1
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("上腔温度1", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 7.上腔温度2
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("上腔温度2", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 8.上腔温度3
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("上腔温度3", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 9.上腔温度4
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("上腔温度4", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 10.上腔温度5
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("上腔温度5", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 11.上腔温度6
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("上腔温度6", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 12.下腔温度1
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("下腔温度1", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 13.下腔温度2
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("下腔温度2", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 14.下腔温度3
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("下腔温度3", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 15.下腔温度4
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("下腔温度4", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 16.下腔温度5
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("下腔温度5", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 17.下腔温度6
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("下腔温度6", "", this->getName().c_str(), v * 0.1f));
        i += 2;
 
        // 18.加热剩余时间
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("加热剩余时间", "", this->getName().c_str(), v * 0.01f));
        i += 2;
 
        // 19.压合剩余时间
        v = (pszData[i] & 0xff) | (pszData[i + 1] & 0xff) << 8;
        params.push_back(CParam("压合剩余时间", "", this->getName().c_str(), v * 0.01f));
        i += 2;
 
        return (int)params.size();
    }
 
}