xm
2020-07-20 b02e8275a21dc06bf54b66273485d44e007a2616
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
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ZigBee.Device;
 
namespace Shared.Common
{
    /// <summary>
    /// 本地设备
    /// </summary>
    public class LocalDevice
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 本地设备
        /// </summary>
        private static LocalDevice m_Current = null;
        /// <summary>
        /// 本地设备
        /// </summary>
        public static LocalDevice Current
        {
            get
            {
                if (m_Current == null)
                {
                    m_Current = new LocalDevice();
                }
                return m_Current;
            }
            set
            {
                m_Current = value;
            }
        }
        /// <summary>
        /// 本地所有设备的缓存
        /// </summary>
        public List<CommonDevice> listAllDevice
        {
            get
            {
                lock (dicAllDevice)
                {
                    //先获取全部的Mac
                    var listMac = new List<string>();
                    foreach (var strMac in this.dicDeviceEpoint.Keys)
                    {
                        listMac.Add(strMac);
                    }
                    //根据MAC地址,获取全部回路的设备对象(强制排序)
                    return this.GetDevicesByMac(listMac);
                }
            }
        }
 
        /// <summary>
        /// R文件里面设备模块ID的翻译名字的前缀
        /// </summary>
        public const string deviceModelIdName = "uDeviceModelId";
        /// <summary>
        /// R文件里面所有设备名字的ID
        /// </summary>
        public Dictionary<string, int> dicDeviceAllNameID = null;
        /// <summary>
        /// 设备的模块ID的枚举(keys:模块ID  value:设备具体类型值-设备所属类型值(自定义的值,嘛,只要不重复就可以)
        /// </summary>
        private Dictionary<string, string> dicDeviceModelIdEnum = null;
        /// <summary>
        /// 需要转换的设备的模块ID(keys:旧模块ID,value:新模块ID)
        /// </summary>
        private Dictionary<string, string> dicDeviceModelIdChanged = null;
        /// <summary>
        /// 图片共有(keys:指定设备的具体类型 value:指定共有对象的具体类型)
        /// </summary>
        private Dictionary<string, string> dicPictrueShard = null;
        /// <summary>
        /// 本地所有设备的缓存(非公开)
        /// </summary>
        private Dictionary<string, CommonDevice> dicAllDevice = new Dictionary<string, CommonDevice>();
        /// <summary>
        /// 本地所有的顶点升级设备(非公开,主键是MAC+200端口)
        /// </summary>
        private Dictionary<string, OTADevice> dicOTADevice = new Dictionary<string, OTADevice>();
        /// <summary>
        /// 设备的总回路(keys:Mac地址  value:全部端口号)
        /// </summary>
        private Dictionary<string, HashSet<int>> dicDeviceEpoint = new Dictionary<string, HashSet<int>>();
        /// <summary>
        /// 物理设备属于哪个房间的记录
        /// </summary>
        private Dictionary<string, string> dicDeviceRoomId = null;
 
        #endregion
 
        #region ■ 刷新设备___________________________
 
        /// <summary>
        /// 刷新本地设备信息
        /// </summary>
        public void ReFreshByLocal()
        {
            this.dicAllDevice.Clear();
            this.dicDeviceEpoint.Clear();
 
            //初始化R文件里面设备默认名字的ID
            this.InitDeviceDefultNameIDList();
 
            //获取本地全部的设备文件
            List<string> listFile = this.GetAllDeviceFile();
            foreach (string file in listFile)
            {
                CommonDevice device = null;
                //反序列化为指定的类,不然数据会丢失而导致无法强转
                try 
                {
                    device = CommonDevice.CommonDeviceByFilePath(file);
                }
                catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
 
                if (device == null || device.CurrentGateWayId == null)
                {
                    //失效的文件,没有网关id的都删除掉
                    Global.DeleteFilebyHomeId(file);
                    continue;
                }
                //如果这个设备的网关ID不存在的话
                if (HdlGatewayLogic.Current.IsGatewayExist(device.CurrentGateWayId) == false)
                {
                    if (UserCenterResourse.UserInfo.AuthorityNo == 3)
                    {
                        //如果他是成员的话,帮他新建一个网关
                        HdlGatewayLogic.Current.AddVirtualGateway(device.CurrentGateWayId);
                    }
                    else
                    {
                        //如果是主人,或者管理员,那么这个文件是非法的,直接删除
                        Global.DeleteFilebyHomeId(file);
                        continue;
                    }
                }
 
                string mainKey = this.GetDeviceMainKeys(device);
                if (device is OTADevice)
                {
                    //200端口不需要处理
                    this.dicOTADevice[mainKey] = (OTADevice)device;
                    continue;
                }
                //添加缓存
                this.dicAllDevice[mainKey] = device;
 
                //回路收集
                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == false)
                {
                    this.dicDeviceEpoint[device.DeviceAddr] = new HashSet<int>();
                }
                this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint);
 
