-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPage.cs
6436 lines (5551 loc) · 268 KB
/
Page.cs
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
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
namespace SCADA
{
[Serializable]
public class Page
{
public CollectionsText CollectionText { get; set; }
public CollectionsPipe CollectionPipe { get; set; }
public CollectionsPipe90 CollectionPipe90 { get; set; }
public CollectionsDisplay CollectionDisplay { get; set; }
public CollectionsImage CollectionImage { get; set; }
public CollectionsEthernet CollectionEthernet { get; set; }
public CollectionsCom CollectionCom { get; set; }
public CollectionsModbus CollectionModbus { get; set; }
public Page()
{
CollectionPipe90 = new CollectionsPipe90();
CollectionPipe = new CollectionsPipe();
CollectionText = new CollectionsText();
CollectionDisplay = new CollectionsDisplay();
CollectionImage = new CollectionsImage();
CollectionEthernet = new CollectionsEthernet();
CollectionCom = new CollectionsCom();
CollectionModbus = new CollectionsModbus();
}
}
public class CollectionsPipe : List<PipeSer>
{ }
public class CollectionsPipe90 : List<Pipe90Ser>
{ }
public class CollectionsText : List<TextSer>
{ }
public class CollectionsDisplay : List<DisplaySer>
{ }
public class CollectionsImage : List<ImageSer>
{ }
public class CollectionsEthernet : List<EthernetSer>
{ }
public class CollectionsCom : List<ComSer>
{ }
public class CollectionsModbus : List<ModbusSer>
{ }
[Serializable]
public class CollectionNets : ObservableCollection<ItemNet>
{ }
[Serializable]
public class CollectionModbusNets : ObservableCollection<ItemModbus>
{ }
[Serializable]
public class Item : INotifyPropertyChanged
{
[field: NonSerialized()]
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
{
PropertyChanged(this, e);
}
}
[field: NonSerializedAttribute()]
private object valueItem;
public object Value
{
get { return valueItem; }
set
{
valueItem = value;
OnPropertyChanged(new PropertyChangedEventArgs("Value"));
}
}
[field: NonSerializedAttribute()]
private bool isBinding;
public bool IsBinding
{
get { return isBinding; }
set
{
isBinding = value;
OnPropertyChanged(new PropertyChangedEventArgs("IsBinding"));
}
}
public bool IsEmergencyUpDG
{
get { return IsEmergencyUp; }
set
{
IsEmergencyUp = value;
OnPropertyChanged(new PropertyChangedEventArgs("IsEmergencyUpDG"));
}
}
public bool IsEmergencyDownDG
{
get { return IsEmergencyDown; }
set
{
IsEmergencyDown = value;
OnPropertyChanged(new PropertyChangedEventArgs("IsEmergencyDownDG"));
}
}
public string TypeValue { get; set; }
public string Description { get; set; }
public bool IsSaveDatabase { get; set; }
public string TableName { get; set; }
public int PeridTimeSaveDB { get; set; }
public string FormulaText { get; set; }
public string Text { get; set; }
public bool IsEmergencySaveDB { get; set; }
public int PeriodEmergencySaveDB { get; set; }
public bool IsEmergencyUp { get; set; }
public bool IsEmergencyDown { get; set; }
public object EmergencyUp { get; set; }
public object EmergencyDown { get; set; }
public string ID { get; set; }
public Item()
{
TypeValue = "float";
Value = "###";
Description = "Описание " + ((AppWPF)Application.Current).GenerateTextName.Next();
IsSaveDatabase = false;
TableName = "";
PeridTimeSaveDB = 120;
FormulaText = "";
Text = "";
EmergencyUp = 0;
EmergencyDown = 0;
PeriodEmergencySaveDB = 60;
ID = ((AppWPF)Application.Current).GenerateID();
}
}
[Serializable]
public class ItemModbus : Item
{
public ushort Address { get; set; }
public ushort Function { get; set; }
[field: NonSerializedAttribute()]
private object valueItem;
public static bool operator ==(ItemModbus op1, ItemModbus op2)
{
if ((object)op1 == null)
{
return (object)op2 == null;
}
return op1.Equals(op2);
}
public static bool operator !=(ItemModbus op1, ItemModbus op2)
{
if ((object)op1 != null)
{
if ((object)op2 == null)
{
return true;
}
else
{
return !op1.Equals(op2);
}
}
else
{
return (object)op2 != null;
}
}
public override bool Equals(System.Object obj)
{
// If parameter is null return false.
if (obj == null)
{
return false;
}
// If parameter cannot be cast to ItemNet return false.
ItemModbus itemModbus = obj as ItemModbus;
if ((System.Object)itemModbus == null)
{
return false;
}
// Return true if the fields match:
if (ID == itemModbus.ID && Description == itemModbus.Description && Function == itemModbus.Function && TypeValue == itemModbus.TypeValue && IsSaveDatabase == itemModbus.IsSaveDatabase
&& TableName == itemModbus.TableName && PeridTimeSaveDB == itemModbus.PeridTimeSaveDB && Address == itemModbus.Address
&& FormulaText == itemModbus.FormulaText && Text == itemModbus.Text && Convert.ToSingle(EmergencyUp, CultureInfo.InvariantCulture) == Convert.ToSingle(itemModbus.EmergencyUp, CultureInfo.InvariantCulture)
&& Convert.ToSingle(EmergencyDown, CultureInfo.InvariantCulture) == Convert.ToSingle(itemModbus.EmergencyDown, CultureInfo.InvariantCulture) && IsEmergencyUp == itemModbus.IsEmergencyUp && IsEmergencyDown == itemModbus.IsEmergencyDown
&& IsEmergencySaveDB == itemModbus.IsEmergencySaveDB && PeriodEmergencySaveDB == itemModbus.PeriodEmergencySaveDB)
{
return true;
}
else
{
return false;
}
}
public bool Equals(ItemModbus itemModbus)
{
// If parameter is null return false:
if ((object)itemModbus == null)
{
return false;
}
// Return true if the fields match:
if (ID == itemModbus.ID && Description == itemModbus.Description && Function == itemModbus.Function && TypeValue == itemModbus.TypeValue && IsSaveDatabase == itemModbus.IsSaveDatabase
&& TableName == itemModbus.TableName && PeridTimeSaveDB == itemModbus.PeridTimeSaveDB && Address == itemModbus.Address
&& FormulaText == itemModbus.FormulaText && Text == itemModbus.Text && Convert.ToSingle(EmergencyUp, CultureInfo.InvariantCulture) == Convert.ToSingle(itemModbus.EmergencyUp, CultureInfo.InvariantCulture)
&& Convert.ToSingle(EmergencyDown, CultureInfo.InvariantCulture) == Convert.ToSingle(itemModbus.EmergencyDown, CultureInfo.InvariantCulture) && IsEmergencyUp == itemModbus.IsEmergencyUp && IsEmergencyDown == itemModbus.IsEmergencyDown
&& IsEmergencySaveDB == itemModbus.IsEmergencySaveDB && PeriodEmergencySaveDB == itemModbus.PeriodEmergencySaveDB)
{
return true;
}
else
{
return false;
}
}
public ItemModbus()
{
TypeValue = "float";
Value = "###";
Function = 3;
Description = "Описание " + ((AppWPF)Application.Current).GenerateTextName.Next();
IsSaveDatabase = false;
TableName = "";
PeridTimeSaveDB = 120;
FormulaText = "";
Text = "";
EmergencyUp = 0;
EmergencyDown = 0;
PeriodEmergencySaveDB = 60;
ID = ((AppWPF)Application.Current).GenerateID();
}
}
[Serializable]
public class ItemNet : Item
{
public int Range0 { get; set; }
public int Range1 { get; set; }
[field: NonSerializedAttribute()]
public ItemModbus ItemModbus;
public static bool operator ==(ItemNet op1, ItemNet op2)
{
if ((object)op1 == null)
{
return (object)op2 == null;
}
return op1.Equals(op2);
}
public static bool operator !=(ItemNet op1, ItemNet op2)
{
if ((object)op1 != null)
{
if ((object)op2 == null)
{
return true;
}
else
{
return !op1.Equals(op2);
}
}
else
{
return (object)op2 != null;
}
}
public override bool Equals(System.Object obj)
{
// If parameter is null return false.
if (obj == null)
{
return false;
}
// If parameter cannot be cast to ItemNet return false.
ItemNet itemNet = obj as ItemNet;
if ((System.Object)itemNet == null)
{
return false;
}
// Return true if the fields match:
if (ID == itemNet.ID && Description == itemNet.Description && Range0 == itemNet.Range0 && Range1 == itemNet.Range1 && TypeValue == itemNet.TypeValue && IsSaveDatabase == itemNet.IsSaveDatabase
&& TableName == itemNet.TableName && PeridTimeSaveDB == itemNet.PeridTimeSaveDB && FormulaText == itemNet.FormulaText && Text == itemNet.Text && Convert.ToSingle(EmergencyUp, CultureInfo.InvariantCulture) == Convert.ToSingle(itemNet.EmergencyUp, CultureInfo.InvariantCulture)
&& Convert.ToSingle(EmergencyDown, CultureInfo.InvariantCulture) == Convert.ToSingle(itemNet.EmergencyDown, CultureInfo.InvariantCulture) && IsEmergencyUp == itemNet.IsEmergencyUp && IsEmergencyDown == itemNet.IsEmergencyDown
&& IsEmergencySaveDB == itemNet.IsEmergencySaveDB && PeriodEmergencySaveDB == itemNet.PeriodEmergencySaveDB)
{
return true;
}
else
{
return false;
}
}
public bool Equals(ItemNet itemNet)
{
// If parameter is null return false:
if ((object)itemNet == null)
{
return false;
}
// Return true if the fields match:
if (ID == itemNet.ID && Description == itemNet.Description && Range0 == itemNet.Range0 && Range1 == itemNet.Range1 && TypeValue == itemNet.TypeValue && IsSaveDatabase == itemNet.IsSaveDatabase
&& TableName == itemNet.TableName && PeridTimeSaveDB == itemNet.PeridTimeSaveDB && FormulaText == itemNet.FormulaText && Text == itemNet.Text && Convert.ToDecimal(EmergencyUp) == Convert.ToDecimal(itemNet.EmergencyUp)
&& Convert.ToDecimal(EmergencyDown) == Convert.ToDecimal(itemNet.EmergencyDown) && IsEmergencyUp == itemNet.IsEmergencyUp && IsEmergencyDown == itemNet.IsEmergencyDown
&& IsEmergencySaveDB == itemNet.IsEmergencySaveDB && PeriodEmergencySaveDB == itemNet.PeriodEmergencySaveDB)
{
return true;
}
else
{
return false;
}
}
public ItemNet()
{
Range0 = 0;
Range1 = 3;
}
public byte[] Formula(int PeriodTime)
{
string modbusID;
string itemModbusID;
byte[] bWrite;
if (ItemModbus != null)
{
if (ItemModbus.TypeValue == "float")
{
bWrite = BitConverter.GetBytes((float)ItemModbus.Value);
return bWrite;
}
else if (ItemModbus.TypeValue == "int")
{
bWrite = BitConverter.GetBytes((int)ItemModbus.Value);
return bWrite;
}
else if (ItemModbus.TypeValue == "uint")
{
bWrite = bWrite = BitConverter.GetBytes((uint)ItemModbus.Value);
return bWrite;
}
else if (ItemModbus.TypeValue == "short")
{
bWrite = BitConverter.GetBytes((short)ItemModbus.Value);
return bWrite;
}
else if (ItemModbus.TypeValue == "ushort")
{
bWrite = BitConverter.GetBytes((ushort)ItemModbus.Value);
return bWrite;
}
else if (ItemModbus.TypeValue == "byte")
{
bWrite = BitConverter.GetBytes((byte)ItemModbus.Value);
return bWrite;
}
else if (ItemModbus.TypeValue == "sbyte")
{
bWrite = BitConverter.GetBytes((sbyte)ItemModbus.Value);
return bWrite;
}
}
else if (FormulaText.IndexOf("ItemModbusID") != -1)
{
int modbusIDIndex = Text.IndexOf("ItemModbusID");
modbusID = Text.Substring(modbusIDIndex, 32);
itemModbusID = Text.Substring(modbusIDIndex + 33, 32);
foreach (ModbusSer mb in ((AppWPF)Application.Current).CollectionModbusSers)
{
if (mb.ID == modbusID)
{
foreach (ItemModbus im in mb.CollectionItemModbus)
{
if (im.ID == itemModbusID)
{
ItemModbus = im;
if (im.TypeValue == "float")
{
bWrite = BitConverter.GetBytes((float)im.Value);
return bWrite;
}
else if (im.TypeValue == "int")
{
bWrite = BitConverter.GetBytes((int)im.Value);
return bWrite;
}
else if (im.TypeValue == "uint")
{
bWrite = bWrite = BitConverter.GetBytes((uint)im.Value);
return bWrite;
}
else if (im.TypeValue == "short")
{
bWrite = BitConverter.GetBytes((short)im.Value);
return bWrite;
}
else if (im.TypeValue == "ushort")
{
bWrite = BitConverter.GetBytes((ushort)im.Value);
return bWrite;
}
else if (im.TypeValue == "byte")
{
bWrite = BitConverter.GetBytes((byte)im.Value);
return bWrite;
}
else if (im.TypeValue == "sbyte")
{
bWrite = BitConverter.GetBytes((sbyte)im.Value);
return bWrite;
}
}
}
}
}
}
else if (FormulaText.IndexOf("Period") != -1)
{
return bWrite = BitConverter.GetBytes(PeriodTime);
}
return null;
}
}
[Serializable]
public class TextSer : ControlOnCanvasSer
{
public string ColorBackGround { get; set; }
public string ColorBorder { get; set; }
public double BorderThickness { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public FlowDocument TextDocument { get; set; }
public TwoPointSegment RightSize { get; set; }
public TwoPointSegment LeftSize { get; set; }
public TwoPointSegment TopSize { get; set; }
public TwoPointSegment DownSize { get; set; }
public FivePointSegment Border { get; set; }
public TextSer(int ZIndex, int transform, Point point)
: base(ZIndex, transform)
{
RightSize = new TwoPointSegment();
LeftSize = new TwoPointSegment();
TopSize = new TwoPointSegment();
DownSize = new TwoPointSegment();
Border = new FivePointSegment();
Width = 40;
Height = 22;
Сoordinates = point;
BorderThickness = 2;
ColorBorder = new ColorConverter().ConvertToString(Colors.Black);
ColorBackGround = new ColorConverter().ConvertToString(Colors.Transparent);
RightSize.point = new Point[2] { new Point(45, 3), new Point(45, 24) };
LeftSize.point = new Point[2] { new Point(0, 3), new Point(0, 24) };
TopSize.point = new Point[2] { new Point(3, 0), new Point(42, 0) };
DownSize.point = new Point[2] { new Point(3, 27), new Point(42, 27) };
Border.point = new Point[5] { new Point(0, 0), new Point(45, 0), new Point(45, 27), new Point(0, 27), new Point(0, 0) };
}
public TextSer()
{ }
}
[Serializable]
public class PipeSer : ControlOnCanvasSer
{
public PipeSer(int ZIndex, int transform , Point point)
: base(ZIndex, transform)
{
RightSize = new TwoPointSegment();
LeftSize = new TwoPointSegment();
TopSize = new TwoPointSegment();
DownSize = new TwoPointSegment();
LeftFlange = new FivePointSegment();
RightFlange = new FivePointSegment();
Pipe = new FivePointSegment();
BorderPipe = new FivePointSegment();
Сoordinates = point;
RightSize.point = new Point[2] {new Point(145.5, 28), new Point(145.5, 7)};
LeftSize.point = new Point[2] {new Point(2.5, 7), new Point(2.5, 28)};
TopSize.point = new Point[2] {new Point(5, 3), new Point(142, 3)};
DownSize.point = new Point[2] {new Point(5, 31), new Point(142, 31)};
RightFlange.point = new Point[5] {new Point(142, 0), new Point(147, 0), new Point(147, 34), new Point(142, 34), new Point(142, 0)};
LeftFlange.point = new Point[5] {new Point(0, 0), new Point(5, 0), new Point(5, 34), new Point(0, 34), new Point(0, 0)};
Pipe.point = new Point[5] {new Point(143, 31), new Point(143, 3), new Point(4, 3), new Point(4, 31), new Point(143, 31)};
BorderPipe.point = new Point[5] {new Point(0, 0), new Point(147, 0), new Point(147, 34), new Point(0, 34), new Point(0, 0)};
Environment = 4;
}
public PipeSer()
{ }
public TwoPointSegment RightSize { get; set; }
public TwoPointSegment LeftSize { get; set; }
public TwoPointSegment TopSize { get; set; }
public TwoPointSegment DownSize { get; set; }
public FivePointSegment LeftFlange { get; set; }
public FivePointSegment RightFlange { get; set; }
public FivePointSegment Pipe { get; set; }
public FivePointSegment BorderPipe { get; set; }
private int environment = 4;
public int Environment
{
get { return environment; }
set { environment = value; }
}
}
[Serializable]
public class ImageSer : ControlOnCanvasSer
{
public string ColorBackGround { get; set; }
public Brush ColorBorder { get; set; }
public double BorderThickness { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public string PathImage { get; set; }
public string StretchImage { get; set; }
public string LibraryImage { get; set; }
public bool IsPathImage { get; set; }
public TwoPointSegment RightSize { get; set; }
public TwoPointSegment LeftSize { get; set; }
public TwoPointSegment TopSize { get; set; }
public TwoPointSegment DownSize { get; set; }
public FivePointSegment Border { get; set; }
public ImageSer(int ZIndex, int transform, Point point)
: base(ZIndex, transform)
{
RightSize = new TwoPointSegment();
LeftSize = new TwoPointSegment();
TopSize = new TwoPointSegment();
DownSize = new TwoPointSegment();
Border = new FivePointSegment();
IsPathImage = true;
StretchImage = "Uniform";
Width = 40;
Height = 22;
Сoordinates = point;
BorderThickness = 2;
ColorBorder = new SolidColorBrush(Colors.Black);
ColorBackGround = new ColorConverter().ConvertToString(Colors.Transparent);
RightSize.point = new Point[2] { new Point(45, 3), new Point(45, 24) };
LeftSize.point = new Point[2] { new Point(0, 3), new Point(0, 24) };
TopSize.point = new Point[2] { new Point(3, 0), new Point(42, 0) };
DownSize.point = new Point[2] { new Point(3, 27), new Point(42, 27) };
Border.point = new Point[5] { new Point(0, 0), new Point(45, 0), new Point(45, 27), new Point(0, 27), new Point(0, 0) };
}
public ImageSer()
{ }
}
[Serializable]
public class DisplaySer : ControlOnCanvasSer
{
public bool IsCollSend { get; set; }
public bool IsCollRec { get; set; }
public string EthernetSearch { get; set; }
public string ModbusSearch { get; set; }
public bool IsEthernet { get; set; }
public bool IsModbus { get; set; }
public ItemNet ItemNetSearch { get; set; }
public ItemModbus ItemModbusSearch { get; set; }
public string ColorBackGround { get; set; }
public string ColorBorder { get; set; }
public double BorderThickness { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public int PeriodTime { get; set; }
public TwoPointSegment RightSize { get; set; }
public TwoPointSegment LeftSize { get; set; }
public TwoPointSegment TopSize { get; set; }
public TwoPointSegment DownSize { get; set; }
public FivePointSegment Border { get; set; }
public DisplaySer(int ZIndex, int transform, Point point)
: base(ZIndex, transform)
{
PeriodTime = 1000;
RightSize = new TwoPointSegment();
LeftSize = new TwoPointSegment();
TopSize = new TwoPointSegment();
DownSize = new TwoPointSegment();
Border = new FivePointSegment();
Width = 40;
Height = 22;
Сoordinates = point;
BorderThickness = 2;
ColorBorder = new ColorConverter().ConvertToString(Colors.Black);
ColorBackGround = new ColorConverter().ConvertToString(Colors.Transparent);
RightSize.point = new Point[2] { new Point(45, 3), new Point(45, 24) };
LeftSize.point = new Point[2] { new Point(0, 3), new Point(0, 24) };
TopSize.point = new Point[2] { new Point(3, 0), new Point(42, 0) };
DownSize.point = new Point[2] { new Point(3, 27), new Point(42, 27) };
Border.point = new Point[5] { new Point(0, 0), new Point(45, 0), new Point(45, 27), new Point(0, 27), new Point(0, 0) };
}
public DisplaySer()
{ }
}
[Serializable]
public class ControlOnCanvasSer : IComparable
{
public Point Сoordinates { get; set; }
public int Transform { get; set; }
public int ZIndex {get; set;}
[NonSerialized()]
public ControlOnCanvas ControlItem;
public ControlOnCanvasSer(int zIndex, int transform)
{
Transform = transform;
ZIndex = zIndex;
}
public ControlOnCanvasSer()
{ }
public int CompareTo(object obj)
{
ControlOnCanvasSer otherControlOnCanvasSer = obj as ControlOnCanvasSer;
if (otherControlOnCanvasSer != null) return this.ZIndex.CompareTo(otherControlOnCanvasSer.ZIndex);
else throw new ArgumentException("Пустой объект для сортировки");
}
}
[Serializable]
public class Pipe90Ser: ControlOnCanvasSer
{
public Pipe90Ser(int ZIndex, int transform, Point point)
: base(ZIndex, transform)
{
RightDownSize = new TwoPointSegment();
LeftDownSize = new TwoPointSegment();
TopSize = new TwoPointSegment();
DownSize = new TwoPointSegment();
LeftFlange = new FivePointSegment();
RightFlange = new FivePointSegment();
Pipe90 = new SevenPointSegment();
BorderPipe90 = new FivePointSegment();
TopImage = new FivePointSegment();
DownImage = new FivePointSegment();
DownLenghtSize = new TwoPointSegment();
TopLenghtSize = new TwoPointSegment();
Сoordinates = point;
RightDownSize.point = new Point[2] { new Point(31, 69), new Point(31, 31) };
LeftDownSize.point = new Point[2] { new Point(3, 69), new Point(3, 31) };
TopSize.point = new Point[2] { new Point(69, 3), new Point(31, 3) };
DownSize.point = new Point[2] { new Point(69, 31), new Point(31, 31) };
DownLenghtSize.point = new Point[2] { new Point(6.5, 72), new Point(27.5, 72) };
TopLenghtSize.point = new Point[2] { new Point(72, 6.5), new Point(72, 27.5) };
RightFlange.point = new Point[5] { new Point(74, 34), new Point(69, 34), new Point(69, 0), new Point(74, 0), new Point(74, 34) };
LeftFlange.point = new Point[5] { new Point(0, 74), new Point(0, 69), new Point(34, 69), new Point(34, 74), new Point(0, 74) };
Pipe90.point = new Point[7] { new Point(69, 3), new Point(3, 3), new Point(3, 31), new Point(3, 70), new Point(31, 70), new Point(31, 31), new Point(69, 31) };
BorderPipe90.point = new Point[5] { new Point(0, 0), new Point(74, 0), new Point(74, 74), new Point(0, 74), new Point(0, 0) };
TopImage.point = new Point[5] { new Point(31, 31), new Point(3, 3), new Point(70, 3), new Point(70, 31), new Point(31, 31) };
DownImage.point = new Point[5] { new Point(4, 3), new Point(31, 30), new Point(31, 70), new Point(3, 70), new Point(3, 3) };
Environment = 4;
}
public Pipe90Ser()
{ }
public TwoPointSegment RightDownSize { get; set; }
public TwoPointSegment LeftDownSize { get; set; }
public TwoPointSegment TopSize { get; set; }
public TwoPointSegment DownSize { get; set; }
public FivePointSegment LeftFlange { get; set; }
public FivePointSegment RightFlange { get; set; }
public SevenPointSegment Pipe90 { get; set; }
public FivePointSegment BorderPipe90 { get; set; }
public FivePointSegment TopImage { get; set; }
public FivePointSegment DownImage { get; set; }
public TwoPointSegment DownLenghtSize { get; set; }
public TwoPointSegment TopLenghtSize { get; set; }
private int environment = 4;
public int Environment
{
get { return environment; }
set { environment = value; }
}
}
[Serializable]
public class EthernetSer : ControlOnCanvasSer
{
public string ColorBackGround { get; set; }
public string ColorBorder { get; set; }
public double BorderThickness { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public int BufferSizeRec { get; set; }
public int BufferSizeSend { get; set; }
public string EthernetProtocol { get; set; }
public int Time { get; set; }
public string[] IPAddressServer { get; set; }
public byte[] IPAddressClient { get; set; }
public int PortServer { get; set; }
public int PortClient { get; set; }
public string ID { get; set; }
public string Description { get; set; }
public ObservableCollection<ItemNet> CollectionItemNetRec { get; set; }
public ObservableCollection<ItemNet> CollectionItemNetSend { get; set; }
public TwoPointSegment RightSize { get; set; }
public TwoPointSegment LeftSize { get; set; }
public TwoPointSegment TopSize { get; set; }
public TwoPointSegment DownSize { get; set; }
public FivePointSegment Border { get; set; }
public EthernetSer(int ZIndex, int transform, Point point)
: base(ZIndex, transform)
{
IPAddressClient = new byte[4];
PortServer = 1000;
PortClient = 0;
Description = "Описание " + ((AppWPF)Application.Current).GenerateTextName.Next();
IPAddressServer = new string[4] { "192", "168", "0", "1" };
List<IPAddress> Addresses = new List<IPAddress>();
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
IPInterfaceProperties properties = adapter.GetIPProperties();
foreach (IPAddressInformation uniCast in properties.UnicastAddresses)
{
if (!IPAddress.IsLoopback(uniCast.Address) && uniCast.Address.AddressFamily != AddressFamily.InterNetworkV6)
{
Addresses.Add(uniCast.Address);
}
}
}
}
if (Addresses.Count > 0)
{
IPAddressClient = Addresses[0].GetAddressBytes();
}
EthernetProtocol = "TCP";
Time = 5;
RightSize = new TwoPointSegment();
LeftSize = new TwoPointSegment();
TopSize = new TwoPointSegment();
DownSize = new TwoPointSegment();
Border = new FivePointSegment();
Width = 84;
Height = 22;
Сoordinates = point;
BorderThickness = 2;
ColorBorder = new ColorConverter().ConvertToString(Colors.Black);
ColorBackGround = new ColorConverter().ConvertToString(Colors.Transparent);
BufferSizeRec = 4;
BufferSizeSend = 4;
ID = ((AppWPF)Application.Current).GenerateID();
RightSize.point = new Point[2] { new Point(90, 3), new Point(90, 24) };
LeftSize.point = new Point[2] { new Point(3, 3), new Point(3, 24) };
TopSize.point = new Point[2] { new Point(3, 3), new Point(84, 3) };
DownSize.point = new Point[2] { new Point(3, 27), new Point(84, 27) };
Border.point = new Point[5] { new Point(0, 0), new Point(90, 0), new Point(90, 30), new Point(0, 30), new Point(0, 0) };
CollectionItemNetRec = new CollectionNets();
CollectionItemNetSend = new CollectionNets();
CollectionEthernetOperational = new CollectionEthernetOperational();
}
public EthernetSer()
{ }
public static bool operator ==(EthernetSer op1, EthernetSer op2)
{
if ((object)op1 == null)
{
return (object)op2 == null;
}
return op1.Equals(op2);
}
public static bool operator !=(EthernetSer op1, EthernetSer op2)
{
if ((object)op1 != null)
{
if ((object)op2 == null)
{
return true;
}
else
{
return !op1.Equals(op2);
}
}
else
{
return (object)op2 != null;
}
}
public override bool Equals(System.Object obj)
{
// If parameter is null return false.
if (obj == null)
{
return false;
}
// If parameter cannot be cast to EthernetSer return false.
EthernetSer ethernetSer = obj as EthernetSer;
if ((System.Object)ethernetSer == null)
{
return false;
}
// Return true if the fields match:
if (ID == ethernetSer.ID && BufferSizeRec == ethernetSer.BufferSizeRec && EthernetProtocol == ethernetSer.EthernetProtocol && Time == ethernetSer.Time
&& IPAddressServer[0] == ethernetSer.IPAddressServer[0] && IPAddressServer[1] == ethernetSer.IPAddressServer[1] && IPAddressServer[2] == ethernetSer.IPAddressServer[2]
&& IPAddressServer[3] == ethernetSer.IPAddressServer[3] && Description == ethernetSer.Description && PortClient == ethernetSer.PortClient && PortServer == ethernetSer.PortServer
&& IPAddressClient[0] == ethernetSer.IPAddressClient[0] && IPAddressClient[1] == ethernetSer.IPAddressClient[1] && IPAddressClient[2] == ethernetSer.IPAddressClient[2]
&& IPAddressClient[3] == ethernetSer.IPAddressClient[3] && BufferSizeSend == ethernetSer.BufferSizeSend)
{
return true;
}
else
{
return false;
}
}
public bool Equals(EthernetSer ethernetSer)
{
// If parameter is null return false:
if ((object)ethernetSer == null)
{
return false;
}
// Return true if the fields match:
if (ID == ethernetSer.ID && BufferSizeRec == ethernetSer.BufferSizeRec && EthernetProtocol == ethernetSer.EthernetProtocol && Time == ethernetSer.Time
&& IPAddressServer[0] == ethernetSer.IPAddressServer[0] && IPAddressServer[1] == ethernetSer.IPAddressServer[1] && IPAddressServer[2] == ethernetSer.IPAddressServer[2]
&& IPAddressServer[3] == ethernetSer.IPAddressServer[3] && Description == ethernetSer.Description && PortClient == ethernetSer.PortClient && PortServer == ethernetSer.PortServer
&& IPAddressClient[0] == ethernetSer.IPAddressClient[0] && IPAddressClient[1] == ethernetSer.IPAddressClient[1] && IPAddressClient[2] == ethernetSer.IPAddressClient[2]
&& IPAddressClient[3] == ethernetSer.IPAddressClient[3] && BufferSizeSend == ethernetSer.BufferSizeSend)
{
return true;
}
else
{
return false;
}
}
}
[Serializable]
public class ComSer : ControlOnCanvasSer
{
public string ComPort { get; set; }
public int BaudRate { get; set; }
public int DataBits { get; set; }
public string StopBits { get; set; }
public string Parity { get; set; }
public int ReadTimeout { get; set; }
public int WriteTimeout { get; set; }
public string ColorBackGround { get; set; }
public string ColorBorder { get; set; }
public double BorderThickness { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public string Description { get; set; }
public TwoPointSegment RightSize { get; set; }
public TwoPointSegment LeftSize { get; set; }
public TwoPointSegment TopSize { get; set; }
public TwoPointSegment DownSize { get; set; }
public FivePointSegment Border { get; set; }
public ComSer(int ZIndex, int transform, Point point)
: base(ZIndex, transform)
{
ReadTimeout = 100;
WriteTimeout = 100;
Description = "Описание " + ((AppWPF)Application.Current).GenerateTextName.Next();
Parity = "None";
BaudRate = 115200;
StopBits = "One";
DataBits = 8;
RightSize = new TwoPointSegment();
LeftSize = new TwoPointSegment();
TopSize = new TwoPointSegment();
DownSize = new TwoPointSegment();
Border = new FivePointSegment();
Width = 84;
Height = 22;
Сoordinates = point;