                //检测Ui图片是否正确,这个图片本地是否存在?
                if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(device.IconPath)) == true)
                {
                    //不存在的话,重新生成
                    device.IconPath = string.Empty;
                    device.ReSave();
                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
                }
            }
            //成员身份的时候,删除掉非法的网关文件
            this.DeleteGatewayFileByMemberModel();
            //初始化物理设备所属房间的记录
            this.InitRealDeviceRoomId();
        }
 
        /// <summary>
        /// 成员身份的时候,删除掉非法的网关文件
        /// </summary>
        private void DeleteGatewayFileByMemberModel()
        {
            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
                return;
            }
            var listId = new HashSet<string>();
 
            lock (dicAllDevice)
            {
                foreach (var device in this.dicAllDevice.Values)
                {
                    if (listId.Contains(device.CurrentGateWayId) == false)
                    {
                        listId.Add(device.CurrentGateWayId);
                    }
                }
            }
            var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
            foreach (var gateway in listGateway)
            {
                string gwId = gateway.GwId;
                if (listId.Contains(gwId) == false)
                {
                    //这个网关对于当前这个成员来说是非法的
                    HdlGatewayLogic.Current.DeleteGatewayFile(gwId);
                }
            }
        }
 
        #endregion
 
        #region ■ 添加设备___________________________
 
        /// <summary>
        /// <para>将指定网关的设备存入缓存中(从新获取镜像)</para>
        /// <para>-1:异常 1:正常 2:设备信息缺损</para>
        /// </summary>
        /// <param name="zbGateway">网关对象</param>
        public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway)
        {
            //从网关获取全部的设备
            int statu = 0;
            List<CommonDevice> listDevice = new List<CommonDevice>();
            List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, true);
            if (list == null)
            {
                return -1;
            }
            listDevice.AddRange(list);
 
            //获取这个网关的本地所有设备
            string gwID = zbGateway.GwId;
            List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
            //获取ota设备
            foreach (var ota in this.dicOTADevice.Values)
            {
                if (ota.CurrentGateWayId == gwID)
                {
                    listLocalDevices.Add(ota);
                }
            }
 
            Dictionary<string, CommonDevice> dicExist = new Dictionary<string, CommonDevice>();
            foreach (var device in listLocalDevices)
            {
                string maikey = this.GetDeviceMainKeys(device);
                dicExist[maikey] = device;
            }
 
            //添加设备的缓存
            var listDriveDevice = new List<CommonDevice>();
            for (int i = 0; i < listDevice.Count; i++)
            {
                var device = listDevice[i];
                if (device == null || device.DeviceAddr == null)
                {
                    continue;
                }
                //添加缓存
                this.AddDeviceToMemory(ref device);
 
                //移除存在的设备内存 
                string maikey = this.GetDeviceMainKeys(device);
                if (dicExist.ContainsKey(maikey) == true)
                {
                    dicExist.Remove(maikey);
                }
                //获取设备的固定属性
                HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device);
                //对未命名的虚拟设备重新命名
                if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty)
                {
                    listDriveDevice.Add(device);
                }
            }
            if (listDriveDevice.Count > 0)
            {
                //如果虚拟设备还没有名字的话
                HdlThreadLogic.Current.RunThread(() =>
                {
                    //如果不这样放在一个线程里,有可能对Dictionary产生影响
                    foreach (var myDevice in listDriveDevice)
                    {
                        //根据设备类型获取名称
                        var dName = this.GetDeviceObjectText(new List<CommonDevice>() { myDevice }, false);
                        //在端点名字的后面附加【回路】字样
                        dName += "(" + myDevice.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                        this.ReName(myDevice, dName, ShowErrorMode.NO);
                    }
                });
            }
 
            //只有完全获取的时候,才会去处理删除的问题
            if (statu != 1)
            {
                return statu;
            }
 
            //如果本地和网关的设备不一致的时候,删除本地的设备
            var listDeleteMac = new List<string>();
            foreach (var device in dicExist.Values)
            {
                if (device is OTADevice)
                {
                    this.DeleteMemmoryOtaDevice(device.DeviceAddr);
                }
                else
                {
                    this.DeleteMemmoryDevice(device, true);
                }
                if (listDeleteMac.Contains(device.DeviceAddr) == false)
                {
                    //收集被删除的Mac
                    listDeleteMac.Add(device.DeviceAddr);
                }
            }
            if (listDeleteMac.Count > 0)
            {
                //将真实物理设备从房间中移除
                this.DeleteRealDeviceFromRoom(listDeleteMac);
            }
 
            return statu;
        }
 
        /// <summary>
        /// 添加设备到缓存,存在时覆盖
        /// </summary>
        /// <param name="device">设备对象(这个东西有可能会被更改)</param>
        public void AddDeviceToMemory(ref CommonDevice device)
        {
            string mainKeys = this.GetDeviceMainKeys(device);
            //如果它是升级的顶端端点,则不能让它加入到缓存,但是可以让他生成文件
            if (device is OTADevice)
            {
                if (this.dicOTADevice.ContainsKey(mainKeys) == false)
                {
                    this.dicOTADevice[mainKeys] = (OTADevice)device;
                }
                else
                {
                    //交换属性
                    var tempDevice = this.dicOTADevice[mainKeys];
                    //将DeviceInfo的属性设置到主属性中
                    this.SetDeviceInfoToMain(tempDevice, device);
                    device = tempDevice;
                }
 
                bool exists = Global.IsExistsByHomeId(device.FilePath);
                device.ReSave();
                if (exists == false)
                {
                    //添加自动备份
                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
                }
                return;
            }
 
            lock (dicAllDevice)
            {
                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
                {
                    //交换属性
                    var tempDevice = this.dicAllDevice[mainKeys];
                    //将DeviceInfo的属性设置到主属性中
                    this.SetDeviceInfoToMain(tempDevice, device);
                    device = tempDevice;
                }
                else
                {
                    this.dicAllDevice[mainKeys] = device;
                }
            }
 
            //设备回路收集
            if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == false)
            {
                this.dicDeviceEpoint[device.DeviceAddr] = new HashSet<int>();
            }
            if (this.dicDeviceEpoint[device.DeviceAddr].Contains(device.DeviceEpoint) == false)
            {
                this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint);
            }
 
            bool exists2 = Global.IsExistsByHomeId(device.FilePath);
            device.ReSave();
            if (exists2 == false)
            {
                //添加自动备份
                HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
            }
        }
 
        /// <summary>
        /// 添加虚拟设备到缓存
        /// </summary>
        /// <param name="device">设备对象</param>
        public void AddVirtualDeviceToMemory(CommonDevice device)
        {
            string mainKeys = this.GetDeviceMainKeys(device);
            this.dicAllDevice[mainKeys] = device;
 
            //设备回路收集
            if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == false)
            {
                this.dicDeviceEpoint[device.DeviceAddr] = new HashSet<int>();
            }
            if (this.dicDeviceEpoint[device.DeviceAddr].Contains(device.DeviceEpoint) == false)
            {
                this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint);
            }
            device.ReSave();
        }
 
        #endregion
 
        #region ■ 修改设备___________________________
 
        /// <summary>
        /// 更改端点名字并且刷新缓存(修改失败时,会显示信息)
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <param name="newName">新名字</param>
        /// <param name="mode">是否显示错误</param>
        public bool ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES)
        {
            //先别管那么多,更改名字后,刷新设备缓存
            this.SetEpointName(device, newName);
 
            this.BackupDeviceAfterReName(device);
 
            //如果住宅为虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                //修改设备名字的话,主页需要重新刷新
                Phone.UserView.UserPage.Instance.RefreshAllForm = true;
                return true;
            }
 
            //不再检测名字是否一样
            //成员只能修改自己本地的名字
            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
                var result = this.RenameDeviceNameAsync(device, newName);
                if (result == null || result.deviceRenameData == null || result.deviceRenameData.Result == 1)
                {
                    //设备名称修改失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNameFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
 
                    if (mode == ShowErrorMode.YES)
                    {
                        this.ShowErrorMsg(msg);
                    }
                    return false;
                }
            }
            //修改设备名字的话,主页需要重新刷新
            Phone.UserView.UserPage.Instance.RefreshAllForm = true;
            return true;
        }
 
        /// <summary>
        /// 更改Mac名字并且刷新缓存(修改失败时,会显示信息)
        /// </summary>
        /// <param name="listDevice">设备对象</param>
        /// <param name="newMacName">新名字</param>
        /// <param name="mode">是否显示错误</param>
        public bool ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES)
        {
            if (listDevice.Count == 0)
            {
                return true;
            }
            //先别管那么多,先修改缓存
            for (int i = 0; i < listDevice.Count; i++)
            {
                var device2 = listDevice[i];
                //这两个东西很特殊
                this.SetMacName(device2, newMacName);
 
                //更改名字后,刷新设备缓存
                this.BackupDeviceAfterReName(device2);
            }
            //如果住宅为虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return true;
            }
 
            CommonDevice device = listDevice[0];
            //不再检测名字是否一样
            //成员只能修改自己本地的名字
            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
                //修改物理名字
                var result = this.RenameDeviceMacNameAsync(device, newMacName);
                if (result == null || result.renameDeviceMacNameData == null || result.renameDeviceMacNameData.Result != 0)
                {
                    //设备名称修改失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNameFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                    if (mode == ShowErrorMode.YES)
                    {
                        this.ShowErrorMsg(msg);
                    }
                    return false;
                }
                //如果它只有一个回路,则更改端点名字
                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
                {
                    //只有一个端点
                    if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
                    {
                        return this.ReName(device, newMacName);
                    }
                    //如果它有两个端点时,pir传感器特殊处理
                    else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2)
                    {
                        var myType = this.GetMyDeviceEnumInfo(listDevice);
                        if (myType.ConcreteType == DeviceConcreteType.Sensor_Pir)
                        {
                            foreach (var myDevice in listDevice)
                            {
                                if (myDevice.Type == DeviceType.IASZone)
                                {
                                    return this.ReName(myDevice, newMacName);
                                }
                            }
                        }
                    }
                }
            }
            return true;
        }
 
        ///<summary >
        /// 修改设备mac名称
        /// <para>macName:设备名称</para>
        /// </summary>
        private CommonDevice.RenameDeviceMacNameAllData RenameDeviceMacNameAsync(CommonDevice device, string macName)
        {
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename");
            }
 
            //获取编辑设备Mac名字的命令字符
            var sendData = this.GetReDeviceMacNameCommandText(device.DeviceAddr, device.DeviceEpoint, macName);
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon", 8);
            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
            {
                return null;
            }
            //加缓存
            Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename");
 
            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RenameDeviceMacNameData>(result.ReceiptData);
            return new CommonDevice.RenameDeviceMacNameAllData { renameDeviceMacNameData = tempData };
        }
 
        /// <summary>
        /// 修改设备端口(按键)名称
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <param name="deviceName">设备端点名字</param>
        /// <returns></returns>
        private CommonDevice.DeviceRenameAllData RenameDeviceNameAsync(CommonDevice device, string deviceName)
        {
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename");
            }
            //获取编辑设备端点名字的命令字符
            var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName);
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon", 8);
            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
            {
                return null;
            }
            //加缓存
            Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename");
 
            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceRenameResponseData>(result.ReceiptData);
            return new CommonDevice.DeviceRenameAllData { deviceRenameData = tempData };
        }
 
        /// <summary>
        /// 获取编辑设备Mac名字的命令字符
        /// </summary>
        /// <param name="deviceAddr"></param>
        /// <param name="deviceEpoint"></param>
        /// <param name="deviceName"></param>
        /// <returns></returns>
        public string GetReDeviceMacNameCommandText(string deviceAddr, int deviceEpoint, string deviceName)
        {
            var bytes = new byte[64];
            var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName);
            System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length);
            deviceName = Encoding.UTF8.GetString(bytes);
 
            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 100 } };
            var data = new Newtonsoft.Json.Linq.JObject { { "MacName", deviceName } };
            jObject.Add("Data", data);
            return jObject.ToString();
        }
 
        /// <summary>
        /// 获取编辑设备端点名字的命令字符
        /// </summary>
        /// <param name="deviceAddr"></param>
        /// <param name="deviceEpoint"></param>
        /// <param name="deviceName"></param>
        /// <returns></returns>
        public string GetReDeviceEpointNameCommandText(string deviceAddr, int deviceEpoint, string deviceName)
        {
            var bytes = new byte[64];
            var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName);
            System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length);
            deviceName = Encoding.UTF8.GetString(bytes);
 
            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 96 } };
            var data = new Newtonsoft.Json.Linq.JObject { { "DeviceName", deviceName } };
            jObject.Add("Data", data);
 
            return jObject.ToString();
        }
 
        /// <summary>
        /// 更改名字后,刷新设备缓存
        /// </summary>
        /// <param name="device"></param>
        private void BackupDeviceAfterReName(CommonDevice device)
        {
            lock (dicAllDevice)
            {
                string mainKeys = this.GetDeviceMainKeys(device);
                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
                {
                    //一般设备
                    this.dicAllDevice[mainKeys] = device;
                    device.ReSave();
 
                    //添加自动备份
                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
                }
                else if (this.dicOTADevice.ContainsKey(mainKeys) == true)
                {
                    //Ota设备
                    this.dicOTADevice[mainKeys] = (OTADevice)device;
                    device.ReSave();
 
                    //添加自动备份
                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
 
                }
            }
        }
 
        #endregion
 
        #region ■ 删除设备___________________________
 
        /// <summary>
        /// 删除设备并且刷新缓存(删除失败时,会显示信息)
        /// </summary>
        /// <param name="listdevice">设备对象(MAC地址必须要相同)</param>
        public async Task<bool> DeleteDevice(List<CommonDevice> listdevice)
        {
            //虚拟住宅的话,不需要删除网关的设备
            if (Config.Instance.Home.IsVirtually == false)
            {
                var data = new CommonDevice.RemoveDeviceData();
                var info = new CommonDevice.RemoveDeviceListInfo();
                info.DeviceAddr = listdevice[0].DeviceAddr;
                data.DeviceAddrList.Add(info);
 
                //删一次的时候,它会把MAC地址下面全部的设备都删除
                var result = await listdevice[0].DeleteDeviceAsync(data);
                if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0)
                {
                    //设备删除失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
 
                    this.ShowErrorMsg(msg);
                    return false;
                }
            }
 
            //删除缓存的Ota设备
            this.DeleteMemmoryOtaDevice(listdevice[0].DeviceAddr);
            //删除一般设备文件
            foreach (CommonDevice device in listdevice)
            {
                this.DeleteMemmoryDevice(device);
            }
 
            if (this.dicDeviceRoomId.ContainsKey(listdevice[0].DeviceAddr) == true)
            {
                //移除真实设备的房间索引
                this.dicDeviceRoomId.Remove(listdevice[0].DeviceAddr);
                this.SaveRealDeviceRoomId(null, null);
            }
            return true;
        }
 
        /// <summary>
        /// 删除缓存的一般设备
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <param name="deleteRoom">是否从房间删除</param>
        public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
        {
            //删除缓存设备的话,主页需要重新刷新
            Phone.UserView.UserPage.Instance.RefreshAllForm = true;
 
            if (deleteRoom == true)
            {
                //从房间中删除
                HdlRoomLogic.Current.DeleteDevice(device);
                //删除我的喜爱的设备
                HdlRoomLogic.Current.DeleteLoveDevice(device);
            }
 
            //删除缓存
            string mainKeys = this.GetDeviceMainKeys(device);
            lock (dicAllDevice)
            {
                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
                {
                    this.dicAllDevice.Remove(mainKeys);
                }
                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
                {
                    //变更端点数
                    this.dicDeviceEpoint[device.DeviceAddr].Remove(device.DeviceEpoint);
                }
            }
 
            //删除设备文件
            string filePath = device.FilePath;
            if (Global.IsExistsByHomeId(filePath) == true)
            {
                if (UserCenterResourse.UserInfo.AuthorityNo == 3)
                {
                    //成员的话,直接删除,没有商量的余地
                    Global.DeleteFilebyHomeId(filePath);
                }
                else
                {
                    //变更:搞掉它,不留了
                    Global.DeleteFilebyHomeId(filePath);
                    //删除自动备份
                    HdlAutoBackupLogic.DeleteFile(device.FilePath);
                }
            }
        }
 
        /// <summary>
        /// 删除缓存的Ota设备
        /// </summary>
        /// <param name="macAdrr"></param>
        /// <param name="ePoint"></param>
        public void DeleteMemmoryOtaDevice(string macAdrr, int ePoint = 200)
        {
            //删除200端口文件
            string otaKeys = this.GetDeviceMainKeys(macAdrr, ePoint);
            if (this.dicOTADevice.ContainsKey(otaKeys) == true)
            {
                string otaFile = this.dicOTADevice[otaKeys].FilePath;
                if (Global.IsExistsByHomeId(otaFile) == true)
                {
                    if (UserCenterResourse.UserInfo.AuthorityNo == 3)
                    {
                        //成员的话,直接删除,没有商量的余地
                        Global.DeleteFilebyHomeId(otaFile);
                    }
                    else
                    {
                        //变更:搞掉它,不留了
                        Global.DeleteFilebyHomeId(otaFile);
                        //删除自动备份
                        HdlAutoBackupLogic.DeleteFile(otaFile);
                    }
                }
                this.dicOTADevice.Remove(otaKeys);
            }
        }
 
        #endregion
 
        #region ■ 同步设备___________________________
        /// <summary>
        ///  同步设备并且刷新缓存(同步失败时,会显示信息)
        /// </summary>
        /// <param name="litdevice">设备对象(MAC地址必须要相同)</param>
        public async Task<bool> SynchronizationDevice(List<CommonDevice> listdevice)
        {
            //虚拟住宅的话,不需要删除网关的设备
            if (Config.Instance.Home.IsVirtually == false)
            {
                //同步
                var result = await listdevice[0].SyncMsgToBindSource(listdevice[0].DeviceAddr, listdevice[0].DeviceEpoint);
                if (result == null || result.result != 0)
                {
                    //同步删除失败
                    string msg = Language.StringByID(R.MyInternationalizationString.SynchronizationFailed);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
 
                    this.ShowErrorMsg(msg);
                    return false;
                }
            }
            return true;
        }
        #endregion
 
 
 
        #region ■ 测试设备___________________________
 
        /// <summary>
        /// 发送定位指令到设备
        /// </summary>
        /// <param name="device"></param>
        public void SetFixedPositionCommand(CommonDevice device)
        {
            //如果当前住宅不是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == false)
            {
                device.IdentifyControl(device.DeviceAddr, device.DeviceEpoint, 5);
            }
        }
 
        /// <summary>
        /// 检测设备是否拥有定位的功能
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool DeviceIsCanFixedPosition(CommonDevice device)
        {
            if (device.Type == DeviceType.DoorLock || device.Type == DeviceType.PMSensor)
            {
                //门锁没有定位功能
                return false;
            }
            if (device.Type == DeviceType.IASZone)
            {
                var myTypeInfo = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_Pir)
                {
                    //传感器除了Pir都没有定位功能
                    return true;
                }
                else if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_SphericalMotion)
                {
                    //球型移动传感器虽然是电池设备,但是它有定位功能
                    return true;
                }
                return false;
            }
 
            foreach (var data in device.InClusterList)
            {
                //拥有on/off功能的,才支持测试
                if (data.InCluster == 3)
                {
                    return true;
                }
            }
            return false;
        }
 
        /// <summary>
        /// 检测设备是否拥有一键同步功能
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool DeviceIsCanSynchronization(CommonDevice device)
        {
            //获取设备类型的
            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
            {
                return true;
            }
            return false;
        }
 
        /// <summary>
        /// 检测设备是否拥有开关的功能(输出簇)
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool OutDeviceIsCanOnOff(CommonDevice device)
        {
            foreach (var data in device.OutClusterList)
            {
                //拥有on/off功能的,才支持测试
                if (data.OutCluster == 6)
                {
                    return true;
                }
            }
            return false;
        }
 
        /// <summary>
        /// 检测设备是否拥有开关的功能(输入簇)
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool InDeviceIsCanOnOff(CommonDevice device)
        {
            foreach (var data in device.InClusterList)
            {
                //拥有on/off功能的,才支持测试
                if (data.InCluster == 6)
                {
                    return true;
                }
            }
            return false;
        }
 
        #endregion
 
        #region ■ 获取设备___________________________
 
        /// <summary>
        /// 根据网关ID获取所有的设备
        /// </summary>
        /// <param name="gwId">网关ID</param>>
        /// <returns></returns>
        public List<CommonDevice> GetDeviceByGatewayID(string gwId)
        {
            lock (dicAllDevice)
            {
                var listMac = new List<string>();
                //各网关的所有设备的Mac
                foreach (CommonDevice device in this.dicAllDevice.Values)
                {
                    if (gwId == device.CurrentGateWayId)
                    {
                        listMac.Add(device.DeviceAddr);
                    }
                }
                return this.GetDevicesByMac(listMac);
            }
        }
 
        /// <summary>
        /// 获取指定设备(主键是:Mac地址+端口号),不存在时,返回null
        /// </summary>
        /// <param name="mainKeys">Mac地址+端口号</param>
        /// <returns></returns>
        public CommonDevice GetDevice(string mainKeys)
        {
            lock (dicAllDevice)
            {
                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
                {
                    return this.dicAllDevice[mainKeys];
                }
            }
            return null;
        }
 
        /// <summary>
        /// 获取指定设备,不存在时,返回null
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
        /// <param name="DeviceEpoint">端口号</param>
        /// <returns></returns>
        public CommonDevice GetDevice(string DeviceAddr, int DeviceEpoint)
        {
            string mainkeys = this.GetDeviceMainKeys(DeviceAddr, DeviceEpoint);
            return this.GetDevice(mainkeys);
        }
 
        /// <summary>
        /// 根据MAC地址,获取全部回路的设备对象
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
        /// <param name="sort">是否排序</param>
        /// <returns></returns>
        public List<CommonDevice> GetDevicesByMac(string DeviceAddr, bool sort = true)
        {
            var list = new List<CommonDevice>();
            if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
            {
                return list;
            }
            foreach (var point in dicDeviceEpoint[DeviceAddr])
            {
                var device = this.GetDevice(DeviceAddr, point);
                if (device != null)
                {
                    list.Add(device);
                }
            }
            if (sort == false)
            {
                return list;
            }
 
            //排序
            list.Sort((obj1, obj2) =>
            {
                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
                {
                    return 1;
                }
                return -1;
            });
            return list;
        }
 
        /// <summary>
        /// 根据MAC地址,获取简约面板全部回路的设备对象
        /// </summary>
        /// <param name="listDevice"></param>
        /// <returns></returns>
        public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true)
        {
            //和彪哥、设备和产品部同事确认:
            //简约多功能面板[不显示多余的回路,只显示携带的2个继电器,1个温度传感器,1个湿度传感器
            var list = new List<CommonDevice>();
            foreach (var dev in listDevice)
            {
                if (dev.Type == DeviceType.TemperatureSensor)
                {
                    if (dev.DeviceEpoint == 64)
                    {
                        list.Add(dev);
                    }
                }
                else if (dev.Type == DeviceType.FreshAirHumiditySensor)
                {
                    if (dev.DeviceEpoint == 65)
                    {
                        list.Add(dev);
                    }
                }
                else if (dev.Type == DeviceType.OnOffOutput)
                {
                    list.Add(dev);
                }
            }
 
            if (sort == false)
            {
                return list;
            }
            list.Sort((obj1, obj2) =>
            {
                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
                {
                    return 1;
                }
                return -1;
            });
 
            return list;
        }
 
        /// <summary>
        /// 根据MAC地址,获取新风、简约环境面板全部回路的设备对象
        /// </summary>
        /// <param name="listDevice"></param>
        /// <returns></returns>
        public List<CommonDevice> GetPanelMatchEpointByMac(List<CommonDevice> listDevice, bool sort = true)
        { 
            var list = new List<CommonDevice>();
            foreach (var dev in listDevice)
            {
                if (dev.Type == DeviceType.TemperatureSensor)
                {
                    list.Add(dev);
                }
                else if (dev.Type == DeviceType.FreshAirHumiditySensor)
                {
                    list.Add(dev);
                }  
            }
            if (sort == false)
            {
                return list;
            }
            list.Sort((obj1, obj2) =>
            {
 
                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
                {
                    return 1;
                }
                return -1;
            }); 
            return list;
        }
 
        /// <summary>
        /// 根据MAC地址,获取全部回路的设备对象(强制排序)
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
        /// <returns></returns>
        public List<CommonDevice> GetDevicesByMac(List<string> listMacAddr)
        {
            //先排序
            listMacAddr.Sort();
 
            var list = new List<CommonDevice>();
            foreach (string strMac in listMacAddr)
            {
                var listEpoint = new List<int>();
                //获取全部的端点
                foreach (int epoint in this.dicDeviceEpoint[strMac])
                {
                    listEpoint.Add(epoint);
                }
                //然后排序
                listEpoint.Sort();
                foreach (int epoint in listEpoint)
                {
                    var device = this.GetDevice(strMac, epoint);
                    if (device != null)
                    {
                        list.Add(device);
                    }
                }
            }
            return list;
        }
 
        /// <summary>
        /// 根据MAC地址,获取全部回路的数量
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
        /// <returns></returns>
        public int GetDevicesCountByMac(string DeviceAddr)
        {
            if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
            {
                return 0;
            }
            return dicDeviceEpoint[DeviceAddr].Count;
        }
 
        /// <summary>
        /// 获取本地全部的设备文件
        /// </summary>
        /// <returns></returns>
        public List<string> GetAllDeviceFile()
        {
            List<string> listDeviceFile = new List<string>();
            List<string> listAllFile = HdlFileLogic.Current.GetRootPathListFile();
 
            foreach (string file in listAllFile)
            {
                if (file.StartsWith("Device_") == false)
                {
                    //如果不是设备文件
                    continue;
                }
                listDeviceFile.Add(file);
            }
            return listDeviceFile;
        }
 
        /// <summary>
        /// 获取OTA设备(200端口的)
        /// </summary>
        /// <param name="macAdrr"></param>
        /// <param name="ePoint"></param>
        /// <returns></returns>
        public OTADevice GetOTADevice(string macAdrr, int ePoint = 200)
        {
            string mainkeys = this.GetDeviceMainKeys(macAdrr, ePoint);
            if (this.dicOTADevice.ContainsKey(mainkeys) == false)
            {
                return null;
            }
            return this.dicOTADevice[mainkeys];
        }
 
        /// <summary>
        /// 获取特殊的,没有其他回路,单纯只有200端点的OTA设备
        /// </summary>
        /// <param name="gwId">网关ID</param>
        /// <returns></returns>
        public List<OTADevice> GetSpecialOtaDevice(string gwId)
        {
            var list = new List<OTADevice>();
            foreach (var ota in this.dicOTADevice.Values)
            {
                if (ota.CurrentGateWayId != gwId)
                {
                    //不是同一个网关
                    continue;
                }
                //没有其他回路
                if (dicDeviceEpoint.ContainsKey(ota.DeviceAddr) == false
                    || dicDeviceEpoint[ota.DeviceAddr].Count == 0)
                {
                    //目前只针对中央空调
                    if (ota.ModelIdentifier == "MAC/GW-ZB.10")
                    {
                        list.Add(ota);
                    }
                }
            }
            return list;
        }
 
        #endregion
 
        #region ■ 获取设备信息_______________________
 
        /// <summary>
        /// 读取单个端点回路设备信息
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public CommonDevice.DeviceInfoData ReadDeviceEpointDeviceInfo(CommonDevice device)
        {
            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 80 } };
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "GetStatusRecord", jObject.ToString(), "GetStatusRecord_Respon");
            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
            {
                return null;
            }
            var info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(result.ReceiptData);
            return info;
        }
 
        #endregion
 
        #region ■ 设置设备功能类型___________________
 
        /// <summary>
        /// 设置设备功能类型到网关
        /// </summary>
        /// <param name="device">设备回路</param>
        /// <param name="functionType">功能类型</param>
        /// <returns></returns>
        public bool SendDeviceFunctionTypeToGateway(CommonDevice device, DeviceFunctionType functionType)
        {
            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 110 } };
            var data = new Newtonsoft.Json.Linq.JObject { { "FunctionType", (int)functionType } };
            jObject.Add("Data", data);
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Device/SetEPDeviceFunctionType", jObject.ToString(), "Device/SetEPDeviceFunctionTypeRespon");
            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
            {
                return false;
            }
            var resultData = Newtonsoft.Json.Linq.JObject.Parse(result.ReceiptData);
            if (resultData.Property("Result") != null)
            {
                //0:修改成功 1:修改失败
                return resultData["Result"].ToString() == "0";
            }
            return false;
        }
 
        #endregion
 
        #region ■ 获取设备名称_______________________
 
        /// <summary>
        /// 获取设备端点的名称(有特效)
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public string GetDeviceEpointName(CommonDevice device)
        {
            string dName = this.GetSimpleEpointName(device);
            if (string.IsNullOrEmpty(dName) == false)
            {
                return dName;
            }
            if (this.IsMiniLight(device) == true)
            {
                //Mini夜灯
                return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
            }
 
            //如果这个设备只有一个回路的话,返回Mac名字给它
            if (this.GetDevicesCountByMac(device.DeviceAddr) <= 1)
            {
                return this.GetDeviceMacName(device);
            }
 
            //同一设备里面,不同类型的回路,它的命名都从1开始
            int epointNo = 0;
            var listSort = this.GetDevicesByMac(device.DeviceAddr);
            foreach (var myDevice in listSort)
            {
                if (myDevice.Type == device.Type)
                {
                    //同一类型编号+1
                    epointNo++;
                    if (myDevice.DeviceEpoint == device.DeviceEpoint)
                    {
                        //已经到达它自己
                        break;
                    }
                }
            }
 
            if (device.Type == DeviceType.OnOffOutput
                || device.Type == DeviceType.DimmableLight 
                || device.Type == DeviceType.ColorDimmableLight
                || device.Type == DeviceType.ColorTemperatureLight)
            {
                //继电器,掉光器都叫回路
                return Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + epointNo;
            }
            if (device.Type == DeviceType.Thermostat)
            {
                //空调都叫室内机
                return Language.StringByID(R.MyInternationalizationString.uIndoorUnit) + epointNo;
            }  
 
            //获取设备类型
            var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (device.Type == DeviceType.OnOffSwitch)
            {
                //面板的干接点叫按键
                if (deviceInfoType.BeloneType == DeviceBeloneType.A按键面板)
                {
                    return Language.StringByID(R.MyInternationalizationString.uPanelButton) + epointNo;
                }
                //其他的干接点叫干接点
                else
                {
                    return Language.StringByID(R.MyInternationalizationString.uDeviceBelongId16) + epointNo;
                }
            }
            else if (device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //新风面板/简约多功能/简约环境面板湿度传感器
                return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
            }
            else if (device.Type == DeviceType.TemperatureSensor)
            {
                if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment
                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                {
                    //新风面板/简约多功能/简约环境面板 温度传感器
                    return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                }
                else if (deviceInfoType.BeloneType == DeviceBeloneType.A按键面板)
                {
                    //面板的温度探头叫  面板名字+温度
                    return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.uTemperature);
                }
            }
            //其他情况,使用它的默认名称
            return Language.StringByID(deviceInfoType.DefultNameId) + epointNo;
        }
 
        /// <summary>
        /// 获取设备MAC名称
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public string GetDeviceMacName(CommonDevice device)
        {
            string dName = this.GetSimpleMacName(device);
            if (string.IsNullOrEmpty(dName) == false)
            {
                return dName;
            }
            if (this.IsMiniLight(device) == true)
            {
                //Mini夜灯
                return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
            }
 
            //获取设备类型
            var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            return Language.StringByID(deviceInfoType.DefultNameId);
        }
 
        /// <summary>
        /// 非公开,设置设备的Mac名字(此方法只是单存的变更缓存)
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <param name="macName">Mac名字</param>
        /// <returns></returns>
        private void SetMacName(CommonDevice device, string macName)
        {
            device.DeviceName = macName;
        }
 
        /// <summary>
        /// 非公开,设置设备的端点名字(此方法只是单存的变更缓存)
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <param name="epointName">端点名字</param>
        /// <returns></returns>
        private void SetEpointName(CommonDevice device, string epointName)
        {
            device.DeviceEpointName = epointName;
        }
 
        /// <summary>
        /// 单纯获取设备的Mac名字
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public string GetSimpleMacName(CommonDevice device)
        {
            return device.DeviceName;
        }
 
        /// <summary>
        /// 单纯获取设备的端点名字
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public string GetSimpleEpointName(CommonDevice device)
        {
            return device.DeviceEpointName;
        }
 
        /// <summary>
        /// 初始化R文件里面设备默认名字的ID
        /// </summary>
        private void InitDeviceDefultNameIDList()
        {
            if (this.dicDeviceAllNameID != null)
            {
                return;
            }
            this.dicDeviceAllNameID = new Dictionary<string, int>();
            Type type = typeof(R.MyInternationalizationString);
 
            var PropertyList = type.GetFields();
            foreach (var item in PropertyList)
            {
                if (item.Name.StartsWith(deviceModelIdName) == true
                    || item.Name.StartsWith("uDeviceBelongId") == true)
                {
                    this.dicDeviceAllNameID[item.Name] = Convert.ToInt32(item.GetValue(null));
                }
            }
 
            //初始化设备枚举
            this.InitDeviceModelIdEnum();
        }
 
        #endregion
 
        #region ■ 设置图标___________________________
 
        /// <summary>
        /// 变更设备的图标
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <param name="unSelPath">图片地址(非选择)</param>
        public void ChangedDeviceIcon(CommonDevice device, string unSelPath)
        {
            if (unSelPath == string.Empty)
            {
                return;
            }
            device.IconPath = unSelPath;
            device.IsCustomizeImage = true;
            device.ReSave();
 
            HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
        }
 
        /// <summary>
        /// 设置设备【图标】到指定的控件
        /// </summary>
        /// <param name="btnIcon">控件对象</param>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public void SetDeviceIconToControl(Button btnIcon, CommonDevice device)
        {
            if (device == null)
            {
                btnIcon.UnSelectedImagePath = "Device/ThirdPartyDevice.png";
                return;
            }
            string unSelectFilePath = string.Empty;
            string selectFilePath = string.Empty;
 
            //获取设备【图标】
            this.GetDeviceIcon(device, ref unSelectFilePath, ref selectFilePath);
            if (btnIcon.UnSelectedImagePath != unSelectFilePath)
            {
                btnIcon.UnSelectedImagePath = unSelectFilePath;
            }
            if (btnIcon.SelectedImagePath != selectFilePath)
            {
                btnIcon.SelectedImagePath = selectFilePath;
            }
        }
 
        /// <summary>
        /// 设置设备【图标】到指定的控件(注意,此函数设置的选择状态的图片是白色的)
        /// </summary>
        /// <param name="btnIcon">控件对象</param>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public void SetDeviceIconToControl2(Button btnIcon, CommonDevice device)
        {
            if (device == null)
            {
                btnIcon.UnSelectedImagePath = "Device/ThirdPartyDevice.png";
                return;
            }
            string unSelectFilePath = device.IconPath;
            string selectFilePath = unSelectFilePath.Replace(".png", "Selected2.png");
 
            //获取设备【图标】
            if (btnIcon.UnSelectedImagePath != unSelectFilePath)
            {
                btnIcon.UnSelectedImagePath = unSelectFilePath;
            }
            if (btnIcon.SelectedImagePath != selectFilePath)
            {
                btnIcon.SelectedImagePath = selectFilePath;
            }
        }
 
        /// <summary>
        /// 获取设备【图标】
        /// </summary>
        /// <param name="listdevice">设备对象</param>
        /// <param name="unSelectPath">图片地址</param>
        /// <param name="selectPath">图片地址</param>
        /// <returns></returns>
        public void GetDeviceIcon(CommonDevice device, ref string unSelectPath, ref string selectPath)
        {
            if (string.IsNullOrEmpty(device.IconPath) == true)
            {
                return;
            }
            unSelectPath = device.IconPath;
 
            string selPath = device.OnlineIconPath;
            if (string.IsNullOrEmpty(selPath) == false)
            {
                selectPath = selPath;
            }
        }
 
        /// <summary>
        /// 设置设备的真实图片到指定的控件
        /// </summary>
        /// <param name="btnIcon">控件对象</param>
        /// <param name="listdevice">设备对象</param>
        public void SetRealDeviceIconToControl(Button btnIcon, List<CommonDevice> listdevice)
        {
            //获取设备的真实图片
            string imagePath = this.GetRealDeviceIcon(listdevice);
            btnIcon.UnSelectedImagePath = imagePath;
        }
 
        /// <summary>
        /// 获取设备的真实图片
        /// </summary>
        /// <param name="listdevice">设备对象</param>
        public string GetRealDeviceIcon(List<CommonDevice> listdevice)
        {
            //获取它属于什么类型的设备
            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
            string strConcrete = Enum.GetName(typeof(DeviceConcreteType), myDeviceType.ConcreteType);
 
            //图片共有
            if (this.dicPictrueShard.ContainsKey(strConcrete) == true)
            {
                strConcrete = this.dicPictrueShard[strConcrete];
            }
 
            string strType = strConcrete.Replace("_", string.Empty);
            //将类型转为图片地址
            string imageFilePath = "RealDevice/" + strType + ".png";
            //这个图片本地是否存在?
            if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
            {
                //不存在则使用共通图片
                string[] arry = strConcrete.Split(new string[] { "_" }, StringSplitOptions.None);
                if (arry.Length == 1)
                {
                    //如果它自己就是共通图片的话,不再处理
                    return "RealDevice/CommonDevice.png";
                }
                imageFilePath = "RealDevice/" + arry[0] + ".png";
                //如果它自己的共通图片还是不存在的话,则直接使用所有设备的共通图片
                if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
                {
                    imageFilePath = "RealDevice/CommonDevice.png";
                }
            }
            return imageFilePath;
        }
 
        /// <summary>
        /// 设置【设备类型】的图标到指定的控件(此方法不能用在设备功能类型菜单的图标)
        /// </summary>
        /// <param name="btnIcon">控件对象</param>
        /// <param name="listdevice">设备对象</param>
        /// <returns></returns>
        public void SetDeviceObjectIconToControl(Button btnIcon, List<CommonDevice> listdevice)
        {
            //获取自定义设备类型
            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
 
            string imageUnSelectFilePath = string.Empty;
            string imageSelectFilePath = string.Empty;
 
            //获取【设备类型】的图标
            this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath);
 
            //设置图片
            btnIcon.UnSelectedImagePath = imageUnSelectFilePath;
            btnIcon.SelectedImagePath = imageSelectFilePath;
        }
 
        /// <summary>
        /// 获取【设备类型】的图标(此方法不能用在设备功能类型菜单的图标)
        /// </summary>
        /// <param name="listdevice">设备对象</param>
        /// <param name="unSelectPath">图片地址</param>
        /// <param name="selectPath">图片地址</param>
        /// <returns></returns>
        public void GetDeviceObjectIcon(List<CommonDevice> listdevice, ref string unSelectPath, ref string selectPath)
        {
            //获取自定义设备类型
            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
 
            //获取【设备类型】的图标
            this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath);
        }
 
        /// <summary>
        /// 获取【设备功能类型】的菜单图标
        /// </summary>
        /// <param name="specificType">自定义设备类型</param>
        /// <param name="unSelectPath">图片地址</param>
        /// <param name="selectPath">图片地址</param>
        /// <returns></returns>
        public void GetDeviceFunctionTypeMenuIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
        {
            //新风小模块
            if (specificType == DeviceConcreteType.Relay_FangyueFreshAirModul)
            {
                unSelectPath = "Device/FreshAirEpoint.png";
                selectPath = "Device/FreshAirEpointSelected.png";
                return;
            }
            //PM2.5空气质量传感器
            else if (specificType == DeviceConcreteType.Sensor_PMTwoPointFive)
            {
                unSelectPath = "Device/AirQualitySensorEpoint.png";
                selectPath = "Device/AirQualitySensorEpointSelected.png";
                return;
            }
            //上面需要特殊处理
 
            //获取【设备类型】的图标
            this.GetDeviceObjectIcon(specificType, ref unSelectPath, ref selectPath);
        }
 
        /// <summary>
        /// 获取【设备类型】的图标 2020.05.13:次函数不再公开
        /// </summary>
        /// <param name="specificType">自定义设备类型</param>
        /// <param name="unSelectPath">图片地址</param>
        /// <param name="selectPath">图片地址</param>
        /// <returns></returns>
        private void GetDeviceObjectIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
        {
            //将具体类型转字符串
            string strSpecific = Enum.GetName(typeof(DeviceConcreteType), specificType);
            //图片共有
            if (this.dicPictrueShard.ContainsKey(strSpecific) == true)
            {
                strSpecific = this.dicPictrueShard[strSpecific];
            }
 
            string strType = strSpecific.Replace("_", string.Empty);
            //将类型转为图片地址
            string imageFilePath = "Device/" + strType + ".png";
            string imageSelectFilePath = "Device/" + strType + "Selected.png";
 
            //这个图片本地是否存在?
            if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
            {
                //不存在则使用共通图片
                string[] arry = strSpecific.Split(new string[] { "_" }, StringSplitOptions.None);
                //如果它自己就是共通图片的话,不再处理
                if (arry.Length > 1)
                {
                    imageFilePath = "Device/" + arry[0] + ".png";
                    imageSelectFilePath = "Device/" + arry[0] + "Selected.png";
                }
            }
            //如果那款设备连共通图片都没有的话
            if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
            {
                imageFilePath = "Device/ThirdPartyDevice.png";
                imageSelectFilePath = "Device/ThirdPartyDeviceSelected.png";
            }
            //设置图片
            unSelectPath = imageFilePath;
            selectPath = imageSelectFilePath;
        }
 
        #endregion
 
        #region ■ 获取自定义的设备类型_______________
 
        /// <summary>
        /// 获取【自定义的设备类型】,两种类型都设置了
        /// </summary>
        /// <param name="listdevice">设备对象</param>
        /// <returns></returns>
        public DeviceEnumInfo GetMyDeviceEnumInfo(List<CommonDevice> listdevice)
        {
            CommonDevice checkDevice = listdevice[0];
            foreach (var temp in listdevice)
            {
                //拿拥有模块ID的那个回路来判断
                if (temp.ModelIdentifier != string.Empty)
                {
                    checkDevice = temp;
                }
            }
 
            //获取河东设备的设备类型
            DeviceEnumInfo info = this.GetHdlMyDeviceEnumInfo(checkDevice);
            if (info != null)
            {
                return info;
            }
            //获取第三方设备的【设备类型】
            info = this.GetNotHdlMyDeviceEnumInfo(listdevice);
            //这里再次判断是否是河东设备,有可能它的模块ID写错了
            info.IsHdlDevice = this.IsHdlDevice(checkDevice);
 
            return info;
        }
 
        /// <summary>
        /// 获取设备的【设备类型】的翻译文本(优先镜像)
        /// </summary>
        /// <param name="listDevice"></param>
        /// <param name="ApendFalge">第三方或者虚拟设备的时候,是否添加标识</param>
        /// <returns></returns>
        public string GetDeviceObjectText(List<CommonDevice> listDevice, bool ApendFalge = true)
        {
            CommonDevice checkDevice = listDevice[0];
            foreach (var temp in listDevice)
            {
                //拿拥有模块ID的那个回路来判断
                if (temp.ModelIdentifier != string.Empty)
                {
                    checkDevice = temp;
                }
            }
            //获取自定义设备类型
            var myInfoType = this.GetMyDeviceEnumInfo(listDevice);
            //获取设备类型的翻译名字
            string strName = Language.StringByID(myInfoType.ObjectTypeNameId);
            if (strName == string.Empty)
            {
                //加一层保险,未知设备
                strName = Language.StringByID(R.MyInternationalizationString.UnknowDevice);
            }
 
            if (ApendFalge == true)
            {
                if (listDevice[0].DriveCode > 0)
                {
                    //虚拟设备加个标识
                    strName += "✩";
                }
                else
                {
                    foreach (var temp in listDevice)
                    {
                        //拿拥有模块ID的那个回路来判断
                        if (temp.ModelIdentifier != string.Empty)
                        {
                            if (this.IsHdlDevice(checkDevice) == false)
                            {
                                //第三方设备加个标识
                                strName += "★";
                                break;
                            }
                        }
                    }
                }
            }
            return strName;
        }
 
        #endregion
 
        #region ■ 获取河东设备的设备类型_____________
 
        /// <summary>
        /// 获取Hdl设备的【自定义的设备类型】
        /// </summary>
        /// <param name="device">随便某一回路</param>
        /// <returns></returns>
        private DeviceEnumInfo GetHdlMyDeviceEnumInfo(CommonDevice device)
        {
            //设备具体类型
            var info = new DeviceEnumInfo();
            info.IsHdlDevice = this.IsHdlDevice(device);
            if (device.ModelIdentifier == string.Empty)
            {
                return null;
            }
            string modelKeys = device.ModelIdentifier;
            //交换一下模块ID(麦乐克那边的传感器)
            this.ChangedDeviceModeId(ref modelKeys);
 
            if (this.dicDeviceModelIdEnum.ContainsKey(modelKeys) == false)
            {
                //没有匹配到模块ID,则直接走第三方设备的判断
                return null;
            }
 
            string[] strValue = this.dicDeviceModelIdEnum[modelKeys].Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
            int ConcreteValue = Convert.ToInt32(strValue[0]);
            int BeloneValue = Convert.ToInt32(strValue[1]);
            //设置设备的【设备所属类型】
            info.BeloneType = (DeviceBeloneType)BeloneValue;
            if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + BeloneValue) == true)
            {
                //设备所属类型的翻译名字
                info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + BeloneValue];
            }
 
            //设备具体类型
            info.ConcreteType = (DeviceConcreteType)ConcreteValue;
            if (info.ConcreteType.ToString() == ConcreteValue.ToString())
            {
                info.ConcreteType = DeviceConcreteType.UnKownDevice;
            }
            string keyName = deviceModelIdName + ConcreteValue;
            if (this.dicDeviceAllNameID.ContainsKey(keyName) == true)
            {
                //设备的官方名称
                info.ConcreteTextId = this.dicDeviceAllNameID[keyName];
            }
 
            //设备的类型翻译名称
            info.ObjectTypeNameId = Convert.ToInt32(strValue[2]);
 
            return info;
        }
 
        #endregion
 
        #region ■ 获取第三方设备的设备类型___________
 
        /// <summary>
        /// 获取设备的【所属类型信息】,此方法会把所有的传感器都归为【传感器】(包括温湿度传感器)
        /// </summary>
        /// <param name="device">设备回路</param>
        /// <returns></returns>
        public DeviceEnumInfo GetDeviceBelongEnumInfo(CommonDevice device)
        {
            var info = this.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (info.BeloneType == DeviceBeloneType.A调光器
                || info.BeloneType == DeviceBeloneType.A彩灯)
            {
                //归为灯光
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                info.BeloneType = DeviceBeloneType.A灯光;
                info.ConcreteType = DeviceConcreteType.Light;
                info.ObjectTypeNameId = 60007;//调光模块
 
                int value = (int)info.BeloneType;
                if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
                {
                    //设备所属类型的翻译名字
                    info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
                }
            }
            else if (info.BeloneType == DeviceBeloneType.A传感器
                || device.Type == DeviceType.TemperatureSensor)
            {
                //传感器合并
                info.BeloneType = DeviceBeloneType.A传感器;
                info.ConcreteType = DeviceConcreteType.Sensor;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
                info.ObjectTypeNameId = 60000;//传感器
 
                int value = (int)info.BeloneType;
                if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
                {
                    //设备所属类型的翻译名字
                    info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
                }
            }
 
            return info;
        }
 
        /// <summary>
        /// 获取第三方设备的【设备类型】(不建议使用)
        /// </summary>
        /// <param name="listdevice">Mac都一样的设备列表</param>
        /// <returns></returns>
        public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice)
        {
            var dicType = new Dictionary<DeviceType, CommonDevice>();
            foreach (CommonDevice device in listdevice)
            {
                if (dicType.ContainsKey(device.Type) == false)
                {
                    dicType[device.Type] = device;
                }
            }
            var info = new DeviceEnumInfo();
            info.IsHdlDevice = false;
            //1包含面板的话,当面板处理
            if (dicType.ContainsKey(DeviceType.OnOffSwitch) == true)
            {
                if (listdevice.Count > 1)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId200;
                    info.BeloneType = DeviceBeloneType.A按键面板;
                    info.ConcreteType = DeviceConcreteType.ButtonPanel;
                }
                else
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId16;
                    info.BeloneType = DeviceBeloneType.A干接点;
                    info.ConcreteType = DeviceConcreteType.DryContact;
                }
                info.ObjectTypeNameId = 60003;//智能面板
            }
            //3包含窗帘的话,当窗帘处理
            else if (dicType.ContainsKey(DeviceType.WindowCoveringDevice) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId100;
                info.BeloneType = DeviceBeloneType.A窗帘;
                info.ConcreteType = DeviceConcreteType.Curtain;
                info.ObjectTypeNameId = 60002;//遮阳模块
            }
            //4空气开关
            else if (dicType.ContainsKey(DeviceType.AirSwitch) == true)
            {
                //默认值
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4100;
                info.BeloneType = DeviceBeloneType.A开关;
                info.ConcreteType = DeviceConcreteType.AirSwitch;
                info.ObjectTypeNameId = 60001;//开关模块
 
                if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A开关)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
                    info.BeloneType = DeviceBeloneType.A开关;
                    info.ConcreteType = DeviceConcreteType.Switch;
                }
                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A插座)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
                    info.BeloneType = DeviceBeloneType.A插座;
                    info.ConcreteType = DeviceConcreteType.Socket1;
                }
                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A灯光)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                    info.BeloneType = DeviceBeloneType.A灯光;
                    info.ConcreteType = DeviceConcreteType.Light;
                }
            }
            //5继电器
            else if (dicType.ContainsKey(DeviceType.OnOffOutput) == true)
            {
                //默认值
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2300;
                info.BeloneType = DeviceBeloneType.A继电器;
                info.ConcreteType = DeviceConcreteType.Relay;
                info.ObjectTypeNameId = 60001;//开关模块
 
                if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A开关)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
                    info.BeloneType = DeviceBeloneType.A开关;
                    info.ConcreteType = DeviceConcreteType.Switch;
                }
                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A插座)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
                    info.BeloneType = DeviceBeloneType.A插座;
                    info.ConcreteType = DeviceConcreteType.Socket1;
                }
                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A灯光)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                    info.BeloneType = DeviceBeloneType.A灯光;
                    info.ConcreteType = DeviceConcreteType.Light;
                }
            }
            //6调光器
            else if (dicType.ContainsKey(DeviceType.DimmableLight) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2500;
                info.BeloneType = DeviceBeloneType.A调光器;
                info.ConcreteType = DeviceConcreteType.DimmableLight;
                info.ObjectTypeNameId = 60007;//调光模块
            }
            //7彩灯
            else if (dicType.ContainsKey(DeviceType.ColorDimmableLight) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId9;
                info.BeloneType = DeviceBeloneType.A彩灯;
                info.ConcreteType = DeviceConcreteType.ColorLight;
                info.ObjectTypeNameId = 60007;//调光模块
            }
            //8空调
            else if (dicType.ContainsKey(DeviceType.Thermostat) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId3600;
                info.BeloneType = DeviceBeloneType.A空调;
                info.ConcreteType = DeviceConcreteType.AirConditioner;
                info.ObjectTypeNameId = 60009;//空调模块
            }
            //9中继器
            else if (dicType.ContainsKey(DeviceType.Repeater) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId3900;
                info.BeloneType = DeviceBeloneType.A中继器;
                info.ConcreteType = DeviceConcreteType.Repeater;
                info.ObjectTypeNameId = 60006;//系统设备
            }
            //10转换器
            else if (dicType.ContainsKey(DeviceType.Transverter) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4200;
                info.BeloneType = DeviceBeloneType.A转换器;
                info.ConcreteType = DeviceConcreteType.Converter;
                info.ObjectTypeNameId = 60008;//转换器
            }
            //11智能门锁
            else if (dicType.ContainsKey(DeviceType.DoorLock) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2800;
                info.BeloneType = DeviceBeloneType.A智能门锁;
                info.ConcreteType = DeviceConcreteType.IntelligentLocks;
                info.ObjectTypeNameId = 60010;//智能门锁
            }
            //12包含传感器的话,当传感器处理
            else if (dicType.ContainsKey(DeviceType.IASZone) == true)
            {
                info.BeloneType = DeviceBeloneType.A传感器;
                info.ConcreteType = DeviceConcreteType.Sensor;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
                info.ObjectTypeNameId = 60000;//传感器
                //设置传感器具体的类型
                this.SetSensorDeviceSpecificType(ref info, listdevice);
            }
            //13包含温度传感器的话
            else if (dicType.ContainsKey(DeviceType.TemperatureSensor) == true)
            {
                bool temperatrue = false;
                bool humidity = false;
                //获取全部的回路
                var listTemp = this.GetDevicesByMac(listdevice[0].DeviceAddr, false);
                foreach (var device in listTemp)
                {
                    if (device is TemperatureSensor)
                    {
                        //温度传感器
                        if (((TemperatureSensor)device).SensorDiv == 1)
                        {
                            temperatrue = true;
                        }
                        //湿度传感器
                        else if (((TemperatureSensor)device).SensorDiv == 2)
                        {
                            humidity = true;
                        }
                    }
                }
                if (temperatrue == true && humidity == true)
                {
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A温湿度传感器;
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId10;
                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity;
                }
                else if (temperatrue == true && humidity == false)
                {
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A温度传感器;
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId11;
                    info.ConcreteType = DeviceConcreteType.Sensor_Temperature;
                }
                else if (temperatrue == false && humidity == true)
                {
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A湿度传感器;
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId12;
                    info.ConcreteType = DeviceConcreteType.Sensor_Humidity;
                }
                info.ObjectTypeNameId = 60000;//传感器
            }
            //14新风设备
            else if (dicType.ContainsKey(DeviceType.FreshAir) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId2310;
                info.BeloneType = DeviceBeloneType.A新风;
                info.ConcreteType = DeviceConcreteType.Relay_FangyueFreshAirModul;
                info.ObjectTypeNameId = 60011;//新风
            }
            //15 PM2.5传感器设备
            else if (dicType.ContainsKey(DeviceType.PMSensor) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1307;
                info.BeloneType = DeviceBeloneType.APM2点5空气质量传感器;
                info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive;
                info.ObjectTypeNameId = 60000;//传感器
            }
            //16色温灯
            else if (dicType.ContainsKey(DeviceType.ColorTemperatureLight) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId20000;
                info.BeloneType = DeviceBeloneType.A彩灯;
                info.ConcreteType = DeviceConcreteType.ColorLight_Temperature;
                info.ObjectTypeNameId = 60007;//调光模块
            }
 
            int value = (int)info.BeloneType;
            if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
            {
                //设备所属类型的翻译名字
                info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
            }
 
            return info;
        }
 
        #endregion
 
        #region ■ 传感器具体的类型___________________
 
        /// <summary>
        /// 设置传感器具体的类型
        /// </summary>
        /// <param name="info">自定义设备枚举信息</param>
        /// <param name="listdevice">设备对象</param>
        private void SetSensorDeviceSpecificType(ref DeviceEnumInfo info, List<CommonDevice> listdevice)
        {
            //如果这个设备拥有多个回路的话,我也不知道怎么命名,只能给个默认名字
            if (listdevice.Count > 1)
            {
                return;
            }
            var iasZone = (IASZone)listdevice[0];
            if (iasZone.IasDeviceType == 13)
            {
                //运动传感器
                info.ConcreteType = DeviceConcreteType.Sensor_Motion;
                info.ConcreteTextId = R.MyInternationalizationString.uMotionSensor;
            }
            else if (iasZone.IasDeviceType == 40)
            {
                //烟雾传感器
                info.ConcreteType = DeviceConcreteType.Sensor_Fire;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1302;
            }
            else if (iasZone.IasDeviceType == 42)
            {
                //水侵传感器
                info.ConcreteType = DeviceConcreteType.Sensor_Water;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1304;
            }
            else if (iasZone.IasDeviceType == 43)
            {
                //燃气传感器
                info.ConcreteType = DeviceConcreteType.Sensor_CarbonMonoxide;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1300;
            }
            else if (iasZone.IasDeviceType == 44)
            {
                //紧急按钮
                info.ConcreteType = DeviceConcreteType.Sensor_EmergencyButton;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1305;
            }
            else if (iasZone.IasDeviceType == 277)
            {
                //钥匙扣
                info.ConcreteType = DeviceConcreteType.Sensor_Keyfob;
                info.ConcreteTextId = R.MyInternationalizationString.uKeyfob;
            }
            else if (iasZone.IasDeviceType == 21 || iasZone.IasDeviceType == 22)
            {
                //门窗传感器
                info.ConcreteType = DeviceConcreteType.Sensor_DoorWindow;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1301;
            }
            else if (iasZone.IasDeviceType == 541)
            {
                //球型移动传感器
                info.ConcreteType = DeviceConcreteType.Sensor_SphericalMotion;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1205;
            }
        }
 
        #endregion
 
        #region ■ 物理设备所属房间___________________
 
        /// <summary>
        /// 初始化物理设备所属房间的记录
        /// </summary>
        private void InitRealDeviceRoomId()
        {
            this.dicDeviceRoomId = new Dictionary<string, string>();
            string fullName = DirNameResourse.DeviceRoomIdFile;
            var strData = HdlFileLogic.Current.ReadFileTextContent(fullName);
            if (strData != null)
            {
                this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData);
            }
        }
 
        /// <summary>
        /// 获取全部物理设备所属房间的记录
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, string> GetAllRealDeviceRoomData()
        {
            return this.dicDeviceRoomId;
        }
 
        /// <summary>
        /// 保存物理设备所属房间的记录
        /// </summary>
        /// <param name="listDevice">需要保存的设备对象</param>
        /// <param name="roomId">需要保存的哪个设备的房间ID</param>
        /// <param name="saveRoadDevice">如果只有一个回路,是否把回路的房间一起修改</param>
        public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true)
        {
            if (listDevice == null)
            {
                return;
            }
            //如果设备只有一个回路,如果改变了真实设备区域,则它的回路的区域也一起改了
            if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
            {
                if (listDevice[0] is OTADevice)
                {
                    //单纯只是Ota设备则不处理
                    return;
                }
                HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
            }
            bool save = false;
            if (roomId == string.Empty)
            {
                //选择的是未分配
                this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr);
                save = true;
            }
            else
            {
                if (this.dicDeviceRoomId.ContainsKey(listDevice[0].DeviceAddr) == false)
                {
                    this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
                    save = true;
                }
                else
                {
                    //2020.05.18追加:如果记录的房间ID是不存在的话,则重新覆盖
                    var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]);
                    if (room == null || this.dicDeviceRoomId[listDevice[0].DeviceAddr] != roomId)
                    {
                        this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
                        save = true;
                    }
                }
            }
 
            if (save == true)
            {
                //保存记录
                HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
 
                //添加自动备份
                HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
            }
        }
 
        /// <summary>
        /// 获取真实物理设备的房间名字
        /// </summary>
        /// <param name="device">设备的某一个回路</param>
        /// <returns></returns>
        public string GeteRealDeviceRoomName(CommonDevice device)
        {
            if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false)
            {
                //未分配区域
                return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
            }
            var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
            return HdlRoomLogic.Current.GetRoomName(room);
        }
 
        /// <summary>
        /// 获取真实物理设备属于哪个房间
        /// </summary>
        /// <param name="device">设备的某一个回路</param>
        /// <returns></returns>
        public Room GeteRealDeviceRoom(CommonDevice device)
        {
            if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false)
            {
                return null;
            }
            return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
        }
 
        /// <summary>
        /// 将真实物理设备从房间中移除
        /// </summary>
        /// <param name="device">随便一个回路</param>
        public void DeleteRealDeviceFromRoom(CommonDevice device)
        {
            //将真实物理设备从房间中移除
            this.DeleteRealDeviceFromRoom(new List<string>() { device.DeviceAddr });
        }
 
        /// <summary>
        /// 将真实物理设备从房间中移除
        /// </summary>
        /// <param name="listMac">设备Mac地址</param>
        public void DeleteRealDeviceFromRoom(List<string> listMac)
        {
            bool save = false;
            foreach (var deviceMacAddr in listMac)
            {
                if (this.dicDeviceRoomId.ContainsKey(deviceMacAddr) == true)
                {
                    this.dicDeviceRoomId.Remove(deviceMacAddr);
                    save = true;
                }
            }
            if (save == false)
            {
                //没有改变,不需要保存
                return;
            }
            //保存记录
            HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
 
            //添加自动备份
            HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
        }
 
        /// <summary>
        /// 根据房间ID,移除指定的真实物理设备的所属房间记录
        /// </summary>
        /// <param name="i_RoomId"></param>
        public void DeleteRealDeviceByRoomId(string i_RoomId)
        {
            var listDeleteKey = new List<string>();
            foreach (var deviceAddr in this.dicDeviceRoomId.Keys)
            {
                if (this.dicDeviceRoomId[deviceAddr] == i_RoomId
                    && listDeleteKey.Contains(deviceAddr) == false)
                {
                    listDeleteKey.Add(deviceAddr);
                }
            }
            //将真实物理设备从房间中移除
            this.DeleteRealDeviceFromRoom(listDeleteKey);
        }
 
        #endregion
 
        #region ■ 设备排序___________________________
 
        /// <summary>
        /// 设备排序
        /// </summary>
        /// <param name="i_listDevice">请确保这个东西已经按mac和端点排序了</param>
        /// <returns></returns>
        public List<CommonDevice> SortDeviceByBelongType(List<CommonDevice> i_listDevice)
        {
            //获取排序规则
            var listRule = this.GetBelongTypeSortRule();
            var dicDevice = new Dictionary<DeviceBeloneType, List<CommonDevice>>();
            dicDevice[DeviceBeloneType.A未知设备] = new List<CommonDevice>();
 
            foreach (var device in i_listDevice)
            {
                //获取所属类型
                var typeInfo = this.GetDeviceBelongEnumInfo(device);
                if (listRule.Contains(typeInfo.BeloneType) == false)
                {
                    //不在排序范围内,都丢在最后面
                    dicDevice[DeviceBeloneType.A未知设备].Add(device);
                    continue;
                }
                if (dicDevice.ContainsKey(typeInfo.BeloneType) == false)
                {
                    dicDevice[typeInfo.BeloneType] = new List<CommonDevice>();
                }
                dicDevice[typeInfo.BeloneType].Add(device);
            }
 
            var listSort = new List<CommonDevice>();
            foreach (var myType in listRule)
            {
                //根据规则顺序,添加设备
                if (dicDevice.ContainsKey(myType) == false || dicDevice[myType].Count == 0)
                {
                    continue;
                }
                listSort.AddRange(dicDevice[myType]);
            }
 
            return listSort;
        }
 
        /// <summary>
        /// 获取设备所属类型的的排序规则
        /// </summary>
        /// <returns></returns>
        public HashSet<DeviceBeloneType> GetBelongTypeSortRule()
        {
            //谁在前面,谁就优先显示
            var list = new HashSet<DeviceBeloneType>();
            list.Add(DeviceBeloneType.A灯光);
            list.Add(DeviceBeloneType.A彩灯);
            list.Add(DeviceBeloneType.A开关);
            list.Add(DeviceBeloneType.A插座);
            list.Add(DeviceBeloneType.A调光器);
            list.Add(DeviceBeloneType.A窗帘);
            list.Add(DeviceBeloneType.A新风);
            list.Add(DeviceBeloneType.A空调);
            list.Add(DeviceBeloneType.A继电器);
            list.Add(DeviceBeloneType.A干接点);
            list.Add(DeviceBeloneType.A智能门锁);
            list.Add(DeviceBeloneType.A智能空开);
            list.Add(DeviceBeloneType.A传感器);
 
            //其他的看着办呗,都是排在后面的,都归为这个属性
            list.Add(DeviceBeloneType.A未知设备);
            
            return list;
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 从缓存变量检测设备是否在线
        /// </summary>
        /// <param name="i_device"></param>
        /// <returns></returns>
        public bool CheckDeviceIsOnline(CommonDevice i_device)
        {
            var listDevice = this.GetDevicesByMac(i_device.DeviceAddr, false);
            foreach (var device in listDevice)
            {
                //0:离线 1:在线 2:正在刷新状态 
                bool statu = i_device.IsOnline == 1 || i_device.IsOnline == 2;
                if (statu == true)
                {
                    //有一个回路在线,即在线
                    return true;
                }
            }
            return false;
        }
 
        /// <summary>
        /// 判断该设备是否可以显示在主页
        /// </summary>
        /// <param name="i_device"></param>
        /// <returns></returns>
        public bool CanShowInHomeHomeMainPage(CommonDevice i_device)
        {
            if (i_device == null || i_device.Type == DeviceType.OnOffSwitch)//干接点
            {
                //这个设备不见了
                return false;
            }
            if (i_device.Type == DeviceType.OnOffOutput || i_device.Type == DeviceType.AirSwitch)
            {
                //2020.03.23追加式样:未指定类型的继电器,不显示
                if (i_device.DfunctionType == DeviceFunctionType.A未定义
                    || i_device.DfunctionType == DeviceFunctionType.A不指定)
                {
                    return false;
                }
            }
            //2020.03.30追加式样:如果是面板的温度探头,不显示
            else if (i_device.Type == DeviceType.TemperatureSensor && ((TemperatureSensor)i_device).SensorDiv == 1)
            {
                var myInfoType = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
                if (myInfoType.BeloneType == DeviceBeloneType.A按键面板)
                {
                    return false;
                }
            }
            else if (i_device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //新风的湿度传感器不显示
                return false;
            }
 
            //如果是新风面板或环境面板,则都不显示任何回路
            var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
            if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir || myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
            {
                return false;
            }
            else if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
            {
                if (i_device.Type != DeviceType.OnOffOutput)
                {
                    return false;
                }
            }
            return true;
        }
 
        /// <summary>
        /// 判断是不是河东的设备
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool IsHdlDevice(CommonDevice device)
        {
            return device.ManufacturerName == "HDL";
        }
 
        /// <summary>
        /// 是否是Mini夜灯
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool IsMiniLight(CommonDevice device)
        {
            return device.DriveCode != 0 && device.Type == DeviceType.ColorTemperatureLight;
        }
 
        /// <summary>
        /// 获取设备的唯一主键
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public string GetDeviceMainKeys(CommonDevice device)
        {
            return this.GetDeviceMainKeys(device.DeviceAddr, device.DeviceEpoint);
        }
 
        /// <summary>
        /// 获取设备的唯一主键
        /// </summary>
        /// <param name="DeviceAddr">MAC地址</param>
        /// <param name="DeviceEpoint">端口号</param>
        /// <returns></returns>
        public string GetDeviceMainKeys(string DeviceAddr, int DeviceEpoint)
        {
            return DeviceAddr + "_" + DeviceEpoint;
        }
 
        /// <summary>
        /// 交换设备的模块ID
        /// </summary>
        /// <param name="modeId">模块ID</param>
        /// <returns></returns>
        public bool ChangedDeviceModeId(ref string modeId)
        {
            if (this.dicDeviceModelIdChanged.ContainsKey(modeId) == false)
            {
                return false;
            }
            modeId = this.dicDeviceModelIdChanged[modeId];
 
            return true;
        }
 
        /// <summary>
        /// 附加设备的版本代号(返回Ver.XXX)
        /// </summary>
        /// <param name="versionValue">版本号</param>
        /// <returns></returns>
        public string AppendVersion(int versionValue)
        {
            //10101 3个byte  显示为:ver.1.01.01
            //中间那个byte为奇数时,代表是测试版本,在显示最新版本时,不需要显示,但是在历史版本那里可以显示
            //中间那个byte为偶数时, 代表是正式版本
 
            //直接是10进制
            string txt10 = Convert.ToString(versionValue).PadLeft(6, '0');
            //这个是第一位
            int value1 = Convert.ToInt32(txt10.Substring(0, 2));
            //这个是第二位
            string value2 = txt10.Substring(2, 2);
            //这个是第三位
            string value3 = txt10.Substring(4, 2);
 
            //Ver.
            string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation);
            return ver + value1 + "." + value2 + "." + value3;
        }
 
        /// <summary>
        /// 显示错误信息窗口
        /// </summary>
        /// <param name="msg"></param>
        private void ShowErrorMsg(string msg)
        {
            Application.RunOnMainThread(() =>
            {
                var contr = new ShowMsgControl(ShowMsgType.Error, msg);
                contr.Show();
            });
        }
 
        /// <summary>
        /// 显示Tip信息窗口
        /// </summary>
        /// <param name="msg"></param>
        private void ShowTipMsg(string msg)
        {
            Application.RunOnMainThread(() =>
            {
                var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
                contr.Show();
            });
        }
 
        #endregion
 
        //----------------------------------分割线(自定义接口)---------------------------------------------
 
        #region ■ 获取设备列表的接口_________________
 
        /// <summary>
        /// <para>从网关重新获取设备列表(返回的设备为虚拟出来的)</para>
        /// <para>statu状态 -1:异常,会返回null, 1:没有异常, 2:数据接收不全</para>
        /// </summary>
        /// <param name="zbGateway">网关对象</param>
        /// <param name="statu">状态-> -1:异常,会返回null, 1:没有异常, 2:数据接收不全</param>
        /// <param name="ignoreTime">是否无视时间(此变量是给获取在线状态用的),true:每次调用都去网关获取,false:3分钟内返回的是本地的设备</param>
        /// <param name="mode">是否显示错误</param>
        /// <returns></returns>
        public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool ignoreTime, ShowErrorMode mode = ShowErrorMode.YES)
        {
            if (ignoreTime == false)
            {
                if ((DateTime.Now - zbGateway.LastDateTime).TotalMilliseconds < 3 * 60 * 1000)
                {
                    //不无视时间,返回本地设备列表
                    statu = 1;
                    return this.GetDeviceByGatewayID(zbGateway.GwId);
                }
            }
            zbGateway.LastDateTime = DateTime.Now;
 
            //如果切换到了别的界面,则不显示错误信息
            string nowFormId = UserCenterResourse.NowActionFormID;
 
            ZbGateway realWay = null;
            if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, zbGateway) == false)
            {
                if (nowFormId == UserCenterResourse.NowActionFormID && mode == ShowErrorMode.YES)
                {
                    //错误:网关对象丢失
                    string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
                    this.ShowTipMsg(msg);
                }
                statu = -1;
                return null;
            }
 
            //是否达成中断的时机
            bool canBreak = false;
            //网关ID
            string gatewayID = zbGateway.GwId;
            //超时时间
            int TimeOut = 0;
            //设备总数
            int deviceCount = -1;
            //接收数
            int receiveCount = 0;
            //设备列表
            var listDevice = new List<CommonDevice>();
            //网关里面有可能会有重复的回路
            var listCheck = new HashSet<string>();
            Action<string, string> getDeviceAction = (topic, message) =>
            {
                if (topic == gatewayID + "/DeviceInfoRespon")
                {
                    try
                    {
                        lock (listDevice)
                        {
                            //设备接收数
                            receiveCount++;
 
                            TimeOut = 0;
                            var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
                            var totalNum = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["TotalNum"].ToString());
                            if (totalNum == 0)
                            {
                                //这个网关没有设备
                                canBreak = true;
                                return;
                            }
                            if (deviceCount == -1)
                            {
                                //设置需要接收多少个设备
                                deviceCount = totalNum;
                            }
 
                            var deviceID = (DeviceType)jobject.Value<int>("Device_ID");
                            //根据设备类型创建设备对象的实例
                            var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, zbGateway);
                            if (device != null)
                            {
                                string mainkeys = this.GetDeviceMainKeys(device);
                                //网关里面有可能会有重复的回路
                                if (listCheck.Contains(mainkeys) == false)
                                {
                                    listDevice.Add(device);
                                    listCheck.Add(mainkeys);
                                    //刷新一下本地缓存
                                    var localDevice = this.GetDevice(mainkeys);
                                    if (localDevice != null)
                                    {
                                        //刷新属性
                                        this.SetDeviceInfoToMain(localDevice, device);
                                    }
                                }
                            }
                        }
                    }
                    //Log出力
                    catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
 
                    if (receiveCount == deviceCount && deviceCount != -1)
                    {
                        //设备全部接收完成
                        canBreak = true;
                    }
                }
                else if (topic == gatewayID + "/DeviceInfoResponEnd")
                {
                }
            };
 
            realWay.Actions += getDeviceAction;
            try
            {
                var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
                realWay.Send("GetDeviceInfo", jObject.ToString());
            }
            catch { canBreak = true; }
 
            while (canBreak == false && TimeOut < 60)
            {
                System.Threading.Thread.Sleep(100);
                TimeOut++;
            }
 
            realWay.Actions -= getDeviceAction;
            getDeviceAction = null;
 
            if (TimeOut >= 60)
            {
                if (listDevice.Count == 0)
                {
                    if (nowFormId == UserCenterResourse.NowActionFormID && mode == ShowErrorMode.YES)
                    {
                        //获取设备列表失败
                        //[XXXX]网关回复超时,请稍后再试
                        string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceListFail);
                        msg += "\r\n[" + HdlGatewayLogic.Current.GetGatewayName(zbGateway).ToString() + "]";
                        msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时", false);
                        this.ShowTipMsg(msg);
                    }
                    statu = -1;
                    return null;
                }
                else
                {
                    if (nowFormId == UserCenterResourse.NowActionFormID && mode == ShowErrorMode.YES)
                    {
                        //网络不稳定,设备列表信息缺损
                        string msg = Language.StringByID(R.MyInternationalizationString.uNetworkUnStableAndDeviceInfoIsNotFull);
                        this.ShowTipMsg(msg);
                    }
                    statu = 2;
                }
            }
            else
            {
                statu = 1;
            }
            return listDevice;
        }
 
        #endregion
 
        #region ■ 创建新设备对象相关_________________
 
        /// <summary>
        /// 根据设备类型创建设备对象的实例
        /// </summary>
        /// <param name="deviceType">设备类型</param>
        /// <param name="jobject">主题Data</param>
        /// <param name="zbGateway">网关对象</param>
        /// <returns></returns>
        private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, ZbGateway zbGateway)
        {
            string gwId = zbGateway.GwId;
 
            //根据设备类型创建设备对象的实例
            CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType);
            if (device == null)
            {
                return null;
            }
 
            //设置设备属性类
            device.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(jobject["Data"].ToString());
            if (device.DeviceInfo == null)
            {
                return null;
            }
            this.SetMacName(device, string.Empty);
            this.SetEpointName(device, string.Empty);
 
            //设置设备主键类
            this.SetNewDeviceMainKeys(device, jobject);
            device.CurrentGateWayId = gwId;
 
            //将DeviceInfo的属性设置到主属性中
            this.SetDeviceInfoToMain(device, device);
 
            return device;
        }
 
        /// <summary>
        /// 将DeviceInfo的属性设置到主属性中
        /// </summary>
        /// <param name="mainDevice">主设备对象</param>
        /// <param name="device">设置源设备对象</param>
        public void SetDeviceInfoToMain(CommonDevice mainDevice, CommonDevice device)
        {
            if (string.IsNullOrEmpty(device.DeviceInfo.MacName) == false)
            {
                mainDevice.DeviceName = device.DeviceInfo.MacName;
            }
            if (string.IsNullOrEmpty(device.DeviceInfo.DeviceName) == false)
            {
                mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName;
            }
            mainDevice.CurrentGateWayId = device.CurrentGateWayId;
            mainDevice.ZigbeeType = device.DeviceInfo.ZigbeeType;
            mainDevice.IsOnline = device.DeviceInfo.IsOnline;
            mainDevice.DriveCode = device.DeviceInfo.DriveCode;
            mainDevice.IasDeviceType = device.DeviceInfo.DeviceType;
            mainDevice.Profile = device.DeviceInfo.Profile;
            mainDevice.Type = device.Type;
 
            //固件版本
            mainDevice.ImgVersion = device.DeviceInfo.ImgVersion;
            //硬件版本
            mainDevice.HwVersion = device.DeviceInfo.HwVersion;
            //镜像ID
            mainDevice.ImgTypeId = device.DeviceInfo.ImgTypeId;
            //厂商名称
            mainDevice.ManufacturerName = device.DeviceInfo.ManufacturerName;
            //模块ID
            mainDevice.ModelIdentifier = device.DeviceInfo.ModelIdentifier;
            //序列号
            mainDevice.SerialNumber = device.DeviceInfo.ProductCode;
            //设备功能类型
            mainDevice.DfunctionType = (DeviceFunctionType)device.DeviceInfo.FunctionType;
 
            mainDevice.InClusterList.Clear();
            mainDevice.InClusterList.AddRange(device.DeviceInfo.InClusterList);
            mainDevice.OutClusterList.Clear();
            mainDevice.OutClusterList.AddRange(device.DeviceInfo.OutClusterList);
 
            //如果是温度传感器
            if (mainDevice.Type == DeviceType.TemperatureSensor)
            {
                //输出族 1026:温度传感器 1029:湿度传感器
                foreach (var data in mainDevice.OutClusterList)
                {
                    if (data.OutCluster == 1029)
                    {
                        ((TemperatureSensor)mainDevice).SensorDiv = 2;
                    }
                    else if (data.OutCluster == 1026)
                    {
                        ((TemperatureSensor)mainDevice).SensorDiv = 1;
                    }
                }
            }
            //如果是调光器
            else if (mainDevice.Type == DeviceType.DimmableLight)
            {
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //调光器固定灯光
                    this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
                }
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/Light.png";
                }
            }
            //如果是色温灯
            else if (mainDevice.Type == DeviceType.ColorTemperatureLight)
            {
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //色温灯固定灯光
                    this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
                }
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/ColorLightTemperature.png";
                }
            }
            //如果是三路继电器的回路的话,默认为灯光
            else if (mainDevice.Type == DeviceType.OnOffOutput)
            {
                //2020.05.13变更:继电器都默认为灯光
                if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                {
                    mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                    if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                    {
                        //继电器默认为灯光
                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
                    }
                }
                //根据功能类型,重新设置设备回路图标
                this.ResetIconPathByDeviceFunctionType(mainDevice);
            }
            //如果是空气开关的话
            else if (mainDevice.Type == DeviceType.AirSwitch)
            {
                //空气开关默认为开关
                if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                {
                    mainDevice.DfunctionType = DeviceFunctionType.A开关;
                    if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A开关)
                    {
                        //空气开关默认为开关
                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
                    }
                }
                //根据功能类型,重新设置设备回路图标
                this.ResetIconPathByDeviceFunctionType(mainDevice);
            }
            //如果是彩灯的话
            else if (mainDevice.Type == DeviceType.ColorDimmableLight)
            {
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //彩灯默认为开关
                    this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
                }
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/ColorLight.png";
                }
            }
        }
 
        /// <summary>
        /// 根据功能类型,重新设置设备回路图标
        /// </summary>
        /// <param name="device"></param>
        private void ResetIconPathByDeviceFunctionType(CommonDevice device)
        {
            if (device.IsCustomizeImage == true)
            {
                return;
            }
            if (device.DfunctionType == DeviceFunctionType.A开关)
            {
                device.IconPath = "Device/Switch.png";
            }
            else if (device.DfunctionType == DeviceFunctionType.A插座)
            {
                device.IconPath = "Device/Socket1.png";
            }
            else
            {
                device.IconPath = "Device/Light.png";
            }
        }
 
        /// <summary>
        /// 根据设备Type创建对应的设备对象
        /// </summary>
        /// <param name="deviceType">设备Type</param>
        /// <returns></returns>
        public CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType)
        {
            CommonDevice device = null;
 
            //根据设备类型创建设备对象的实例
            if (deviceType == DeviceType.ColorDimmableLight) { device = new ColorDimmableLight(); }
            else if (deviceType == DeviceType.DimmableLight) { device = new DimmableLight(); }
            else if (deviceType == DeviceType.ColorDimmerSwitch) { device = new ColorDimmerSwitch(); }
            else if (deviceType == DeviceType.LevelControlSwitch) { device = new LevelControlSwitch(); }
            else if (deviceType == DeviceType.OnOffSwitch) { device = new Panel(); }
            else if (deviceType == DeviceType.OnOffOutput) { device = new ToggleLight(); }
            else if (deviceType == DeviceType.AirSwitch) { device = new AirSwitch(); }
            else if (deviceType == DeviceType.WindowCoveringDevice) { device = new Rollershade(); }
            else if (deviceType == DeviceType.WindowCoveringController) { device = new WindowCoveringController(); }
            else if (deviceType == DeviceType.IASZone) { device = new IASZone(); }
            else if (deviceType == DeviceType.Repeater) { device = new Repeater(); }
            else if (deviceType == DeviceType.Thermostat) { device = new AC(); }
            else if (deviceType == DeviceType.FreshAir) { device = new FreshAir(); }
            else if (deviceType == DeviceType.DoorLock) { device = new DoorLock(); }
            else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); }
            else if (deviceType == DeviceType.PMSensor) { device = new PMSensor(); }
            else if (deviceType == DeviceType.FreshAirHumiditySensor) { device = new HumiditySensor(); }
            else if (deviceType == DeviceType.ColorTemperatureLight) { device = new ColorTemperatureLight(); }
            else if (deviceType == DeviceType.Buzzer) { device = new Buzzer(); }
            else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
            else { return null; }
 
            device.DeviceEpointName = string.Empty;
            device.DeviceName = string.Empty;
 
            return device;
        }
 
        /// <summary>
        /// 给新设备设置主键属性
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <param name="jobject">主题Data</param>
        public void SetNewDeviceMainKeys(CommonDevice device, Newtonsoft.Json.Linq.JObject jobject)
        {
            //设置设备主键类
            device.DeviceID = jobject.Value<int>("Device_ID");
            device.DeviceAddr = jobject.Value<string>("DeviceAddr");
            device.DeviceEpoint = jobject.Value<int>("Epoint");
        }
 
        #endregion
 
        //----------------------------------分割线(设备模块ID)---------------------------------------------
 
        #region ■ 自定义设备模块ID___________________
 
        /// <summary>
        /// 初始化设备的模块ID的枚举
        /// </summary>
        private void InitDeviceModelIdEnum()
        {
            if (this.dicDeviceModelIdEnum != null)
            {
                return;
            }
            this.dicDeviceModelIdEnum = new Dictionary<string, string>();
 
            //*********************************************************************
            //新设备添加方法:
            //1、在这里填写上模块ID,然后是 DeviceConcreteType ,然后是 DeviceBeloneType , 然后是 设备类型的翻译ID
            //2、然后在最下面的【自定义设备类型】折叠栏里添加【设备的具体类型】,【设备的所属类型】
            //3、以设备的具体类型为名字(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
            //4、添加R文件(uDeviceModelId),添加Language文件
            //5、如果需要共有图片,则在这个函数的最底下添加
            //*********************************************************************
 
            //前言:因为zigbeehome的设备拥有四种名字:
            //1、设备官方名称            ----它由DeviceConcreteType的数值所决定(个人中心专用)
            //2、设备入网后的默认名称    ----它不需要在代码里面定义,它直接在Language文件里面定义
            //                               范围:50000开始,它的规则是DeviceConcreteType对应的R文件里面的ID的数值+20000,
            //3、设备所属名称            ----它有DeviceBeloneType的数值所决定
            //4、设备类型名称            ----它由【设备类型的翻译ID】所决定,这个值是个人中心专用,
            //                               它是Language文件里面的 60000之后的那些值
 
            //定义规则:模块ID(已翻译) = 设备具体类型值 - 设备所属类型值 - 设备类型的翻译ID
            //设备具体类型值:DeviceConcreteType(在这个文件最下面进行定义)
            //设备所属类型值: DeviceBeloneType(自定义的值,嘛,只要不重复就可以,在这个文件最下面进行定义)
            //设备类型的翻译ID:这个值是个人中心专用,它是Language文件里面的 60000之后的那些值
 
            //=========★★开合帘类(100-199)★★=========
            this.dicDeviceModelIdEnum["MWM65B-ZB.20"] = "100-100-60002";//智能开合帘电机
            this.dicDeviceModelIdEnum["MVSM35B-ZB.20"] = "101-100-60002";//智能管状电机
 
            //=========★★按键面板类(200-1199)★★=========
            this.dicDeviceModelIdEnum["MPT4/R4-ZB.18"] = "200-200-60003";//4按键触摸面板(带4路继电器底座)
            this.dicDeviceModelIdEnum["MPT3/R3-ZB.18"] = "201-200-60003";//3按键触摸面板
            this.dicDeviceModelIdEnum["MPT2/R2-ZB.18"] = "202-200-60003";//2按键触摸面板
            this.dicDeviceModelIdEnum["MPT1/R1-ZB.18"] = "203-200-60003";//12按键触摸面板
            this.dicDeviceModelIdEnum["MPT4-ZB.18"] = "210-200-60003";//4按键触摸面板(只带电源底座)
            this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200-60003";//简约4按键面板
            this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200-60003";//简约3按键面板
            this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200-60003";//简约2按键面板
            this.dicDeviceModelIdEnum["MPT4SC/S-ZB.18"] = "224-200-60003";//简约4按键场景面板
            this.dicDeviceModelIdEnum["MPT2W/S-ZB.18"] = "226-200-60003";//简约2路窗帘面板
            this.dicDeviceModelIdEnum["MP2B/TILE-ZB.18"] = "240-200-60003";//方悦单开双控面板
            this.dicDeviceModelIdEnum["MP4B/TILE-ZB.18"] = "241-200-60003";//方悦双开四控面板
            this.dicDeviceModelIdEnum["MP8B/TILE-ZB.18"] = "242-200-60003";//方悦四开八控面板
            this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200-60003";//方悦新风面板
            this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200-60003";//方悦环境面板
            this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200-60003";//窗帘面板
            this.dicDeviceModelIdEnum["MPTL4C/S-ZB.18"] = "212-200-60003";//简约多功能面板
            this.dicDeviceModelIdEnum["MPTE3/S-ZB.18"] = "230-200-60003";//简约环境面板
 
 
            //=========★★PIR传感器类(1200-1299)★★=========
            this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200-60000";//pir传感器220
            this.dicDeviceModelIdEnum["MSPIRB-ZB.10"] = "1205-1200-60000";//球型移动传感器
 
            //=========★★安防类传感器类(1300-2299)★★=========
            //这里是麦乐克的
            this.dicDeviceModelIdEnum["MULTI-GASE--EA07"] = "1300-1200-60000";//燃气传感器
            this.dicDeviceModelIdEnum["MULTI-MECI--EA01"] = "1301-1200-60000";//门窗磁传感器
            this.dicDeviceModelIdEnum["MULTI-FIRE--EA05"] = "1302-1200-60000";//烟雾传感器
            this.dicDeviceModelIdEnum["MULTI-MOTI--EA04"] = "1303-1200-60000";//红外传感器
            this.dicDeviceModelIdEnum["MULTI-WATE--EA02"] = "1304-1200-60000";//水浸传感器
            this.dicDeviceModelIdEnum["MULTI-BURO--EA06"] = "1305-1200-60000";//紧急按键
            //这里是河东的
            this.dicDeviceModelIdEnum["MSG01/M-ZB.10"] = "1300-1200-60000";//燃气传感器
            this.dicDeviceModelIdEnum["MSDC01/M-ZB.10"] = "1301-1200-60000";//门窗磁传感器
            this.dicDeviceModelIdEnum["MSS01/M-ZB.10"] = "1302-1200-60000";//烟雾传感器
            this.dicDeviceModelIdEnum["MSPIR01/M-ZB.10"] = "1303-1200-60000";//红外传感器
            this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1200-60000";//水浸传感器
            this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//紧急按键
            this.dicDeviceModelIdEnum["MGCD01/M-ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
 
            //PM2.5空气质量传感器 【该设备属于第三方设备,没有镜像ID】
            this.dicDeviceModelIdEnum["MSPM25/M-ZB.10"] = "1307-1200-60000";//PM2.5空气质量传感器 
 
            //=========★★继电器类(2300-2499)★★=========
            this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3路继电器小模块
            this.dicDeviceModelIdEnum["MFA01-ZB.10"] = "2310-2300-60011";//方悦新风小模块
 
            //=========★★调光器类(2500-2799)★★=========
            this.dicDeviceModelIdEnum["MPD0101-ZB.10"] = "2500-2500-60007";//1路调光器小模块
 
            //=========★★智能门锁类(2800-????)★★=========
            this.dicDeviceModelIdEnum["H06C"] = "2800-2800-60010";//智能门锁(H06C)
            this.dicDeviceModelIdEnum["S-one"] = "2802-2800-60010";//智能门锁(S-one)
 
            //=========★★空调类(3600-3899)★★=========
            this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600-60009";//zigbee空调网关模块
 
            //=========★★中继器类(3900-3999)★★=========
            this.dicDeviceModelIdEnum["MSR-ZB.10"] = "3900-3900-60006"; //zigbee中继器
 
            //=========★★空气开关类(4100-4199)★★=========
            this.dicDeviceModelIdEnum["MBCI01-ZB.10"] = "4100-4100-60001";//zigbee微断云控制器
 
            //=========★★转换器类(4200-4699)★★=========
            this.dicDeviceModelIdEnum["MBUS/GW-ZB.10"] = "4200-4200-60008";//zigbee转buspro协议转换器
            this.dicDeviceModelIdEnum["M485/GW-ZB.10"] = "4201-4200-60008";//zigbee转485协议转换器
 
 
 
            //✩✩✩✩✩需要交换的模块ID✩✩✩✩✩
            this.dicDeviceModelIdChanged = new Dictionary<string, string>();
            //=========★★安防类传感器类★★=========
            this.dicDeviceModelIdChanged["MULTI-GASE--EA07"] = "MSG01/M-ZB.10";//燃气传感器
            this.dicDeviceModelIdChanged["MULTI-MECI--EA01"] = "MSDC01/M-ZB.10";//门窗磁传感器
            this.dicDeviceModelIdChanged["MULTI-FIRE--EA05"] = "MSS01/M-ZB.10";//烟雾传感器
            this.dicDeviceModelIdChanged["MULTI-MOTI--EA04"] = "MSPIR01/M-ZB.10";//红外传感器
            this.dicDeviceModelIdChanged["MULTI-WATE--EA02"] = "MSW01/M-ZB.10";//水浸传感器
            this.dicDeviceModelIdChanged["MULTI-BURO--EA06"] = "MBU01/M-ZB.10";//紧急按键
 
 
 
            //✩✩✩✩✩需要共有的图片对象✩✩✩✩✩
            //两者都是DeviceConcreteType
            //Keys:指定的设备    value:沿用的图片是哪款设备的
            this.dicPictrueShard = new Dictionary<string, string>();
            this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//简约4按键面板 沿用 4按键的图标
            this.dicPictrueShard["ButtonPanel_SimpleThree"] = "ButtonPanel_Three";//简约3按键面板 沿用 3按键的图标
            this.dicPictrueShard["ButtonPanel_SimpleTwo"] = "ButtonPanel_Two";//简约2按键面板 沿用 2按键的图标
            this.dicPictrueShard["IntelligentLocks_Sone"] = "IntelligentLocks_H06C";//S-one的门锁图片 沿用 H06C的图标
            this.dicPictrueShard["Relay_FangyueFreshAirModul"] = "Relay_ThreeLoad";//方悦新风小模块图片 沿用 3路继电器的图标
        }
 
        #endregion
    }
 
    #region ■ 自定义设备类型_________________________
 
    /// <summary>
    /// <para>仅限底层使用:设备的具体【设备类型】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值)</para>
    /// <para>变量名可以作为【设备类型】图片,这个值是瞎写的,没什么特殊意义</para>
    /// </summary>
    public enum DeviceConcreteType
    {
        //定义规则:【设备类型】图片名字=LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值
 
        /// <summary>
        /// 未知设备
        /// </summary>
        UnKownDevice = -1,
 
        //=========★★窗帘类(100-199)★★=========
        /// <summary>
        /// 窗帘
        /// </summary>
        Curtain = -100,
        /// <summary>
        /// 智能开合帘电机 镜像id:100
        /// </summary>
        Curtain_AutoOpen = 100,
        /// <summary>
        /// 智能管状电机 镜像id:101
        /// </summary>
        Curtain_Siphonate = 101,
 
        //=========★★按键面板类(200-1199)★★=========
        /// <summary>
        /// 按键面板
        /// </summary>
        ButtonPanel = -200,
        /// <summary>
        /// 4按键多功能触摸面板(带4路继电器底座) 镜像id:200
        /// </summary>
        ButtonPanel_Four = 200,
        /// <summary>
        /// 3按键多功能触摸面板(带3路继电器底座) 镜像id:201
        /// </summary>
        ButtonPanel_Three = 201,
        /// <summary>
        /// 2按键多功能触摸面板(带2路继电器底座) 镜像id:202
        /// </summary>
        ButtonPanel_Two = 202,
        /// <summary>
        /// 12按键多功能触摸面板(带1路继电器底座) 镜像id:203
        /// </summary>
        ButtonPanel_Twelve = 203,
        /// <summary>
        /// 4按键多功能触摸面板(只带电源底座) 镜像id:210
        /// </summary>
        ButtonPanel_FourNotPower = 210,
        /// <summary>
        /// 简约4按键面板 镜像id:220
        /// </summary>
        ButtonPanel_SimpleFour = 220,
        /// <summary>
        /// 简约3按键面板 镜像id:221
        /// </summary>
        ButtonPanel_SimpleThree = 221,
        /// <summary>
        /// 简约2按键面板 镜像id:222
        /// </summary>
        ButtonPanel_SimpleTwo = 222,
        /// <summary>
        /// 简约4按键场景面板 镜像id:224
        /// </summary>
        ButtonPanel_FourButtonScene = 224,
        /// <summary>
        /// 简约2路窗帘面板 镜像id:226
        /// </summary>
        ButtonPanel_TwoButtonCurtain = 226,
        /// <summary>
        /// 方悦2按键轻触式面板 镜像id:240
        /// </summary>
        ButtonPanel_FangyueTwo = 240,
        /// <summary>
        /// 方悦4按键轻触式面板 镜像id:241
        /// </summary>
        ButtonPanel_FangyueFour = 241,
        /// <summary>
        /// 方悦8按键轻触式面板 镜像id:242
        /// </summary>
        ButtonPanel_FangyueEight = 242,
        /// <summary>
        /// 方悦新风面板 镜像id:250
        /// </summary>
        ButtonPanel_FangyueFreshAir = 250,
        /// <summary>
        /// 方悦环境面板 镜像id:253
        /// </summary>
        ButtonPanel_FangyueEnvironment = 253,
        /// <summary>
        /// 窗帘面板 镜像id:256
        /// </summary>
        ButtonPanel_Curtain = 256,
        /// <summary>
        /// 简约多功能面板 镜像ID:212
        /// </summary>
        ButtonPanel_SimpleMultifunction = 212,
        /// <summary>
        /// 简约环境面板
        /// </summary>
        ButtonPanel_SimpleEnvironment = 230,
 
        //=========★★PIR传感器类(1200-1299)★★=========
        /// <summary>
        /// 传感器
        /// </summary>
        Sensor = -1200,
        /// <summary>
        /// pir传感器220 镜像id:1200
        /// </summary>
        Sensor_Pir = 1200,
        /// <summary>
        /// 球形移动传感器 镜像id:1205
        /// </summary>
        Sensor_SphericalMotion = 1205,
 
        //=========★★安防类传感器类(1300-2299)★★=========
        /// <summary>
        /// 燃气传感器
        /// </summary>
        Sensor_CarbonMonoxide = 1300,
        /// <summary>
        /// 门窗传感器
        /// </summary>
        Sensor_DoorWindow = 1301,
        /// <summary>
        /// 烟雾传感器
        /// </summary>
        Sensor_Fire = 1302,
        /// <summary>
        /// 红外传感器
        /// </summary>
        Sensor_Infrared = 1303,
        /// <summary>
        /// 水侵传感器
        /// </summary>
        Sensor_Water = 1304,
        /// <summary>
        /// 紧急按钮
        /// </summary>
        Sensor_EmergencyButton = 1305,
        /// <summary>
        /// 吸顶燃气传感器
        /// </summary>
        Sensor_CeilingGas = 1306,
        /// <summary>
        /// PM2.5空气质量传感器
        /// </summary>
        Sensor_PMTwoPointFive = 1307,
 
        /// <summary>
        /// 运动传感器
        /// </summary>
        Sensor_Motion = -1306,
        /// <summary>
        /// 钥匙扣
        /// </summary>
        Sensor_Keyfob = -1307,
        /// <summary>
        /// 温湿度传感器
        /// </summary>
        Sensor_TemperatureHumidity = -1308,
        /// <summary>
        /// 温度传感器
        /// </summary>
        Sensor_Temperature = -1309,
        /// <summary>
        /// 湿度传感器
        /// </summary>
        Sensor_Humidity = -1310,
 
        //=========★★继电器类(2300-2499)★★=========
        /// <summary>
        /// 继电器
        /// </summary>
        Relay = -2300,
        /// <summary>
        /// 三路继电器 镜像id:2300
        /// </summary>
        Relay_ThreeLoad = 2300,
        /// <summary>
        /// 方悦新风小模块 镜像id:2310
        /// </summary>
        Relay_FangyueFreshAirModul = 2310,
        
        //=========★★调光器类(2500-2799)★★=========
        /// <summary>
        /// 调光器
        /// </summary>
        DimmableLight = -2500,
        /// <summary>
        /// 1路调光器小模块
        /// </summary>
        DimmableLight_OneLoad = 2500,
 
        //=========★★智能门锁类(2800-????)★★=========
        /// <summary>
        /// 智能门锁
        /// </summary>
        IntelligentLocks = -2800,
        /// <summary>
        /// H06C
        /// </summary>
        IntelligentLocks_H06C = 2800,
        /// <summary>
        /// S-one
        /// </summary>
        IntelligentLocks_Sone = 2802,
 
        //=========★★彩灯类(????-????)★★=========
        /// <summary>
        /// 彩灯
        /// </summary>
        ColorLight = -10,
        /// <summary>
        /// 色温灯(它的镜像ID未定,暂定20000)
        /// </summary>
        ColorLight_Temperature = 20000,
 
        //=========★★空调(3600-3899)★★=========
        /// <summary>
        /// 空调
        /// </summary>
        AirConditioner = -3600,
        /// <summary>
        /// zigbee空调网关模块
        /// </summary>
        AirConditioner_ZbGateway = 3600,
 
        //=========★★中继器(3900-3999)★★=========
        /// <summary>
        /// 中继器
        /// </summary>
        Repeater = -3900,
        /// <summary>
        /// zigbee中继器 镜像id:3900
        /// </summary>
        Repeater_Zigbee = 3900,
 
        //=========★★空气开关类(4100-????)★★=========
        /// <summary>
        /// 智能空开
        /// </summary>
        AirSwitch = -4100,
        /// <summary>
        /// 智能空开 镜像id:4100
        /// </summary>
        AirSwitch_CloudContr = 4100,
 
        //=========★★转换器类(4200-4699)★★=========
        /// <summary>
        /// 转换器
        /// </summary>
        Converter = -4200,
        /// <summary>
        /// zigbee转485协议转换器
        /// </summary>
        Converter_Zb485 = 4200,
        /// <summary>
        /// zigbee转buspro协议转换器
        /// </summary>
        Converter_ZbBuspro = 4201,
 
        //=========★★其他类(????-????)★★=========
        /// <summary>
        /// 干接点(注意,它属于其他类,不是设备类型)
        /// </summary>
        DryContact = -10000,
        /// <summary>
        /// 灯光(注意,它属于其他类,不是设备类型)
        /// </summary>
        Light = -10001,
        /// <summary>
        /// 插座(注意,它属于其他类,不是设备类型)
        /// </summary>
        Socket1 = -10002,
        /// <summary>
        /// 开关(注意,它属于其他类,不是设备类型)
        /// </summary>
        Switch = -10003,
    }
 
    /// <summary>
    /// <para>仅限底层使用:设备所属的【设备种类】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceBeloneType值)</para>
    /// <para>这个值是瞎写的,没什么特殊意义</para>
    /// </summary>
    public enum DeviceBeloneType
    {
        /// <summary>
        /// 未知设备
        /// </summary>
        A未知设备 = 0,
        /// <summary>
        /// 窗帘(100-199)
        /// </summary>
        A窗帘 = 100,
        /// <summary>
        /// 按键面板(200-1199)
        /// </summary>
        A按键面板 = 200,
        /// <summary>
        /// 传感器(1200-2299)
        /// </summary>
        A传感器 = 1200,
        /// <summary>
        /// PM2.5空气质量传感器
        /// </summary>
        APM2点5空气质量传感器 = 1307,
        /// <summary>
        /// 继电器(2300-2499)
        /// </summary>
        A继电器 = 2300,
        /// <summary>
        /// 新风
        /// </summary>
        A新风 = 2310,
        /// <summary>
        /// 调光器(2500-2799)
        /// </summary>
        A调光器 = 2500,
        /// <summary>
        /// 智能门锁(2800-????)
        /// </summary>
        A智能门锁 = 2800,
        /// <summary>
        /// 空调(3600-3899)
        /// </summary>
        A空调 = 3600,
        /// <summary>
        /// 中继器(3900-3999)
        /// </summary>
        A中继器 = 3900,
        /// <summary>
        /// 智能空开(4100-4199)
        /// </summary>
        A智能空开 = 4100,
        /// <summary>
        /// 转换器(4200-4699)
        /// </summary>
        A转换器 = 4200,
        /// <summary>
        /// 彩灯
        /// </summary>
        A彩灯 = 9,
        /// <summary>
        /// 温湿度传感器
        /// </summary>
        A温湿度传感器 = 10,
        /// <summary>
        /// 温度传感器
        /// </summary>
        A温度传感器 = 11,
        /// <summary>
        /// 湿度传感器
        /// </summary>
        A湿度传感器 = 12,
        /// <summary>
        /// 开关
        /// </summary>
        A开关 = 13,
        /// <summary>
        /// 插座
        /// </summary>
        A插座 = 14,
        /// <summary>
        /// 灯光
        /// </summary>
        A灯光 = 15,
        /// <summary>
        /// 干接点
        /// </summary>
        A干接点 = 16,
    }
 
    #endregion
}