├── .gitattributes
├── .gitignore
├── Bottom_Control.sln
├── Bottom_Control
├── App.config
├── Bottom_Control.csproj
├── DAPLC_Time.cs
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── PLC.cs
├── PLC参数设置界面
│ ├── ButtonBitForm1.Designer.cs
│ ├── ButtonBitForm1.cs
│ ├── ButtonBitForm1.resx
│ ├── ComboxForm1.Designer.cs
│ ├── ComboxForm1.cs
│ ├── ComboxForm1.resx
│ ├── TextboxDForm1.Designer.cs
│ ├── TextboxDForm1.cs
│ └── TextboxDForm1.resx
├── PLC通讯协议
│ ├── IPLC_interface.cs
│ ├── MODBUD_TCP.cs
│ ├── Mitsubishi_realize.cs
│ ├── PLC_public_Class.cs
│ ├── Siemens_realize.cs
│ └── 三菱报文
│ │ ├── Mitsubishi_message.cs
│ │ └── message.cs
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Public_Class.cs
├── packages.config
├── 二维码生成
│ └── IhatetheqrcodeCreate.cs
├── 基本控件
│ ├── DAAlarmLamp.cs
│ ├── DAAnalogMeter.cs
│ ├── DABottle.cs
│ ├── DAButton.cs
│ ├── DACheckBox.cs
│ ├── DACombox.cs
│ ├── DAConduit.cs
│ ├── DAConveyor.cs
│ ├── DADataGridView_PLCSQL.cs
│ ├── DADataGridView_TO_PLC.cs
│ ├── DADataGridView_TO_PLCE.Designer.cs
│ ├── DADataGridView_TO_PLCE.cs
│ ├── DADataGridView_TO_PLCE.resx
│ ├── DADataGridView_TO_SQL.cs
│ ├── DAIhatetheqrcode_PLC.cs
│ ├── DALedBulb.cs
│ ├── DAMeter.cs
│ ├── DAPond.cs
│ ├── DAProcessEllipse.cs
│ ├── DAProcessWave.cs
│ ├── DARotor.cs
│ ├── DASignalLamp.cs
│ ├── DASwitch.cs
│ ├── DATextBox.cs
│ ├── DAThermometer.cs
│ ├── Doughnut_PLC.cs
│ ├── Histogram_PLC.cs
│ ├── IhatetheqrcodeSQL.Designer.cs
│ ├── IhatetheqrcodeSQL.cs
│ ├── IhatetheqrcodeSQL.resx
│ └── Oscillogram_PLC.cs
├── 按钮--TO--PLC方法
│ └── Button_PLC.cs
├── 控件类基
│ ├── Button_base.cs
│ ├── Combox_base.cs
│ ├── DataGridViewPLC_base.cs
│ ├── Doughnut_Base.cs
│ ├── Flicker_base.cs
│ ├── Histogram_base.cs
│ └── TextBox_base.cs
├── 文本--TO--PLC方法
│ └── TextBox_PLC.cs
├── 文本输入键盘
│ ├── keyboard.Designer.cs
│ ├── keyboard.cs
│ ├── keyboard.resx
│ ├── keyboard_Hex.Designer.cs
│ ├── keyboard_Hex.cs
│ └── keyboard_Hex.resx
├── 第三方控件DLL
│ ├── CSScriptLibrary.dll
│ ├── CSkin.XML
│ ├── CSkin.dll
│ ├── HZH_Controls.dll
│ ├── HslCommunication.dll
│ ├── Install_deployment.dll
│ ├── Interop.ActUtlTypeLib.dll
│ ├── Microsoft.Graph.Core.dll
│ ├── SunnyUI.dll
│ ├── System.Buffers.dll
│ ├── System.Buffers.xml
│ ├── UI_Library_da.dll
│ └── 快速访问 - 快捷方式.lnk
├── 表格控件--TO--PLC
│ ├── DataGridView_PLC.cs
│ └── 表格控件--TO--SQL
│ │ └── DADataGridView_SQL.cs
└── 设置控件
│ └── PLC_Open_Time.cs
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Bottom_Control.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30907.101
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bottom_Control", "Bottom_Control\Bottom_Control.csproj", "{9634B0AC-A87F-4725-BAEF-212DDF6A3C42}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {9634B0AC-A87F-4725-BAEF-212DDF6A3C42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {9634B0AC-A87F-4725-BAEF-212DDF6A3C42}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {9634B0AC-A87F-4725-BAEF-212DDF6A3C42}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {9634B0AC-A87F-4725-BAEF-212DDF6A3C42}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {6BA23F48-3E21-4ED2-82B8-61C991C15710}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Bottom_Control/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Bottom_Control/DAPLC_Time.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Bottom_Control
8 | {
9 | //==============================================================
10 | // 作者:BAtoDA
11 | // 时间:2021/2/17 21:54:45
12 | // 文件名:DAPLC_Time
13 | // 版本:V1.0.1
14 | // 说明: 实现PLC底层通讯定时刷新
15 | // 修改者:***
16 | // 修改说明:
17 | //==============================================================
18 | class DAPLC_Time
19 | {
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/Bottom_Control/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Bottom_Control
3 | {
4 | partial class Form1
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Windows Form Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.components = new System.ComponentModel.Container();
33 | this.daButton2 = new Bottom_Control.DAButton();
34 | this.daButton1 = new Bottom_Control.DAButton();
35 | this.SuspendLayout();
36 | //
37 | // daButton2
38 | //
39 | this.daButton2.BackColor = System.Drawing.Color.Transparent;
40 | this.daButton2.Backdrop_OFF = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
41 | this.daButton2.Backdrop_ON = System.Drawing.Color.Lime;
42 | this.daButton2.ControlState = CCWin.SkinClass.ControlState.Normal;
43 | this.daButton2.DownBack = null;
44 | this.daButton2.Location = new System.Drawing.Point(426, 124);
45 | this.daButton2.MouseBack = null;
46 | this.daButton2.Name = "daButton2";
47 | this.daButton2.NormlBack = null;
48 | this.daButton2.Pattern = Bottom_Control.Button_pattern.Regression;
49 | this.daButton2.Plc = Bottom_Control.PLC.Siemens;
50 | this.daButton2.PLC_Address = "0";
51 | this.daButton2.PLC_Contact = "I";
52 | this.daButton2.PLC_Enable = true;
53 | this.daButton2.Size = new System.Drawing.Size(109, 64);
54 | this.daButton2.TabIndex = 1;
55 | this.daButton2.Text = "daButton2";
56 | this.daButton2.UseVisualStyleBackColor = false;
57 | //
58 | // daButton1
59 | //
60 | this.daButton1.BackColor = System.Drawing.Color.Transparent;
61 | this.daButton1.Backdrop_OFF = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
62 | this.daButton1.Backdrop_ON = System.Drawing.Color.Lime;
63 | this.daButton1.ControlState = CCWin.SkinClass.ControlState.Normal;
64 | this.daButton1.DownBack = null;
65 | this.daButton1.Location = new System.Drawing.Point(225, 124);
66 | this.daButton1.MouseBack = null;
67 | this.daButton1.Name = "daButton1";
68 | this.daButton1.NormlBack = null;
69 | this.daButton1.Pattern = Bottom_Control.Button_pattern.Regression;
70 | this.daButton1.PLC_Address = "0";
71 | this.daButton1.PLC_Contact = "X";
72 | this.daButton1.PLC_Enable = false;
73 | this.daButton1.Size = new System.Drawing.Size(117, 42);
74 | this.daButton1.TabIndex = 0;
75 | this.daButton1.Text = "daButton1";
76 | this.daButton1.UseVisualStyleBackColor = false;
77 | //
78 | // Form1
79 | //
80 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
81 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
82 | this.ClientSize = new System.Drawing.Size(800, 450);
83 | this.Controls.Add(this.daButton2);
84 | this.Controls.Add(this.daButton1);
85 | this.Name = "Form1";
86 | this.Text = "Form1";
87 | this.ResumeLayout(false);
88 |
89 | }
90 |
91 | #endregion
92 |
93 | private DAButton daButton1;
94 | private DAButton daButton2;
95 | }
96 | }
--------------------------------------------------------------------------------
/Bottom_Control/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace Bottom_Control
12 | {
13 | public partial class Form1 : Form
14 | {
15 | public Form1()
16 | {
17 | InitializeComponent();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Bottom_Control/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Bottom_Control/PLC.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Bottom_Control
8 | {
9 | //==============================================================
10 | // 作者:BAtoDA
11 | // 时间:2021/2/15 13:01:45
12 | // 文件名:PLC
13 | // 版本:V1.0.1
14 | // 说明: 实现控件PLC选择
15 | // 修改者:***
16 | // 修改说明:
17 | //==============================================================
18 | public enum PLC
19 | {
20 | Mitsubishi,
21 | Siemens,
22 | MODBUS_TCP,
23 | HMI
24 | }
25 | ///
26 | /// PLC各可访问软元件 三菱-bit位
27 | ///
28 | public enum Mitsubishi_bit
29 | {
30 | /* LCS,LCC,*/
31 | SM, X, Y, M, L, F, B, TS, SS, SC, CS, CC, SB, S, D_Bit, SD_Bit, R_Bit, SW_Bit, W_Bit
32 | }
33 | ///
34 | /// PLC各可访问软元件 三菱 -WORD 字
35 | ///
36 | public enum Mitsubishi_D
37 | {
38 | /*LCN,LZ,*/
39 | SD, D, R, W, TN, SN, CN, SW, Z
40 | }
41 | ///
42 | /// PLC各可访问软元件 西门子 -bit位
43 | ///
44 | public enum Siemens_bit
45 | {
46 | I, Q, M, DB
47 | }
48 | ///
49 | /// PLC各可访问软元件 西门子-WORD 字
50 | ///
51 | public enum Siemens_D
52 | {
53 | DB, M
54 | }
55 | ///
56 | /// PLC各可访问软元件 Modbus_TCP -bit位
57 | ///
58 | public enum Modbus_TCP_bit
59 | {
60 | X, Y, M
61 | }
62 | ///
63 | /// PLC各可访问软元件 Modbus_TCP-WORD 字
64 | ///
65 | public enum Modbus_TCP_D
66 | {
67 | D
68 | }
69 | ///
70 | /// PLC各可访问软元件 三菱-bit位
71 | ///
72 | public enum HMI_bit
73 | {
74 | Data_Bit
75 | }
76 | ///
77 | /// PLC各可访问软元件 三菱 -WORD 字
78 | ///
79 | public enum HMI_D
80 | {
81 | Data_D
82 | }
83 | ///
84 | /// PLC--按钮状态
85 | ///
86 | public enum Button_state
87 | {
88 | Off, ON
89 | }
90 | ///
91 | /// 数值显示类型
92 | ///
93 | public enum numerical_format
94 | {
95 | BCD_16_Bit, BCD_32_Bit, Hex_16_Bit, Hex_32_Bit, Binary_16_Bit, Binary_32_Bit, Unsigned_16_Bit, Signed_16_Bit
96 | , Unsigned_32_Bit, Signed_32_Bit, Float_32_Bit, String_32_Bit
97 | }
98 | ///
99 | /// 数值显示类型
100 | ///
101 | public enum numerical_type
102 | {
103 | 数值
104 | }
105 | ///
106 | /// 按钮操作模式
107 | ///
108 | public enum Button_pattern//按钮模式类型枚举
109 | {
110 | Set_as_on, Set_as_off, selector_witch, Regression
111 | }
112 | public enum Button_select
113 | {
114 | Place,
115 | Indicator
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/Bottom_Control/PLC参数设置界面/ButtonBitForm1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Text.RegularExpressions;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 | using Sunny.UI;
12 | namespace Bottom_Control.PLC参数设置界面
13 | {
14 | public partial class ButtonBitForm1 : Sunny.UI.UIForm
15 | {
16 | int combox;
17 | string addeip, indx;
18 | public ButtonBitForm1(int combox, String indx, string addeip)
19 | {
20 | InitializeComponent();
21 | this.combox = combox;
22 | this.indx = indx;
23 | this.addeip = addeip;
24 | }
25 |
26 | private void ComboBoxSelecte(int data)
27 | {
28 | switch (data)
29 | {
30 | case 0:
31 | this.uiComboBox2.DataSource = Enum.GetNames(typeof(Mitsubishi_bit)).ToList();
32 | break;
33 | case 1:
34 | this.uiComboBox2.DataSource = Enum.GetNames(typeof(Siemens_bit)).ToList();
35 | break;
36 | case 2:
37 | this.uiComboBox2.DataSource = Enum.GetNames(typeof(Modbus_TCP_bit)).ToList();
38 | break;
39 | }
40 | this.uiComboBox2.SelectedIndex = 0;
41 | this.uiComboBox2.SelectedItem = 0;
42 | }
43 |
44 | private void ButtonBitForm1_Shown(object sender, EventArgs e)
45 | {
46 | ComboBoxSelecte(this.combox);
47 | this.uiComboBox1.SelectedIndex = combox;
48 | this.uiComboBox1.SelectedItem= combox;
49 | this.uiComboBox2.Text = this.indx;
50 | this.uiTextBox1.Text = addeip;
51 | }
52 |
53 | private void uiComboBox1_SelectedValueChanged(object sender, EventArgs e)
54 | {
55 | ComboBoxSelecte(this.uiComboBox1.SelectedIndex);
56 | }
57 | public string[] PLC_parameter { get; set; }
58 | public PLC pLC { get; set; }
59 | private void uiButton1_Click(object sender, EventArgs e)
60 | {
61 | //检查输入数据是否正确
62 | Regex reg = new Regex(@"^[A-Fa-z0-9]+(.[0-9]+)?$");
63 | if (reg.IsMatch(this.uiTextBox1.Text.Trim()) != true)
64 | {
65 | MessageBox.Show("PLC地址输入错误,输入了一个不可能访问到的地址");
66 | return;
67 | }
68 | PLC_parameter = new string[] { this.uiComboBox1.Text, this.uiComboBox2.Text, this.uiTextBox1.Text };
69 | pLC= (PLC)Enum.Parse(typeof(PLC), this.uiComboBox1.Text);
70 | this.Close();
71 | }
72 |
73 | private void KeyPress_reform(object sender, KeyPressEventArgs e)//键盘事件--位置与大小数据
74 | {
75 | if (e.KeyChar != '\b')//这是允许输入退格键
76 | {
77 | if ((e.KeyChar < '0') || (e.KeyChar > '9') || ((TextBox)sender).Text.Length > 5)//这是允许输入0-9数字 最大数据不能大于5位数
78 | {
79 | if (e.KeyChar == '.') return;
80 | e.Handled = true;//只能输入数字
81 | }
82 | }
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/Bottom_Control/PLC参数设置界面/ButtonBitForm1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Bottom_Control/PLC参数设置界面/ComboxForm1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using Sunny.UI;
11 | namespace Bottom_Control.PLC参数设置界面
12 | {
13 | public partial class ComboxForm1 : Sunny.UI.UIForm
14 | {
15 | int[] key;
16 | string[] Data;
17 | public ComboxForm1(int[] key,string[] Data)
18 | {
19 | InitializeComponent();
20 | this.key = key;
21 | this.Data = Data;
22 | }
23 |
24 | private void ComboxForm1_Load(object sender, EventArgs e)
25 | {
26 | this.uiDataGridView1.Rows.Add();
27 | for (int i=0;i
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | True
122 |
123 |
124 | True
125 |
126 |
--------------------------------------------------------------------------------
/Bottom_Control/PLC参数设置界面/TextboxDForm1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Text.RegularExpressions;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 | using Sunny.UI;
12 | namespace Bottom_Control.PLC参数设置界面
13 | {
14 | public partial class TextboxDForm1 : Sunny.UI.UIForm
15 | {
16 | int combox;
17 | string addeip, indx;
18 | public TextboxDForm1(int combox, String indx, string addeip)
19 | {
20 | InitializeComponent();
21 | this.combox = combox;
22 | this.indx = indx;
23 | this.addeip = addeip;
24 | }
25 | private void ComboBoxSelecte(int data)
26 | {
27 | switch (data)
28 | {
29 | case 0:
30 | this.uiComboBox2.DataSource = Enum.GetNames(typeof(Mitsubishi_D)).ToList();
31 | break;
32 | case 1:
33 | this.uiComboBox2.DataSource = Enum.GetNames(typeof(Siemens_D)).ToList();
34 | break;
35 | case 2:
36 | this.uiComboBox2.DataSource = Enum.GetNames(typeof(Modbus_TCP_D)).ToList();
37 | break;
38 | }
39 | this.uiComboBox2.SelectedIndex = 0;
40 | this.uiComboBox2.SelectedItem = 0;
41 | }
42 |
43 | private void TextboxDForm1_Shown(object sender, EventArgs e)
44 | {
45 | ComboBoxSelecte(this.combox);
46 | this.uiComboBox1.SelectedIndex = combox;
47 | this.uiComboBox1.SelectedItem = combox;
48 | this.uiComboBox2.Text = this.indx;
49 | this.uiTextBox1.Text = addeip;
50 | }
51 |
52 | private void uiComboBox1_SelectedValueChanged(object sender, EventArgs e)
53 | {
54 | ComboBoxSelecte(this.uiComboBox1.SelectedIndex);
55 | }
56 | public string[] PLC_parameter { get; set; }
57 | public PLC pLC { get; set; }
58 | private void uiButton1_Click(object sender, EventArgs e)
59 | {
60 | //检查输入数据是否正确
61 | Regex reg = new Regex(@"^[A-Fa-z0-9]+(.[0-9]+)?$");
62 | if (reg.IsMatch(this.uiTextBox1.Text.Trim()) != true)
63 | {
64 | MessageBox.Show("PLC地址输入错误,输入了一个不可能访问到的地址");
65 | return;
66 | }
67 | PLC_parameter = new string[] { this.uiComboBox1.Text, this.uiComboBox2.Text, this.uiTextBox1.Text };
68 | pLC = (PLC)Enum.Parse(typeof(PLC), this.uiComboBox1.Text);
69 | this.Close();
70 | }
71 | private void KeyPress_reform(object sender, KeyPressEventArgs e)//键盘事件--位置与大小数据
72 | {
73 | if (e.KeyChar != '\b')//这是允许输入退格键
74 | {
75 | if ((e.KeyChar < '0') || (e.KeyChar > '9') || ((TextBox)sender).Text.Length > 3)//这是允许输入0-9数字 最大数据不能大于3位数
76 | {
77 | if (e.KeyChar == '.') return;
78 | e.Handled = true;//只能输入数字
79 | }
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Bottom_Control/PLC参数设置界面/TextboxDForm1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Bottom_Control/PLC通讯协议/IPLC_interface.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Bottom_Control.PLC通讯协议
9 | {
10 | ///
11 | /// PLC实现接口--规范定义的方法名称Mitsubishi_realize
12 | ///
13 | public interface IPLC_interface//规范定义的方法名称
14 | {
15 | ///
16 | /// PLC IP与端口
17 | ///
18 | IPEndPoint IPEndPoint { get; set; }
19 | ///
20 | /// PLC准备好
21 | ///
22 | bool PLC_ready { get; }//PLC准备好
23 | ///
24 | /// PLC报警代码
25 | ///
26 | int PLCerr_code { get; }//PLC报警代码
27 | ///
28 | /// PLC报警内容
29 | ///
30 | string PLCerr_content { get; }//PLC报警内容
31 | ///
32 | /// 打开PLC
33 | ///
34 | ///
35 | string PLC_open();//打开PLC
36 | ///
37 | /// 读取--位
38 | ///
39 | ///
40 | ///
41 | ///
42 | List PLC_read_M_bit(string Name, string id);//读取--位
43 | ///
44 | /// /写入--位
45 | ///
46 | ///
47 | ///
48 | ///
49 | ///
50 | List PLC_write_M_bit(string Name, string id, Button_state button_State);//写入--位
51 | ///
52 | /// /读取--字
53 | ///
54 | ///
55 | ///
56 | ///
57 | ///
58 | string PLC_read_D_register(string Name, string id, numerical_format format);//读取--字
59 | ///
60 | /// 读写--字
61 | ///
62 | ///
63 | ///
64 | ///
65 | ///
66 | ///
67 | string PLC_write_D_register(string Name, string id, string content, numerical_format format);//读写--字
68 | ///
69 | /// 读取--字--多个读取-自动判断类型改变地址索引
70 | ///
71 | ///
72 | ///
73 | List PLC_read_D_register_bit(string Name, string id, numerical_format format, string Index);//读取--字--多个读取
74 | ///
75 | /// 读写--字
76 | ///
77 | ///
78 | ///
79 | List PLC_write_D_register_bit(string id);//读写--字
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Bottom_Control/PLC通讯协议/三菱报文/message.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Bottom_Control.PLC通讯协议.三菱报文
8 | {
9 | ///
10 | /// 可访问设备的软元件-类型是bit位
11 | /// 请指定读取、写入数据的对象模块中存在的软元件
12 | ///
13 | public enum message_bit
14 | {
15 | ///
16 | /// 内部用户软元件
17 | /// 内部继电器
18 | ///
19 | M = 0x90,
20 | ///
21 | /// 系统软元件
22 | /// 特殊继电器
23 | ///
24 | SM = 0x91,
25 | ///
26 | /// 内部用户软元件
27 | /// 输入
28 | ///
29 | X = 0x9C,
30 | ///
31 | /// 内部用户软元件
32 | /// 输出
33 | ///
34 | Y = 0x9D,
35 | ///
36 | /// 内部用户软元件
37 | /// 锁存继电器
38 | ///
39 | L = 0x92,
40 | ///
41 | /// 内部用户软元件
42 | /// 报警器
43 | ///
44 | F = 0x93,
45 | ///
46 | /// 内部用户软元件
47 | /// 变址继电器
48 | ///
49 | V = 0x94,
50 | ///
51 | /// 内部用户软元件
52 | /// 定时器-位触点
53 | ///
54 | TS = 0xC1,
55 | ///
56 | /// 内部用户软元件
57 | /// 定时器-线圈
58 | ///
59 | TC = 0xC2,
60 | ///
61 | /// 内部用户软元件
62 | /// 累计定时器-触点
63 | ///
64 | SS = 0xC7,
65 | ///
66 | /// 内部用户软元件
67 | /// 累计定时器-线圈
68 | ///
69 | SC = 0xC6,
70 | ///
71 | /// 内部用户软元件
72 | /// 计数器-触点
73 | ///
74 | CS = 0xC4,
75 | ///
76 | /// 内部用户软元件
77 | /// 计数器-线圈
78 | ///
79 | CC = 0xC3,
80 | ///
81 | /// 内部用户软元件
82 | /// 链接特殊继电器
83 | ///
84 | SB = 0xA1,
85 | ///
86 | /// 内部用户软元件
87 | /// 步继电器
88 | ///
89 | S = 0x98,
90 | }
91 | ///
92 | /// 可访问设备的软元件-类型是字或者双字
93 | /// 请指定读取、写入数据的对象模块中存在的软元件
94 | ///
95 | public enum message_Word
96 | {
97 | ///
98 | /// 系统软元件
99 | /// 特殊寄存器
100 | ///
101 | SD = 0xA9,
102 | ///
103 | /// 链接直接软元件
104 | /// 链接寄存器
105 | ///
106 | W = 0xB4,
107 | ///
108 | /// 链接直接软元件
109 | /// 链接继电器
110 | ///
111 | B = 0xA0,
112 | ///
113 | /// 内部用户软元件
114 | /// 数据寄存器
115 | ///
116 | D = 0xA8,
117 | ///
118 | /// 内部用户软元件
119 | /// 定时器-当前值
120 | ///
121 | TN = 0xC0,
122 | ///
123 | /// 内部用户软元件
124 | /// 累计定时器-当前值
125 | ///
126 | SN = 0xC8,
127 | ///
128 | /// 内部用户软元件
129 | /// 计数器-当前值
130 | ///
131 | CN = 0xC5,
132 | /////
133 | /////
134 | /////
135 | //DX = 0xA2,
136 | //DY = 0xA3,
137 | ///
138 | /// 变址寄存器
139 | ///
140 | Z = 0xCC,
141 | ///
142 | /// 文件寄存器
143 | ///
144 | R = 0xAF,
145 | ///
146 | /// 文件寄存器-延长
147 | ///
148 | ZR = 0xB0,
149 | ///
150 | /// 内部用户软元件
151 | /// 链接特殊寄存器
152 | ///
153 | SW = 0xB5
154 |
155 | }
156 | ///
157 | /// 用于选择访问设备返回的类型
158 | ///
159 | public enum numerical_format
160 | {
161 | ///
162 | /// 返回字节类型
163 | ///
164 | Byet,
165 | ///
166 | /// 返回16进制字
167 | ///
168 | Hex_16_Bit,
169 | ///
170 | /// 返回16进制双字
171 | ///
172 | Hex_32_Bit,
173 | ///
174 | /// 返回二进制字
175 | ///
176 | Binary_16_Bit,
177 | ///
178 | /// 返回二进制双字
179 | ///
180 | Binary_32_Bit,
181 | ///
182 | /// 返回无符号字
183 | ///
184 | Unsigned_16_Bit,
185 | ///
186 | /// 返回有符号字
187 | ///
188 | Signed_16_Bit,
189 | ///
190 | /// 返回无符号双字
191 | ///
192 | Unsigned_32_Bit,
193 | ///
194 | /// 返回有符号双字
195 | ///
196 | Signed_32_Bit,
197 | ///
198 | /// 返回有符号int64
199 | ///
200 | Signed_64_Bit,
201 | ///
202 | /// 返回单精度浮点小数
203 | ///
204 | Float_32_Bit
205 | }
206 | }
207 |
--------------------------------------------------------------------------------
/Bottom_Control/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 | using Bottom_Control.PLC参数设置界面;
7 |
8 | namespace Bottom_Control
9 | {
10 | static class Program
11 | {
12 | ///
13 | /// 应用程序的主入口点。
14 | ///
15 | [STAThread]
16 | static void Main()
17 | {
18 | Application.EnableVisualStyles();
19 | Application.SetCompatibleTextRenderingDefault(false);
20 | Application.Run(new Form1());
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Bottom_Control/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Bottom_Control")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Bottom_Control")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("9634b0ac-a87f-4725-baef-212ddf6a3c42")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Bottom_Control/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能导致不正确的行为,如果
7 | // 重新生成代码,则所做更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace Bottom_Control.Properties
13 | {
14 | ///
15 | /// 强类型资源类,用于查找本地化字符串等。
16 | ///
17 | // 此类是由 StronglyTypedResourceBuilder
18 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
19 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
20 | // (以 /str 作为命令选项),或重新生成 VS 项目。
21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24 | internal class Resources
25 | {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources()
33 | {
34 | }
35 |
36 | ///
37 | /// 返回此类使用的缓存 ResourceManager 实例。
38 | ///
39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
40 | internal static global::System.Resources.ResourceManager ResourceManager
41 | {
42 | get
43 | {
44 | if ((resourceMan == null))
45 | {
46 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bottom_Control.Properties.Resources", typeof(Resources).Assembly);
47 | resourceMan = temp;
48 | }
49 | return resourceMan;
50 | }
51 | }
52 |
53 | ///
54 | /// 重写当前线程的 CurrentUICulture 属性,对
55 | /// 使用此强类型资源类的所有资源查找执行重写。
56 | ///
57 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
58 | internal static global::System.Globalization.CultureInfo Culture
59 | {
60 | get
61 | {
62 | return resourceCulture;
63 | }
64 | set
65 | {
66 | resourceCulture = value;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Bottom_Control/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Bottom_Control/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Bottom_Control.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 |
26 | [global::System.Configuration.ApplicationScopedSettingAttribute()]
27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28 | [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
29 | [global::System.Configuration.DefaultSettingValueAttribute("Data Source=DESKTOP-955LB02\\SQLEXPRESS;Initial Catalog=XN;Integrated Security=Tru" +
30 | "e")]
31 | public string XNConnectionString {
32 | get {
33 | return ((string)(this["XNConnectionString"]));
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Bottom_Control/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | <?xml version="1.0" encoding="utf-16"?>
7 | <SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
8 | <ConnectionString>Data Source=DESKTOP-955LB02\SQLEXPRESS;Initial Catalog=XN;Integrated Security=True</ConnectionString>
9 | <ProviderName>System.Data.SqlClient</ProviderName>
10 | </SerializableConnectionString>
11 | Data Source=DESKTOP-955LB02\SQLEXPRESS;Initial Catalog=XN;Integrated Security=True
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Bottom_Control/Public_Class.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection.Emit;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Bottom_Control
9 | {
10 | //==============================================================
11 | // 作者:BAtoDA
12 | // 时间:2021/2/15 13:38:25
13 | // 文件名:Public_Class
14 | // 版本:V1.0.1
15 | // 说明: 实现处理控件一些公共方法
16 | // 修改者:***
17 | // 修改说明:
18 | //==============================================================
19 | class Public_Class
20 | {
21 | ///
22 | /// 按钮类PLC选择 根据PLC类型改变辅助触点类型
23 | ///
24 | /// 选择的PLC
25 | ///
26 | public static object PLC_button(PLC pLC)
27 | {
28 | switch(pLC)
29 | {
30 | case PLC.HMI:
31 | return Enum.GetNames(typeof(HMI_bit));
32 | case PLC.Mitsubishi:
33 | return Enum.GetNames(typeof(Mitsubishi_bit));
34 | case PLC.MODBUS_TCP:
35 | return Enum.GetNames(typeof(Modbus_TCP_bit));
36 | case PLC.Siemens:
37 | return Enum.GetNames(typeof(Siemens_bit));
38 | }
39 | return Enum.GetNames(typeof(Mitsubishi_bit));
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Bottom_Control/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Bottom_Control/二维码生成/IhatetheqrcodeCreate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Drawing.Imaging;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using ZXing;
9 | using ZXing.Common;
10 | using ZXing.QrCode;
11 | using ZXing.QrCode.Internal;
12 |
13 | namespace Bottom_Control.二维码生成
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/22 16:08:39
18 | // 文件名:IhatetheqrcodeCreate
19 | // 版本:V1.0.1
20 | // 说明: 实现二维码或者条形码生成
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现二维码或者条形码生成
26 | ///
27 | class IhatetheqrcodeCreate
28 | {
29 | ///
30 | /// 显示内容
31 | ///
32 | public string Data { get; set; } = "123456789";
33 |
34 | ///
35 | /// 选择显示条形码还是二维码--默认二维码
36 | ///
37 | public bool select { get; set; } = false;
38 |
39 | ///
40 | /// 构造函数
41 | ///
42 | public IhatetheqrcodeCreate()
43 | {
44 | }
45 | ///
46 | /// 生成二维码
47 | ///
48 | /// 内容
49 | /// 宽度
50 | /// 高度
51 | ///
52 | public Bitmap Generate1(string text, int width, int height)
53 | {
54 | BarcodeWriter writer = new BarcodeWriter();
55 | writer.Format = BarcodeFormat.QR_CODE;
56 | QrCodeEncodingOptions options = new QrCodeEncodingOptions()
57 | {
58 | DisableECI = true,//设置内容编码
59 | CharacterSet = "UTF-8", //设置二维码的宽度和高度
60 | Width = width,
61 | Height = height,
62 | Margin = 1//设置二维码的边距,单位不是固定像素
63 | };
64 |
65 | writer.Options = options;
66 | Bitmap map = writer.Write(text ?? "123456789");
67 | return map;
68 | }
69 |
70 | ///
71 | /// 生成一维条形码
72 | ///
73 | /// 内容
74 | /// 宽度
75 | /// 高度
76 | ///
77 | public Bitmap Generate2(string text, int width, int height)
78 | {
79 | BarcodeWriter writer = new BarcodeWriter();
80 | //使用ITF 格式,不能被现在常用的支付宝、微信扫出来
81 | //如果想生成可识别的可以使用 CODE_128 格式
82 | //writer.Format = BarcodeFormat.ITF;
83 | writer.Format = BarcodeFormat.CODE_39;
84 | EncodingOptions options = new EncodingOptions()
85 | {
86 | Width = width,
87 | Height = height,
88 | Margin = 2
89 | };
90 | writer.Options = options;
91 | Bitmap map = writer.Write(text.Trim() ?? "123456789");
92 | return map;
93 | }
94 |
95 | ///
96 | /// 生成带Logo的二维码
97 | ///
98 | /// 内容
99 | /// 宽度
100 | /// 高度
101 | public Bitmap Generate3(string text, int width, int height)
102 | {
103 | //Logo 图片
104 | string logoPath = System.AppDomain.CurrentDomain.BaseDirectory + @"\img\logo.png";
105 | Bitmap logo = new Bitmap(logoPath);
106 | //构造二维码写码器
107 | MultiFormatWriter writer = new MultiFormatWriter();
108 | Dictionary hint = new Dictionary();
109 | hint.Add(EncodeHintType.CHARACTER_SET, "UTF-8");
110 | hint.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
111 | //hint.Add(EncodeHintType.MARGIN, 2);//旧版本不起作用,需要手动去除白边
112 |
113 | //生成二维码
114 | BitMatrix bm = writer.encode(text, BarcodeFormat.QR_CODE, width + 30, height + 30, hint);
115 | bm = deleteWhite(bm);
116 | BarcodeWriter barcodeWriter = new BarcodeWriter();
117 | Bitmap map = barcodeWriter.Write(bm);
118 |
119 | //获取二维码实际尺寸(去掉二维码两边空白后的实际尺寸)
120 | int[] rectangle = bm.getEnclosingRectangle();
121 |
122 | //计算插入图片的大小和位置
123 | int middleW = Math.Min((int)(rectangle[2] / 3), logo.Width);
124 | int middleH = Math.Min((int)(rectangle[3] / 3), logo.Height);
125 | int middleL = (map.Width - middleW) / 2;
126 | int middleT = (map.Height - middleH) / 2;
127 |
128 | Bitmap bmpimg = new Bitmap(map.Width, map.Height, PixelFormat.Format32bppArgb);
129 | using (Graphics g = Graphics.FromImage(bmpimg))
130 | {
131 | g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
132 | g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
133 | g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
134 | g.DrawImage(map, 0, 0, width, height);
135 | //白底将二维码插入图片
136 | g.FillRectangle(Brushes.White, middleL, middleT, middleW, middleH);
137 | g.DrawImage(logo, middleL, middleT, middleW, middleH);
138 | }
139 | return bmpimg;
140 | }
141 |
142 | ///
143 | /// 删除默认对应的空白
144 | ///
145 | ///
146 | ///
147 | private BitMatrix deleteWhite(BitMatrix matrix)
148 | {
149 | int[] rec = matrix.getEnclosingRectangle();
150 | int resWidth = rec[2] + 1;
151 | int resHeight = rec[3] + 1;
152 |
153 | BitMatrix resMatrix = new BitMatrix(resWidth, resHeight);
154 | resMatrix.clear();
155 | for (int i = 0; i < resWidth; i++)
156 | {
157 | for (int j = 0; j < resHeight; j++)
158 | {
159 | if (matrix[i + rec[0], j + rec[1]])
160 | resMatrix[i, j] = true;
161 | }
162 | }
163 | return resMatrix;
164 | }
165 |
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAAlarmLamp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Bottom_Control.PLC参数设置界面;
9 | using Bottom_Control.按钮__TO__PLC方法;
10 | using Bottom_Control.控件类基;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/20 15:59:46
18 | // 文件名:DAAlarmLamp
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 指示灯带闪烁类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 指示灯带闪烁类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 指示灯带闪烁类 -不再公共运行时")]
30 | public class DAAlarmLamp: UCAlarmLamp, Button_base, Flicker_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | ButtonBitForm1 buttonBitForm = new ButtonBitForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !Button_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "X";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("按钮参数 ON时触发背景颜色"), Category("PLC-按钮参数")]
93 | [DefaultValue(typeof(Color), "111, 168, 255")]
94 | public Color Backdrop_ON { get; set; } = Color.FromName("Lime");
95 | [Description("按钮参数 OFF时触发背景颜色"), Category("PLC-按钮参数")]
96 | [DefaultValue(typeof(Color), "Control")]
97 | public Color Backdrop_OFF { get; set; } = Color.FromArgb(74, 131, 229);
98 | [Description("按钮按下状态"), Category("PLC-按钮参数")]
99 | public bool Command { get; set; }
100 | public bool Button_select { get; set; }
101 | [Description("按钮操作模式"), Category("PLC-按钮参数")]
102 | public Button_pattern Pattern { get; set; } = Button_pattern.Regression;
103 | public string Text_ON { get; set; } = "ON";
104 | public string Text_OFF { get; set; } = "OFF";
105 | ///
106 | /// 定时刷新 定时器
107 | ///
108 | [Description("按钮刷新定时器"), Category("PLC-按钮参数")]
109 | [DefaultValue(typeof(string), "PLC_time")]
110 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
111 |
112 | ///
113 | /// PLC通讯协议对象
114 | ///
115 | Button_PLC plc;
116 | #endregion
117 | #region 实现闪烁接口参数
118 | [Description("值为0时 是否开启闪烁功能"), Category("PLC类型-闪烁参数")]
119 | [DefaultValue(typeof(bool), "false")]
120 | public bool O_Flicker { get; set; } = false;
121 | [Description("值为0时 闪烁颜色变换队列"), Category("PLC类型-闪烁参数")]
122 | public Color[] O_FlickerColor { get; set; } = new Color[] { Color.FromArgb(255, 77, 59) };
123 | [Description("值为0时 闪烁颜色变换时间"), Category("PLC类型-闪烁参数")]
124 | public int O_FlickerTime { get; set; } = 1000;
125 | [Description("值为1时 是否开启闪烁功能"), Category("PLC类型-闪烁参数")]
126 | [DefaultValue(typeof(bool), "false")]
127 | public bool I_Flicker { get; set; } = false;
128 | [Description("值为1时 闪烁颜色变换队列"), Category("PLC类型-闪烁参数")]
129 | public Color[] I_FlickerColor { get; set; } = new Color[] { Color.FromArgb(255, 77, 59) };
130 | [Description("值为1时 闪烁颜色变换时间"), Category("PLC类型-闪烁参数")]
131 | public int I_FlickerTime { get; set; } = 1000;
132 | #endregion
133 | public DAAlarmLamp()
134 | {
135 | plc = new Button_PLC();
136 | PLC_time.Start();
137 | PLC_time.Tick += new EventHandler(Time_tick);
138 | }
139 | protected override void Dispose(bool disposing)//释放托管资源
140 | {
141 | base.Dispose(disposing);
142 | plc.Dispose();
143 | this.PLC_time.Dispose();
144 | }
145 | ///
146 | /// 定时器到达事件
147 | ///
148 | ///
149 | ///
150 | private void Time_tick(object send, EventArgs e)
151 | {
152 | if (!plc_Enable || this.IsDisposed || this.Created == false) return;//用户不开启PLC功能
153 |
154 | plc.Refresh(this, this.Plc);
155 |
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAAnalogMeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Bottom_Control.PLC参数设置界面;
9 | using Bottom_Control.按钮__TO__PLC方法;
10 | using Bottom_Control.控件类基;
11 | using Bottom_Control.文本__TO__PLC方法;
12 | using Sunny.UI;
13 | using 自定义Uppercomputer_20200727.文本输入键盘;
14 |
15 | namespace Bottom_Control.基本控件
16 | {
17 | //==============================================================
18 | // 作者:BAtoDA
19 | // 时间:2021/2/18 21:16:55
20 | // 文件名:DAAnalogMeter
21 | // 版本:V1.0.1
22 | // 说明:实现上位机底层控件 表盘类 -不再公共运行时
23 | // 修改者:***
24 | // 修改说明:
25 | //==============================================================
26 | ///
27 | /// 实现上位机底层控件 表盘类 -不再公共运行时
28 | ///
29 | [ToolboxItem(true)]
30 | [Browsable(true)]
31 | [Description("实现上位机底层控件 表盘类 -不再公共运行时 ")]
32 | public class DAAnalogMeter: UIAnalogMeter, TextBox_base
33 | {
34 | #region 实现接口参数
35 | public event EventHandler Modification;
36 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
37 | [DefaultValue(typeof(PLC), "Mitsubishi")]
38 | public PLC Plc
39 | {
40 | get => pLC_valu;
41 | set
42 | {
43 | if (plc_Enable)
44 | {
45 | this.Modification += new EventHandler(Modifications_Eeve);
46 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
47 | this.Modification -= new EventHandler(Modifications_Eeve);
48 | return;
49 | }
50 | pLC_valu = value;
51 | }
52 | }
53 | private PLC pLC_valu;
54 | [Description("是否启用PLC功能"), Category("PLC类型")]
55 | public bool PLC_Enable
56 | {
57 | get => plc_Enable;
58 | set => plc_Enable = value;
59 | }
60 | private bool plc_Enable = false;
61 |
62 | public void Modifications_Eeve(object send, EventArgs e)
63 | {
64 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
65 | buttonBitForm.ShowDialog();
66 | if (buttonBitForm.PLC_parameter.Length < 1) return;
67 | pLC_valu = buttonBitForm.pLC;
68 | PLC_Contact = buttonBitForm.PLC_parameter[1];
69 | plc_Address = buttonBitForm.PLC_parameter[2];
70 | }
71 | [Description("PLC读取触点"), Category("PLC类型")]
72 | public string PLC_Contact
73 | {
74 | get => plc_Contact;
75 | set
76 | {
77 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
78 | throw new Exception("参数设置错误");
79 | plc_Contact = value;
80 | }
81 | }
82 | private string plc_Contact = "D";
83 | [Description("PLC访问地址"), Category("PLC类型")]
84 | public string PLC_Address
85 | {
86 | get => plc_Address;
87 | set
88 | {
89 | if (Button_PLC.Address(value))
90 | plc_Address = value;
91 | }
92 | }
93 | private string plc_Address = "0";
94 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
95 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
96 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
97 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
98 | [DefaultValue(typeof(int), "8")]
99 | public int Decimal_Above { get; set; } = 8;
100 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
101 | [DefaultValue(typeof(int), "0")]
102 | public int Decimal_Below { get; set; } = 0;
103 | public string Control_Text { get => Convert.ToString(this.Value); set => this.Value=Convert.ToDouble(value); }
104 | ///
105 | /// 定时刷新 定时器
106 | ///
107 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
108 | [DefaultValue(typeof(string), "PLC_time")]
109 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
110 | ///
111 | /// PLC通讯对象
112 | ///
113 | TextBox_PLC pLC;
114 | #endregion
115 | ///
116 | /// 构造函数
117 | ///
118 | public DAAnalogMeter()
119 | {
120 | pLC = new TextBox_PLC();
121 | PLC_time.Start();
122 | PLC_time.Tick += new EventHandler(Time_tick);
123 | this.Text = "00";
124 | this.BackColor = Color.Transparent;
125 | this.BodyColor = Color.Transparent;
126 | this.NeedleColor = Color.YellowGreen;
127 | this.ScaleColor = Color.Black;
128 | this.ForeColor= Color.Black;
129 | }
130 | ///
131 | /// 定时器到达事件
132 | ///
133 | ///
134 | ///
135 | private void Time_tick(object send, EventArgs e)
136 | {
137 | lock (this)
138 | {
139 | pLC.Refresh(this);
140 | }
141 | }
142 | protected override void Dispose(bool disposing)//重写释放托管资源
143 | {
144 | this.PLC_time.Dispose();
145 | base.Dispose(disposing);
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DABottle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Bottom_Control.PLC参数设置界面;
8 | using Bottom_Control.按钮__TO__PLC方法;
9 | using Bottom_Control.控件类基;
10 | using Bottom_Control.文本__TO__PLC方法;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/20 13:54:30
18 | // 文件名:DABottle
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 瓶子类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 瓶子类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 瓶子类 -不再公共运行时 ")]
30 | public class DABottle: UCBottle, TextBox_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "D";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
93 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
94 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
95 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
96 | [DefaultValue(typeof(int), "8")]
97 | public int Decimal_Above { get; set; } = 8;
98 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
99 | [DefaultValue(typeof(int), "0")]
100 | public int Decimal_Below { get; set; } = 0;
101 | public string Control_Text { get => Convert.ToString(this.Value); set => this.Value = Convert.ToInt32(value); }
102 | ///
103 | /// 定时刷新 定时器
104 | ///
105 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
106 | [DefaultValue(typeof(string), "PLC_time")]
107 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
108 | ///
109 | /// PLC通讯对象
110 | ///
111 | TextBox_PLC pLC;
112 | #endregion
113 | ///
114 | /// 构造函数
115 | ///
116 | public DABottle()
117 | {
118 | pLC = new TextBox_PLC();
119 | PLC_time.Start();
120 | PLC_time.Tick += new EventHandler(Time_tick);
121 | this.Text = "00";
122 | }
123 | ///
124 | /// 定时器到达事件
125 | ///
126 | ///
127 | ///
128 | private void Time_tick(object send, EventArgs e)
129 | {
130 | lock (this)
131 | {
132 | pLC.Refresh(this);
133 | }
134 | }
135 | protected override void Dispose(bool disposing)//重写释放托管资源
136 | {
137 | this.PLC_time.Dispose();
138 | base.Dispose(disposing);
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DACheckBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 | using Bottom_Control.PLC参数设置界面;
10 | using Bottom_Control.按钮__TO__PLC方法;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/18 18:23:41
18 | // 文件名:DACheckBox
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 单选类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 单选类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 单选类 -不再公共运行时")]
30 | public class DACheckBox: UCCheckBox, Button_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | ButtonBitForm1 buttonBitForm = new ButtonBitForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !Button_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "X";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("按钮参数 ON时触发背景颜色"), Category("PLC-按钮参数")]
93 | [DefaultValue(typeof(Color), "111, 168, 255")]
94 | public Color Backdrop_ON { get; set; } = Color.FromName("Lime");
95 | [Description("按钮参数 OFF时触发背景颜色"), Category("PLC-按钮参数")]
96 | [DefaultValue(typeof(Color), "Control")]
97 | public Color Backdrop_OFF { get; set; } = Color.FromArgb(74, 131, 229);
98 | [Description("按钮按下状态"), Category("PLC-按钮参数")]
99 | [DefaultValue(typeof(bool), "false")]
100 | public bool Command { get; set; }
101 | [Description("按钮类型选择 true 位指示灯 false 位处理"), Category("PLC-按钮参数")]
102 | [DefaultValue(typeof(bool), "false")]
103 | public bool Button_select { get; set; }
104 | [Description("按钮操作模式"), Category("PLC-按钮参数")]
105 | [DefaultValue(typeof(Button_pattern), "复归型")]
106 | public Button_pattern Pattern { get; set; } = Button_pattern.Regression;
107 | [Description("控件为ON时显示的文本值"), Category("PLC-按钮参数")]
108 | [DefaultValue(typeof(string), "ON")]
109 | public string Text_ON { get; set; } = "ON";
110 | [Description("控件为OFF时显示的文本值"), Category("PLC-按钮参数")]
111 | [DefaultValue(typeof(string), "OFF")]
112 | public string Text_OFF { get; set; } = "OFF";
113 | ///
114 | /// 定时刷新 定时器
115 | ///
116 | [Description("按钮刷新定时器"), Category("PLC-按钮参数")]
117 | [DefaultValue(typeof(string), "PLC_time")]
118 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
119 | ///
120 | /// PLC通讯协议对象
121 | ///
122 | Button_PLC plc;
123 | #endregion
124 | public DACheckBox()
125 | {
126 | plc = new Button_PLC();
127 | PLC_time.Start();
128 | PLC_time.Tick += new EventHandler(Time_tick);
129 | }
130 | protected override void OnClick(EventArgs e)//重写点击事件
131 | {
132 | if (!plc_Enable || Button_select) return;//用户不开启PLC功能
133 | this.BeginInvoke((EventHandler)delegate
134 | {
135 | plc.plc(this);
136 | });
137 | }
138 | protected override void OnMouseUp(MouseEventArgs e)//重写松开事件
139 | {
140 | if (!plc_Enable || Button_select) return;//用户不开启PLC功能
141 | this.BeginInvoke((MethodInvoker)delegate
142 | {
143 | if (plc.state)
144 | plc.plc(this, plc.state);
145 | });
146 | }
147 | protected override void Dispose(bool disposing)//释放托管资源
148 | {
149 | base.Dispose(disposing);
150 | plc.Dispose();
151 | this.PLC_time.Dispose();
152 | }
153 | ///
154 | /// 定时器到达事件
155 | ///
156 | ///
157 | ///
158 | private void Time_tick(object send, EventArgs e)
159 | {
160 | if (!plc_Enable) return;//用户不开启PLC功能
161 | lock (this)
162 | {
163 | plc.Refresh(this, this.Plc);
164 | }
165 | }
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAConduit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Bottom_Control.PLC参数设置界面;
9 | using Bottom_Control.按钮__TO__PLC方法;
10 | using Bottom_Control.控件类基;
11 | using Bottom_Control.文本__TO__PLC方法;
12 | using HZH_Controls.Controls;
13 |
14 | namespace Bottom_Control.基本控件
15 | {
16 | //==============================================================
17 | // 作者:BAtoDA
18 | // 时间:2021/2/20 11:05:55
19 | // 文件名:DAConduit
20 | // 版本:V1.0.1
21 | // 说明: 实现上位机底层控件 管道类 -不再公共运行时
22 | // 修改者:***
23 | // 修改说明:
24 | //==============================================================
25 | ///
26 | /// 实现上位机底层控件 管道类 -不再公共运行时
27 | ///
28 | [ToolboxItem(true)]
29 | [Browsable(true)]
30 | [Description("实现上位机底层控件 管道类 -不再公共运行时")]
31 | public class DAConduit:UCConduit, Button_base
32 | {
33 | #region 实现接口参数
34 | public event EventHandler Modification;
35 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
36 | [DefaultValue(typeof(PLC), "Mitsubishi")]
37 | public PLC Plc
38 | {
39 | get => pLC_valu;
40 | set
41 | {
42 | if (plc_Enable)
43 | {
44 | this.Modification += new EventHandler(Modifications_Eeve);
45 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
46 | this.Modification -= new EventHandler(Modifications_Eeve);
47 | return;
48 | }
49 | pLC_valu = value;
50 | }
51 | }
52 | private PLC pLC_valu;
53 | [Description("是否启用PLC功能"), Category("PLC类型")]
54 | public bool PLC_Enable
55 | {
56 | get => plc_Enable;
57 | set => plc_Enable = value;
58 | }
59 | private bool plc_Enable = false;
60 |
61 | public void Modifications_Eeve(object send, EventArgs e)
62 | {
63 | ButtonBitForm1 buttonBitForm = new ButtonBitForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
64 | buttonBitForm.ShowDialog();
65 | if (buttonBitForm.PLC_parameter.Length < 1) return;
66 | pLC_valu = buttonBitForm.pLC;
67 | PLC_Contact = buttonBitForm.PLC_parameter[1];
68 | plc_Address = buttonBitForm.PLC_parameter[2];
69 | }
70 | [Description("PLC读取触点"), Category("PLC类型")]
71 | public string PLC_Contact
72 | {
73 | get => plc_Contact;
74 | set
75 | {
76 | if (value == null || !Button_PLC.IsNull(value, Plc))
77 | throw new Exception("参数设置错误");
78 | plc_Contact = value;
79 | }
80 | }
81 | private string plc_Contact = "X";
82 | [Description("PLC访问地址"), Category("PLC类型")]
83 | public string PLC_Address
84 | {
85 | get => plc_Address;
86 | set
87 | {
88 | if (Button_PLC.Address(value))
89 | plc_Address = value;
90 | }
91 | }
92 | private string plc_Address = "0";
93 | [Description("按钮参数 ON时触发背景颜色"), Category("PLC-按钮参数")]
94 | [DefaultValue(typeof(Color), "111, 168, 255")]
95 | public Color Backdrop_ON { get; set; } = Color.FromName("Lime");
96 | [Description("按钮参数 OFF时触发背景颜色"), Category("PLC-按钮参数")]
97 | [DefaultValue(typeof(Color), "Control")]
98 | public Color Backdrop_OFF { get; set; } = Color.FromArgb(74, 131, 229);
99 | [Description("按钮按下状态"), Category("PLC-按钮参数")]
100 | [DefaultValue(typeof(bool), "false")]
101 | public bool Command { get; set; }
102 | [Description("按钮类型选择 true 位指示灯 false 位处理"), Category("PLC-按钮参数")]
103 | [DefaultValue(typeof(bool), "false")]
104 | public bool Button_select { get; set; }
105 | [Description("按钮操作模式"), Category("PLC-按钮参数")]
106 | [DefaultValue(typeof(Button_pattern), "复归型")]
107 | public Button_pattern Pattern { get; set; } = Button_pattern.Regression;
108 | [Description("控件为ON时显示的文本值"), Category("PLC-按钮参数")]
109 | [DefaultValue(typeof(string), "ON")]
110 | public string Text_ON { get; set; } = "ON";
111 | [Description("控件为OFF时显示的文本值"), Category("PLC-按钮参数")]
112 | [DefaultValue(typeof(string), "OFF")]
113 | public string Text_OFF { get; set; } = "OFF";
114 | ///
115 | /// 定时刷新 定时器
116 | ///
117 | [Description("按钮刷新定时器"), Category("PLC-按钮参数")]
118 | [DefaultValue(typeof(string), "PLC_time")]
119 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
120 | ///
121 | /// PLC通讯协议对象
122 | ///
123 | Button_PLC plc;
124 | #endregion
125 | public DAConduit()
126 | {
127 | plc = new Button_PLC();
128 | PLC_time.Start();
129 | PLC_time.Tick += new EventHandler(Time_tick);
130 | }
131 | protected override void Dispose(bool disposing)//释放托管资源
132 | {
133 | base.Dispose(disposing);
134 | plc.Dispose();
135 | this.PLC_time.Dispose();
136 | }
137 | ///
138 | /// 定时器到达事件
139 | ///
140 | ///
141 | ///
142 | private void Time_tick(object send, EventArgs e)
143 | {
144 | if (!plc_Enable) return;//用户不开启PLC功能
145 | plc.Refresh(this, this.Plc);
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAConveyor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 | using Bottom_Control.PLC参数设置界面;
10 | using Bottom_Control.按钮__TO__PLC方法;
11 | using Bottom_Control.控件类基;
12 | using HZH_Controls.Controls;
13 |
14 | namespace Bottom_Control.基本控件
15 | {
16 | //==============================================================
17 | // 作者:BAtoDA
18 | // 时间:2021/2/20 16:18:14
19 | // 文件名:DAConveyor
20 | // 版本:V1.0.1
21 | // 说明: 实现上位机底层控件 皮带类 -不再公共运行时
22 | // 修改者:***
23 | // 修改说明:
24 | //==============================================================
25 | ///
26 | /// 实现上位机底层控件 皮带类 -不再公共运行时
27 | ///
28 | [ToolboxItem(true)]
29 | [Browsable(true)]
30 | [Description("实现上位机底层控件 皮带类 -不再公共运行时")]
31 | public class DAConveyor: UCConveyor
32 | {
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DADataGridView_TO_PLCE.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using Bottom_Control.控件类基;
11 |
12 | namespace Bottom_Control.基本控件
13 | {
14 | ///
15 | /// 实现上位机底层控件 文本类 -不再公共运行时
16 | ///
17 | [ToolboxItem(true)]
18 | [Browsable(true)]
19 | [Description("实现上位机底层控件 定时从PLC自定寄存器读取数据 PLC读取表格类 -不再公共运行时")]
20 | public partial class DADataGridView_TO_PLCE : UserControl
21 | {
22 |
23 | #region 实现接口参数
24 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
25 | [DefaultValue(typeof(PLC), "Mitsubishi")]
26 | public PLC Plc { get => this.daDataGridView_TO_PLC2.Plc; set => this.daDataGridView_TO_PLC2.Plc = value; }
27 | [Description("是否启用PLC功能"), Category("PLC类型")]
28 | public bool PLC_Enable { get => this.daDataGridView_TO_PLC2.PLC_Enable; set => this.daDataGridView_TO_PLC2.PLC_Enable = value; }
29 | [Description("PLC读取触点"), Category("PLC类型")]
30 | public string PLC_Contact { get => this.daDataGridView_TO_PLC2.PLC_Contact; set => this.daDataGridView_TO_PLC2.PLC_Contact = value; }
31 | public string PLC_Address { get => this.daDataGridView_TO_PLC2.PLC_Address; set => this.daDataGridView_TO_PLC2.PLC_Address = value; }
32 | [DefaultValue(typeof(int), "8")]
33 | public int Decimal_Above { get => this.daDataGridView_TO_PLC2.Decimal_Above; set => this.daDataGridView_TO_PLC2.Decimal_Above = value; }
34 | [DefaultValue(typeof(int), "0")]
35 | public int Decimal_Below { get => this.daDataGridView_TO_PLC2.Decimal_Below; set => this.daDataGridView_TO_PLC2.Decimal_Below = value; }
36 | ///
37 | /// 定时刷新 定时器
38 | ///
39 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
40 | [DefaultValue(typeof(string), "PLC_time")]
41 | public System.Windows.Forms.Timer PLC_time { get => this.daDataGridView_TO_PLC2.PLC_time; }
42 | [Description("读取PLC的地址--对应表格列"), Category("PLC-控件参数")]
43 | public string[] PLC_address { get => this.daDataGridView_TO_PLC2.PLC_address; set => this.daDataGridView_TO_PLC2.PLC_address = value; }
44 | [Description("表格列显示的名称--对应表格列"), Category("PLC-控件参数")]
45 | public string[] DataGridView_Name { get => this.daDataGridView_TO_PLC2.DataGridView_Name; set => this.daDataGridView_TO_PLC2.DataGridView_Name = value; }
46 | [Description("表格列读取PLC的类型--对应表格列"), Category("PLC-控件参数")]
47 | public numerical_format[] DataGridView_numerical { get => this.daDataGridView_TO_PLC2.DataGridView_numerical; set => this.daDataGridView_TO_PLC2.DataGridView_numerical = value; }
48 | [Description("指示着是否显示读取时间列"), Category("PLC-控件参数")]
49 | public bool DataGridViewPLC_Time { get => this.daDataGridView_TO_PLC2.DataGridViewPLC_Time; set => this.daDataGridView_TO_PLC2.DataGridViewPLC_Time = value; }
50 |
51 | #endregion
52 | public DADataGridView_TO_PLCE()
53 | {
54 | InitializeComponent();
55 | this.daDataGridView_TO_PLC2.SizeChanged += ((Send, e1) =>
56 | {
57 | this.Size = this.daDataGridView_TO_PLC2.Size;
58 | });
59 | }
60 |
61 | protected override void OnParentChanged(EventArgs e)
62 | {
63 | this.daDataGridView_TO_PLC2.OnParentChanged1(new EventArgs());
64 |
65 | }
66 | private void DADataGridView_TO_PLC1_Load(object sender, EventArgs e)
67 | {
68 |
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DADataGridView_TO_PLCE.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DADataGridView_TO_SQL.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data.SqlClient;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 | using Bottom_Control.表格控件__TO__PLC;
10 | using Bottom_Control.表格控件__TO__PLC.表格控件__TO__SQL;
11 | using CCWin.SkinControl;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/26 8:48:31
18 | // 文件名:DADataGridView_TO_SQL
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 表格控件从SQL进行增删改查操作
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 表格控件从SQL进行增删改查操作
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 表格控件从SQL进行增删改查操作")]
30 | public class DADataGridView_TO_SQL : DataGridView
31 | {
32 | #region
33 | [Description("SQL链接字符串--仅支持用户名 密码 登录不支持Win身份登录 字符串需要写明需要链接的数据库名 注意仅支持SQL Server"), Category("SQL-控件参数")]
34 | ///
35 | /// SQL链接字符串
36 | ///
37 | public string SqlString { get; set; } = @"data source=DESKTOP-955LB02\SQLEXPRESS;initial catalog=XN;persist security info=True;user id=sa;password=3131458;MultipleActiveResultSets=True;App=EntityFramework";
38 | [Description("需要链接的SQL表名"), Category("SQL-控件参数")]
39 | ///
40 | /// 需要链接的SQL表名
41 | ///
42 | public string SqlSurface_Name { get; set; } = "Table_1";
43 | [Description("是否启用SQL功能"), Category("SQL-控件参数")]
44 | public bool SQL_Enable
45 | {
46 | get => sql_Enable;
47 | set
48 | {
49 | sql_Enable = value;
50 | }
51 | }
52 | private bool sql_Enable = false;
53 | ///
54 | /// PLC通讯对象
55 | ///
56 | #endregion
57 | #region SQL操作对象
58 | DADataGridView_SQL gridView_SQL;
59 | #endregion
60 | public DADataGridView_TO_SQL()
61 | {
62 | gridView_SQL = new DADataGridView_SQL(this.SqlString,SqlSurface_Name);
63 | }
64 | ///
65 | /// 判断程序是否在运行
66 | /// true 该程序在电脑进程运行中 false 表示不在进程运行
67 | /// 该方法主要用于避免继承过程中CLR 进入SQL数据库 查询数据从而卡死软件
68 | ///
69 | ///
70 | ///
71 | public bool GetPidByProcess(string Name = "Bottom_Control")
72 | {
73 | return System.Diagnostics.Process.GetProcessesByName(Name).ToList().Count > 0 ? true : false;
74 | }
75 | protected override void OnParentChanged(EventArgs e)//加载状态栏
76 | {
77 | if (!GetPidByProcess()) return;
78 | //添加控件参数
79 | if (!SQL_Enable) return;
80 | this.BeginInvoke((EventHandler)delegate
81 | {
82 | using (SqlConnection sqlConnection = new SqlConnection(this.@SqlString))
83 | {
84 | try
85 | {
86 | sqlConnection.Open();
87 | sqlConnection.Close();
88 | }
89 | catch
90 | {
91 | throw new Exception("链接SQL数据库错误--请检查链接字符串");
92 | }
93 | }
94 | gridView_SQL = new DADataGridView_SQL(this.@SqlString, this.@SqlSurface_Name);
95 | gridView_SQL.skinDataGridView_update(this);
96 | });
97 | }
98 | protected override void OnCellEndEdit(DataGridViewCellEventArgs e)//编辑模式结束
99 | {
100 | this.BeginInvoke((EventHandler)delegate
101 | {
102 | if (!SQL_Enable) return;
103 | for (int i = 0; i < this.ColumnCount; i++)
104 | {
105 | if (this.Rows[e.RowIndex].Cells[i].Value == null || this.Rows[e.RowIndex].Cells[i].Value.ToString() == "")//判断内容是否符合刷新
106 | {
107 | this.Rows[e.RowIndex].Cells[i].Value = " ";
108 | }
109 | }
110 | gridView_SQL.skinDataGridView_modification(this);//修改表
111 | gridView_SQL.skinDataGridView_update(this);//更新表
112 | });
113 | }
114 | protected override void OnUserDeletedRow(DataGridViewRowEventArgs e)//用户删除行完成
115 | {
116 | base.OnUserDeletedRow(e);
117 | this.BeginInvoke((EventHandler)delegate
118 | {
119 | if (!SQL_Enable) return;
120 | gridView_SQL.skinDataGridView_modification(this);//修改表
121 | gridView_SQL.skinDataGridView_update(this);//更新表
122 | });
123 | }
124 | protected override void OnDataError(bool displayErrorDialogIfNoHandler, DataGridViewDataErrorEventArgs e)
125 | {
126 | // base.OnDataError(displayErrorDialogIfNoHandler, e);
127 | }
128 | protected override void Dispose(bool disposing)//释放托管资源
129 | {
130 | base.Dispose(disposing);
131 | }
132 |
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAIhatetheqrcode_PLC.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 | using Bottom_Control.PLC参数设置界面;
9 | using Bottom_Control.二维码生成;
10 | using Bottom_Control.按钮__TO__PLC方法;
11 | using Bottom_Control.控件类基;
12 | using Bottom_Control.文本__TO__PLC方法;
13 | using 自定义Uppercomputer_20200727.文本输入键盘;
14 |
15 | namespace Bottom_Control.基本控件
16 | {
17 | //==============================================================
18 | // 作者:BAtoDA
19 | // 时间:2021/2/22 15:58:49
20 | // 文件名:DAIhatetheqrcode_PLC
21 | // 版本:V1.0.1
22 | // 说明: 实现从PLC侧读取自定类型数据 产生二维码或者条形码
23 | // 修改者:***
24 | // 修改说明:
25 | //==============================================================
26 | ///
27 | /// 实现从PLC侧读取自定类型数据 产生二维码或者条形码
28 | ///
29 | [ToolboxItem(true)]
30 | [Browsable(true)]
31 | [Description("实现从PLC侧读取自定类型数据 产生二维码或者条形码")]
32 | public class DAIhatetheqrcode_PLC : PictureBox, TextBox_base
33 | {
34 | #region 实现接口参数
35 | public event EventHandler Modification;
36 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
37 | [DefaultValue(typeof(PLC), "Mitsubishi")]
38 | public PLC Plc
39 | {
40 | get => pLC_valu;
41 | set
42 | {
43 | if (plc_Enable)
44 | {
45 | this.Modification += new EventHandler(Modifications_Eeve);
46 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
47 | this.Modification -= new EventHandler(Modifications_Eeve);
48 | return;
49 | }
50 | pLC_valu = value;
51 | }
52 | }
53 | private PLC pLC_valu;
54 | [Description("是否启用PLC功能"), Category("PLC类型")]
55 | public bool PLC_Enable
56 | {
57 | get => plc_Enable;
58 | set => plc_Enable = value;
59 | }
60 | private bool plc_Enable = false;
61 |
62 | public void Modifications_Eeve(object send, EventArgs e)
63 | {
64 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
65 | buttonBitForm.ShowDialog();
66 | if (buttonBitForm.PLC_parameter.Length < 1) return;
67 | pLC_valu = buttonBitForm.pLC;
68 | PLC_Contact = buttonBitForm.PLC_parameter[1];
69 | plc_Address = buttonBitForm.PLC_parameter[2];
70 | }
71 | [Description("PLC读取触点"), Category("PLC类型")]
72 | public string PLC_Contact
73 | {
74 | get => plc_Contact;
75 | set
76 | {
77 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
78 | throw new Exception("参数设置错误");
79 | plc_Contact = value;
80 | }
81 | }
82 | private string plc_Contact = "D";
83 | [Description("PLC访问地址"), Category("PLC类型")]
84 | public string PLC_Address
85 | {
86 | get => plc_Address;
87 | set
88 | {
89 | if (Button_PLC.Address(value))
90 | plc_Address = value;
91 | }
92 | }
93 | private string plc_Address = "0";
94 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
95 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
96 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
97 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
98 | [DefaultValue(typeof(int), "8")]
99 | public int Decimal_Above { get; set; } = 8;
100 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
101 | [DefaultValue(typeof(int), "0")]
102 | public int Decimal_Below { get; set; } = 0;
103 | public string Control_Text { get => this.Text; set => this.Text = value; }
104 | ///
105 | /// 定时刷新 定时器
106 | ///
107 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
108 | [DefaultValue(typeof(string), "PLC_time")]
109 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
110 | [Description("二维码生成类型 选择显示条形码还是二维码--默认二维码 false 二维码 true 条形码"), Category("PLC-控件参数")]
111 | ///
112 | /// 选择显示条形码还是二维码--默认二维码
113 | ///
114 | public bool select { get; set; } = false;
115 |
116 | ///
117 | /// PLC通讯对象
118 | ///
119 | TextBox_PLC pLC;
120 | IhatetheqrcodeCreate ihatetheqrcode;
121 | #endregion
122 | ///
123 | /// 构造函数
124 | ///
125 | public DAIhatetheqrcode_PLC()
126 | {
127 | ihatetheqrcode = new IhatetheqrcodeCreate();
128 | pLC = new TextBox_PLC();
129 | PLC_time.Start();
130 | PLC_time.Tick += new EventHandler(Time_tick);
131 | this.Text = "123456789";
132 | }
133 | ///
134 | /// 定时器到达事件
135 | ///
136 | ///
137 | ///
138 | private void Time_tick(object send, EventArgs e)
139 | {
140 | lock (this)
141 | {
142 | pLC.Refresh(this);
143 | this.Refresh_Data(Control_Text);
144 | }
145 | }
146 | ///
147 | /// 刷新图片--目前不实现带Logo
148 | ///
149 | public void Refresh_Data(string Data)
150 | {
151 | this.BackgroundImageLayout = ImageLayout.Stretch;//显示方式铺满
152 | //小于一定字符数量--显示默认数据
153 | if (Data.Length < 2)
154 | Data = "123456789";
155 | //判断用户选择显示的类型
156 | if (this.select != true)
157 | this.BackgroundImage = ihatetheqrcode.Generate1(Data,this.Size.Width, this.Size.Height);//加载二维码
158 | else
159 | this.BackgroundImage = ihatetheqrcode.Generate2(Data, this.Size.Width, this.Size.Height);//加载条形码
160 | }
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DALedBulb.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Bottom_Control.PLC参数设置界面;
9 | using Bottom_Control.按钮__TO__PLC方法;
10 | using Sunny.UI;
11 |
12 | namespace Bottom_Control.基本控件
13 | {
14 | //==============================================================
15 | // 作者:BAtoDA
16 | // 时间:2021/2/20 14:20:21
17 | // 文件名:DALedBulb
18 | // 版本:V1.0.1
19 | // 说明: 实现上位机底层控件 指示灯类 -不再公共运行时
20 | // 修改者:***
21 | // 修改说明:
22 | //==============================================================
23 | ///
24 | /// 实现上位机底层控件 指示灯类 -不再公共运行时
25 | ///
26 | [ToolboxItem(true)]
27 | [Browsable(true)]
28 | [Description("实现上位机底层控件 指示灯类 -不再公共运行时 ")]
29 | public class DALedBulb: UILedBulb, Button_base
30 | {
31 | #region 实现接口参数
32 | public event EventHandler Modification;
33 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
34 | [DefaultValue(typeof(PLC), "Mitsubishi")]
35 | public PLC Plc
36 | {
37 | get => pLC_valu;
38 | set
39 | {
40 | if (plc_Enable)
41 | {
42 | this.Modification += new EventHandler(Modifications_Eeve);
43 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
44 | this.Modification -= new EventHandler(Modifications_Eeve);
45 | return;
46 | }
47 | pLC_valu = value;
48 | }
49 | }
50 | private PLC pLC_valu;
51 | [Description("是否启用PLC功能"), Category("PLC类型")]
52 | public bool PLC_Enable
53 | {
54 | get => plc_Enable;
55 | set => plc_Enable = value;
56 | }
57 | private bool plc_Enable = false;
58 |
59 | public void Modifications_Eeve(object send, EventArgs e)
60 | {
61 | ButtonBitForm1 buttonBitForm = new ButtonBitForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
62 | buttonBitForm.ShowDialog();
63 | if (buttonBitForm.PLC_parameter.Length < 1) return;
64 | pLC_valu = buttonBitForm.pLC;
65 | PLC_Contact = buttonBitForm.PLC_parameter[1];
66 | plc_Address = buttonBitForm.PLC_parameter[2];
67 | }
68 | [Description("PLC读取触点"), Category("PLC类型")]
69 | public string PLC_Contact
70 | {
71 | get => plc_Contact;
72 | set
73 | {
74 | if (value == null || !Button_PLC.IsNull(value, Plc))
75 | throw new Exception("参数设置错误");
76 | plc_Contact = value;
77 | }
78 | }
79 | private string plc_Contact = "X";
80 | [Description("PLC访问地址"), Category("PLC类型")]
81 | public string PLC_Address
82 | {
83 | get => plc_Address;
84 | set
85 | {
86 | if (Button_PLC.Address(value))
87 | plc_Address = value;
88 | }
89 | }
90 | private string plc_Address = "0";
91 | [Description("按钮参数 ON时触发背景颜色"), Category("PLC-按钮参数")]
92 | [DefaultValue(typeof(Color), "111, 168, 255")]
93 | public Color Backdrop_ON { get; set; } = Color.FromName("Lime");
94 | [Description("按钮参数 OFF时触发背景颜色"), Category("PLC-按钮参数")]
95 | [DefaultValue(typeof(Color), "Control")]
96 | public Color Backdrop_OFF { get; set; } = Color.FromArgb(74, 131, 229);
97 | [Description("按钮按下状态"), Category("PLC-按钮参数")]
98 | [DefaultValue(typeof(bool), "false")]
99 | public bool Command { get; set; }
100 | [Description("按钮类型选择 true 位指示灯 false 位处理"), Category("PLC-按钮参数")]
101 | [DefaultValue(typeof(bool), "false")]
102 | public bool Button_select { get; set; }
103 | [Description("按钮操作模式"), Category("PLC-按钮参数")]
104 | [DefaultValue(typeof(Button_pattern), "复归型")]
105 | public Button_pattern Pattern { get; set; } = Button_pattern.Regression;
106 | [Description("控件为ON时显示的文本值"), Category("PLC-按钮参数")]
107 | [DefaultValue(typeof(string), "ON")]
108 | public string Text_ON { get; set; } = "ON";
109 | [Description("控件为OFF时显示的文本值"), Category("PLC-按钮参数")]
110 | [DefaultValue(typeof(string), "OFF")]
111 | public string Text_OFF { get; set; } = "OFF";
112 | ///
113 | /// 定时刷新 定时器
114 | ///
115 | [Description("按钮刷新定时器"), Category("PLC-按钮参数")]
116 | [DefaultValue(typeof(string), "PLC_time")]
117 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
118 | ///
119 | /// PLC通讯协议对象
120 | ///
121 | Button_PLC plc;
122 | #endregion
123 | public DALedBulb()
124 | {
125 | plc = new Button_PLC();
126 | PLC_time.Start();
127 | PLC_time.Tick += new EventHandler(Time_tick);
128 | }
129 | protected override void Dispose(bool disposing)//释放托管资源
130 | {
131 | base.Dispose(disposing);
132 | plc.Dispose();
133 | this.PLC_time.Dispose();
134 | }
135 | ///
136 | /// 定时器到达事件
137 | ///
138 | ///
139 | ///
140 | private void Time_tick(object send, EventArgs e)
141 | {
142 | if (!plc_Enable) return;//用户不开启PLC功能
143 |
144 | plc.Refresh(this, this.Plc);
145 |
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAMeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Bottom_Control.PLC参数设置界面;
8 | using Bottom_Control.按钮__TO__PLC方法;
9 | using Bottom_Control.控件类基;
10 | using Bottom_Control.文本__TO__PLC方法;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/18 21:35:06
18 | // 文件名:DAMeter
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 表盘类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 表盘类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 表盘类 -不再公共运行时 ")]
30 | public class DAMeter: UCMeter, TextBox_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "D";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
93 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
94 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
95 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
96 | [DefaultValue(typeof(int), "8")]
97 | public int Decimal_Above { get; set; } = 8;
98 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
99 | [DefaultValue(typeof(int), "0")]
100 | public int Decimal_Below { get; set; } = 0;
101 | public string Control_Text
102 | {
103 | get => Convert.ToString(this.Value);
104 | set
105 | {
106 | if (Convert.ToDecimal(value) < this.MaxValue)
107 | this.Value = Convert.ToDecimal(value);
108 | else
109 | this.Value = 100;
110 | }
111 | }
112 | ///
113 | /// 定时刷新 定时器
114 | ///
115 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
116 | [DefaultValue(typeof(string), "PLC_time")]
117 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
118 | ///
119 | /// PLC通讯对象
120 | ///
121 | TextBox_PLC pLC;
122 | #endregion
123 | ///
124 | /// 构造函数
125 | ///
126 | public DAMeter()
127 | {
128 | pLC = new TextBox_PLC();
129 | PLC_time.Start();
130 | PLC_time.Tick += new EventHandler(Time_tick);
131 | this.Text = "00";
132 | }
133 | ///
134 | /// 定时器到达事件
135 | ///
136 | ///
137 | ///
138 | private void Time_tick(object send, EventArgs e)
139 | {
140 | lock (this)
141 | {
142 | pLC.Refresh(this);
143 | }
144 | }
145 | protected override void Dispose(bool disposing)//重写释放托管资源
146 | {
147 | this.PLC_time.Dispose();
148 | base.Dispose(disposing);
149 | }
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAPond.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Bottom_Control.PLC参数设置界面;
8 | using Bottom_Control.按钮__TO__PLC方法;
9 | using Bottom_Control.控件类基;
10 | using Bottom_Control.文本__TO__PLC方法;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/20 10:59:55
18 | // 文件名:DAPond
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 水池类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 水池类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 水池类 -不再公共运行时")]
30 | public class DAPond:UCPond, TextBox_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "D";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
93 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
94 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
95 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
96 | [DefaultValue(typeof(int), "8")]
97 | public int Decimal_Above { get; set; } = 8;
98 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
99 | [DefaultValue(typeof(int), "0")]
100 | public int Decimal_Below { get; set; } = 0;
101 | public string Control_Text { get => Convert.ToString(this.Value); set => this.Value = Convert.ToDecimal(value); }
102 | ///
103 | /// 定时刷新 定时器
104 | ///
105 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
106 | [DefaultValue(typeof(string), "PLC_time")]
107 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
108 | ///
109 | /// PLC通讯对象
110 | ///
111 | TextBox_PLC pLC;
112 | #endregion
113 | ///
114 | /// 构造函数
115 | ///
116 | public DAPond()
117 | {
118 | pLC = new TextBox_PLC();
119 | PLC_time.Start();
120 | PLC_time.Tick += new EventHandler(Time_tick);
121 | }
122 | ///
123 | /// 定时器到达事件
124 | ///
125 | ///
126 | ///
127 | private void Time_tick(object send, EventArgs e)
128 | {
129 | lock (this)
130 | {
131 | pLC.Refresh(this);
132 | }
133 | }
134 | protected override void Dispose(bool disposing)//重写释放托管资源
135 | {
136 | this.PLC_time.Dispose();
137 | base.Dispose(disposing);
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAProcessEllipse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Bottom_Control.PLC参数设置界面;
8 | using Bottom_Control.按钮__TO__PLC方法;
9 | using Bottom_Control.控件类基;
10 | using Bottom_Control.文本__TO__PLC方法;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/20 13:48:04
18 | // 文件名:DAProcessEllipse
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 圆形进度条类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 圆形进度条类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 圆形波形图类 -不再公共运行时")]
30 | public class DAProcessEllipse: UCProcessEllipse, TextBox_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "D";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
93 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
94 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
95 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
96 | [DefaultValue(typeof(int), "8")]
97 | public int Decimal_Above { get; set; } = 8;
98 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
99 | [DefaultValue(typeof(int), "0")]
100 | public int Decimal_Below { get; set; } = 0;
101 | public string Control_Text { get => Convert.ToString(this.Value); set => this.Value = Convert.ToInt32(value); }
102 | ///
103 | /// 定时刷新 定时器
104 | ///
105 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
106 | [DefaultValue(typeof(string), "PLC_time")]
107 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
108 | ///
109 | /// PLC通讯对象
110 | ///
111 | TextBox_PLC pLC;
112 | #endregion
113 | ///
114 | /// 构造函数
115 | ///
116 | public DAProcessEllipse()
117 | {
118 | pLC = new TextBox_PLC();
119 | PLC_time.Start();
120 | PLC_time.Tick += new EventHandler(Time_tick);
121 | this.Text = "00";
122 | }
123 | ///
124 | /// 定时器到达事件
125 | ///
126 | ///
127 | ///
128 | private void Time_tick(object send, EventArgs e)
129 | {
130 | lock (this)
131 | {
132 | pLC.Refresh(this);
133 | }
134 | }
135 | protected override void Dispose(bool disposing)//重写释放托管资源
136 | {
137 | this.PLC_time.Dispose();
138 | base.Dispose(disposing);
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAProcessWave.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Bottom_Control.PLC参数设置界面;
8 | using Bottom_Control.按钮__TO__PLC方法;
9 | using Bottom_Control.控件类基;
10 | using Bottom_Control.文本__TO__PLC方法;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/20 13:40:49
18 | // 文件名:DAProcessWave
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 圆形波形图类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 圆形波形图类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 圆形波形图类 -不再公共运行时")]
30 | public class DAProcessWave: UCProcessWave, TextBox_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "D";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
93 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
94 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
95 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
96 | [DefaultValue(typeof(int), "8")]
97 | public int Decimal_Above { get; set; } = 8;
98 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
99 | [DefaultValue(typeof(int), "0")]
100 | public int Decimal_Below { get; set; } = 0;
101 | public string Control_Text { get => Convert.ToString(this.Value); set => this.Value = Convert.ToInt32(value); }
102 | ///
103 | /// 定时刷新 定时器
104 | ///
105 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
106 | [DefaultValue(typeof(string), "PLC_time")]
107 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
108 | ///
109 | /// PLC通讯对象
110 | ///
111 | TextBox_PLC pLC;
112 | #endregion
113 | ///
114 | /// 构造函数
115 | ///
116 | public DAProcessWave()
117 | {
118 | pLC = new TextBox_PLC();
119 | PLC_time.Start();
120 | PLC_time.Tick += new EventHandler(Time_tick);
121 | this.Text = "00";
122 | }
123 | ///
124 | /// 定时器到达事件
125 | ///
126 | ///
127 | ///
128 | private void Time_tick(object send, EventArgs e)
129 | {
130 | lock (this)
131 | {
132 | pLC.Refresh(this);
133 | }
134 | }
135 | protected override void Dispose(bool disposing)//重写释放托管资源
136 | {
137 | this.PLC_time.Dispose();
138 | base.Dispose(disposing);
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DARotor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Bottom_Control.PLC参数设置界面;
9 | using Bottom_Control.按钮__TO__PLC方法;
10 | using HZH_Controls.Controls;
11 |
12 | namespace Bottom_Control.基本控件
13 | {
14 | //==============================================================
15 | // 作者:BAtoDA
16 | // 时间:2021/2/20 11:26:33
17 | // 文件名:DARotor
18 | // 版本:V1.0.1
19 | // 说明: 实现上位机底层控件 风扇类 -不再公共运行时
20 | // 修改者:***
21 | // 修改说明:
22 | //==============================================================
23 | ///
24 | /// 实现上位机底层控件 风扇类 -不再公共运行时
25 | ///
26 | [ToolboxItem(true)]
27 | [Browsable(true)]
28 | [Description("实现上位机底层控件 风扇类 -不再公共运行时")]
29 | public class DARotor: UCRotor, Button_base
30 | {
31 | #region 实现接口参数
32 | public event EventHandler Modification;
33 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
34 | [DefaultValue(typeof(PLC), "Mitsubishi")]
35 | public PLC Plc
36 | {
37 | get => pLC_valu;
38 | set
39 | {
40 | if (plc_Enable)
41 | {
42 | this.Modification += new EventHandler(Modifications_Eeve);
43 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
44 | this.Modification -= new EventHandler(Modifications_Eeve);
45 | return;
46 | }
47 | pLC_valu = value;
48 | }
49 | }
50 | private PLC pLC_valu;
51 | [Description("是否启用PLC功能"), Category("PLC类型")]
52 | public bool PLC_Enable
53 | {
54 | get => plc_Enable;
55 | set => plc_Enable = value;
56 | }
57 | private bool plc_Enable = false;
58 |
59 | public void Modifications_Eeve(object send, EventArgs e)
60 | {
61 | ButtonBitForm1 buttonBitForm = new ButtonBitForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
62 | buttonBitForm.ShowDialog();
63 | if (buttonBitForm.PLC_parameter.Length < 1) return;
64 | pLC_valu = buttonBitForm.pLC;
65 | PLC_Contact = buttonBitForm.PLC_parameter[1];
66 | plc_Address = buttonBitForm.PLC_parameter[2];
67 | }
68 | [Description("PLC读取触点"), Category("PLC类型")]
69 | public string PLC_Contact
70 | {
71 | get => plc_Contact;
72 | set
73 | {
74 | if (value == null || !Button_PLC.IsNull(value, Plc))
75 | throw new Exception("参数设置错误");
76 | plc_Contact = value;
77 | }
78 | }
79 | private string plc_Contact = "X";
80 | [Description("PLC访问地址"), Category("PLC类型")]
81 | public string PLC_Address
82 | {
83 | get => plc_Address;
84 | set
85 | {
86 | if (Button_PLC.Address(value))
87 | plc_Address = value;
88 | }
89 | }
90 | private string plc_Address = "0";
91 | [Description("按钮参数 ON时触发背景颜色"), Category("PLC-按钮参数")]
92 | [DefaultValue(typeof(Color), "111, 168, 255")]
93 | public Color Backdrop_ON { get; set; } = Color.FromName("Lime");
94 | [Description("按钮参数 OFF时触发背景颜色"), Category("PLC-按钮参数")]
95 | [DefaultValue(typeof(Color), "Control")]
96 | public Color Backdrop_OFF { get; set; } = Color.FromArgb(74, 131, 229);
97 | [Description("按钮按下状态"), Category("PLC-按钮参数")]
98 | [DefaultValue(typeof(bool), "false")]
99 | public bool Command { get; set; }
100 | [Description("按钮类型选择 true 位指示灯 false 位处理"), Category("PLC-按钮参数")]
101 | [DefaultValue(typeof(bool), "false")]
102 | public bool Button_select { get; set; }
103 | [Description("按钮操作模式"), Category("PLC-按钮参数")]
104 | [DefaultValue(typeof(Button_pattern), "复归型")]
105 | public Button_pattern Pattern { get; set; } = Button_pattern.Regression;
106 | [Description("控件为ON时显示的文本值"), Category("PLC-按钮参数")]
107 | [DefaultValue(typeof(string), "ON")]
108 | public string Text_ON { get; set; } = "ON";
109 | [Description("控件为OFF时显示的文本值"), Category("PLC-按钮参数")]
110 | [DefaultValue(typeof(string), "OFF")]
111 | public string Text_OFF { get; set; } = "OFF";
112 | ///
113 | /// 定时刷新 定时器
114 | ///
115 | [Description("按钮刷新定时器"), Category("PLC-按钮参数")]
116 | [DefaultValue(typeof(string), "PLC_time")]
117 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
118 | ///
119 | /// PLC通讯协议对象
120 | ///
121 | Button_PLC plc;
122 | #endregion
123 | public DARotor()
124 | {
125 | plc = new Button_PLC();
126 | PLC_time.Start();
127 | PLC_time.Tick += new EventHandler(Time_tick);
128 | }
129 | protected override void Dispose(bool disposing)//释放托管资源
130 | {
131 | base.Dispose(disposing);
132 | plc.Dispose();
133 | this.PLC_time.Dispose();
134 | }
135 | ///
136 | /// 定时器到达事件
137 | ///
138 | ///
139 | ///
140 | private void Time_tick(object send, EventArgs e)
141 | {
142 | if (!plc_Enable) return;//用户不开启PLC功能
143 | plc.Refresh(this, this.Plc);
144 | }
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DASignalLamp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Bottom_Control.PLC参数设置界面;
9 | using Bottom_Control.按钮__TO__PLC方法;
10 | using Bottom_Control.控件类基;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/20 15:30:04
18 | // 文件名:DASignalLamp
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 指示灯带闪烁类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 指示灯带闪烁类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 指示灯带闪烁类 -不再公共运行时")]
30 | public class DASignalLamp: UCSignalLamp, Button_base, Flicker_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | ButtonBitForm1 buttonBitForm = new ButtonBitForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !Button_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "X";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("按钮参数 ON时触发背景颜色"), Category("PLC-按钮参数")]
93 | [DefaultValue(typeof(Color), "111, 168, 255")]
94 | public Color Backdrop_ON { get; set; } = Color.FromName("Lime");
95 | [Description("按钮参数 OFF时触发背景颜色"), Category("PLC-按钮参数")]
96 | [DefaultValue(typeof(Color), "Control")]
97 | public Color Backdrop_OFF { get; set; } = Color.FromArgb(74, 131, 229);
98 | public bool Command { get; set; }
99 | public bool Button_select { get; set; }
100 | public Button_pattern Pattern { get; set; } = Button_pattern.Regression;
101 | public string Text_ON { get; set; } = "ON";
102 | public string Text_OFF { get; set; } = "OFF";
103 | ///
104 | /// 定时刷新 定时器
105 | ///
106 | [Description("按钮刷新定时器"), Category("PLC-按钮参数")]
107 | [DefaultValue(typeof(string), "PLC_time")]
108 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
109 |
110 | ///
111 | /// PLC通讯协议对象
112 | ///
113 | Button_PLC plc;
114 | #endregion
115 | #region 实现闪烁接口参数
116 | [Description("值为0时 是否开启闪烁功能"), Category("PLC类型-闪烁参数")]
117 | [DefaultValue(typeof(bool), "false")]
118 | public bool O_Flicker { get; set; } = false;
119 | [Description("值为0时 闪烁颜色变换队列"), Category("PLC类型-闪烁参数")]
120 | public Color[] O_FlickerColor { get; set; } = new Color[] { Color.FromArgb(255, 77, 59) };
121 | [Description("值为0时 闪烁颜色变换时间"), Category("PLC类型-闪烁参数")]
122 | public int O_FlickerTime { get; set; } = 1000;
123 | [Description("值为1时 是否开启闪烁功能"), Category("PLC类型-闪烁参数")]
124 | [DefaultValue(typeof(bool), "false")]
125 | public bool I_Flicker { get; set; } = false;
126 | [Description("值为1时 闪烁颜色变换队列"), Category("PLC类型-闪烁参数")]
127 | public Color[] I_FlickerColor { get; set; } = new Color[] { Color.FromArgb(255, 77, 59) };
128 | [Description("值为1时 闪烁颜色变换时间"), Category("PLC类型-闪烁参数")]
129 | public int I_FlickerTime { get; set; } = 1000;
130 | #endregion
131 | public DASignalLamp()
132 | {
133 | plc = new Button_PLC();
134 | PLC_time.Start();
135 | PLC_time.Tick += new EventHandler(Time_tick);
136 | }
137 | protected override void Dispose(bool disposing)//释放托管资源
138 | {
139 | base.Dispose(disposing);
140 | plc.Dispose();
141 | this.PLC_time.Dispose();
142 | }
143 | ///
144 | /// 定时器到达事件
145 | ///
146 | ///
147 | ///
148 | private void Time_tick(object send, EventArgs e)
149 | {
150 | if (!plc_Enable) return;//用户不开启PLC功能
151 |
152 | plc.Refresh(this, this.Plc);
153 |
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DASwitch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 | using Bottom_Control.PLC参数设置界面;
10 | using Bottom_Control.按钮__TO__PLC方法;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/18 20:42:22
18 | // 文件名:DASwitch
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 切换开关类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 切换开关类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 切换开关类 -不再公共运行时")]
30 | public class DASwitch: UCSwitch, Button_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | ButtonBitForm1 buttonBitForm = new ButtonBitForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !Button_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "X";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("按钮参数 ON时触发背景颜色"), Category("PLC-按钮参数")]
93 | [DefaultValue(typeof(Color), "111, 168, 255")]
94 | public Color Backdrop_ON { get; set; } = Color.FromName("Lime");
95 | [Description("按钮参数 OFF时触发背景颜色"), Category("PLC-按钮参数")]
96 | [DefaultValue(typeof(Color), "Control")]
97 | public Color Backdrop_OFF { get; set; } = Color.FromArgb(74, 131, 229);
98 | [Description("按钮按下状态"), Category("PLC-按钮参数")]
99 | [DefaultValue(typeof(bool), "false")]
100 | public bool Command { get; set; }
101 | [Description("按钮类型选择 true 位指示灯 false 位处理"), Category("PLC-按钮参数")]
102 | [DefaultValue(typeof(bool), "false")]
103 | public bool Button_select { get; set; }
104 | [Description("按钮操作模式"), Category("PLC-按钮参数")]
105 | [DefaultValue(typeof(Button_pattern), "复归型")]
106 | public Button_pattern Pattern { get; set; } = Button_pattern.Regression;
107 | [Description("控件为ON时显示的文本值"), Category("PLC-按钮参数")]
108 | [DefaultValue(typeof(string), "ON")]
109 | public string Text_ON { get; set; } = "ON";
110 | [Description("控件为OFF时显示的文本值"), Category("PLC-按钮参数")]
111 | [DefaultValue(typeof(string), "OFF")]
112 | public string Text_OFF { get; set; } = "OFF";
113 | ///
114 | /// 定时刷新 定时器
115 | ///
116 | [Description("按钮刷新定时器"), Category("PLC-按钮参数")]
117 | [DefaultValue(typeof(string), "PLC_time")]
118 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
119 | ///
120 | /// PLC通讯协议对象
121 | ///
122 | Button_PLC plc;
123 | #endregion
124 | public DASwitch()
125 | {
126 | plc = new Button_PLC();
127 | PLC_time.Start();
128 | PLC_time.Tick += new EventHandler(Time_tick);
129 | }
130 |
131 | protected override void OnMouseDown(MouseEventArgs e)//重写点击事件
132 | {
133 | if (!plc_Enable || Button_select) return;//用户不开启PLC功能
134 | this.BeginInvoke((EventHandler)delegate
135 | {
136 | plc.plc(this);
137 | });
138 | }
139 | protected override void OnMouseUp(MouseEventArgs e)//重写松开事件
140 | {
141 | if (!plc_Enable || Button_select) return;//用户不开启PLC功能
142 | this.BeginInvoke((MethodInvoker)delegate
143 | {
144 | if (plc.state)
145 | plc.plc(this, plc.state);
146 | });
147 | }
148 | protected override void Dispose(bool disposing)//释放托管资源
149 | {
150 | base.Dispose(disposing);
151 | plc.Dispose();
152 | this.PLC_time.Dispose();
153 | }
154 | ///
155 | /// 定时器到达事件
156 | ///
157 | ///
158 | ///
159 | private void Time_tick(object send, EventArgs e)
160 | {
161 | if (!plc_Enable) return;//用户不开启PLC功能
162 | lock (this)
163 | {
164 | plc.Refresh(this, this.Plc);
165 | }
166 | }
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DATextBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 | using Bottom_Control.PLC参数设置界面;
9 | using Bottom_Control.按钮__TO__PLC方法;
10 | using Bottom_Control.控件类基;
11 | using Bottom_Control.文本__TO__PLC方法;
12 | using CCWin;
13 | using 自定义Uppercomputer_20200727;
14 | using 自定义Uppercomputer_20200727.文本输入键盘;
15 |
16 | namespace Bottom_Control.基本控件
17 | {
18 | //==============================================================
19 | // 作者:BAtoDA
20 | // 时间:2021/2/18 11:14:27
21 | // 文件名:DATextBox
22 | // 版本:V1.0.1
23 | // 说明: 实现控件
24 | // 修改者:***
25 | // 修改说明:
26 | //==============================================================
27 | ///
28 | /// 实现上位机底层控件 文本类 -不再公共运行时
29 | ///
30 | [ToolboxItem(true)]
31 | [Browsable(true)]
32 | [Description("实现上位机底层控件 文本类 -不再公共运行时 ")]
33 | public class DATextBox : CCWin.SkinControl.SkinTextBox, TextBox_base
34 | {
35 | #region 实现接口参数
36 | public event EventHandler Modification;
37 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
38 | [DefaultValue(typeof(PLC), "Mitsubishi")]
39 | public PLC Plc
40 | {
41 | get => pLC_valu;
42 | set
43 | {
44 | if (plc_Enable)
45 | {
46 | this.Modification += new EventHandler(Modifications_Eeve);
47 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
48 | this.Modification -= new EventHandler(Modifications_Eeve);
49 | return;
50 | }
51 | pLC_valu = value;
52 | }
53 | }
54 | private PLC pLC_valu;
55 | [Description("是否启用PLC功能"), Category("PLC类型")]
56 | public bool PLC_Enable
57 | {
58 | get => plc_Enable;
59 | set => plc_Enable = value;
60 | }
61 | private bool plc_Enable = false;
62 |
63 | public void Modifications_Eeve(object send, EventArgs e)
64 | {
65 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
66 | buttonBitForm.ShowDialog();
67 | if (buttonBitForm.PLC_parameter.Length < 1) return;
68 | pLC_valu = buttonBitForm.pLC;
69 | PLC_Contact = buttonBitForm.PLC_parameter[1];
70 | plc_Address = buttonBitForm.PLC_parameter[2];
71 | }
72 | [Description("PLC读取触点"), Category("PLC类型")]
73 | public string PLC_Contact
74 | {
75 | get => plc_Contact;
76 | set
77 | {
78 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
79 | throw new Exception("参数设置错误");
80 | plc_Contact = value;
81 | }
82 | }
83 | private string plc_Contact = "D";
84 | [Description("PLC访问地址"), Category("PLC类型")]
85 | public string PLC_Address
86 | {
87 | get => plc_Address;
88 | set
89 | {
90 | if (Button_PLC.Address(value))
91 | plc_Address = value;
92 | }
93 | }
94 | private string plc_Address = "0";
95 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
96 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
97 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
98 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
99 | [DefaultValue(typeof(int), "8")]
100 | public int Decimal_Above { get; set; } = 8;
101 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
102 | [DefaultValue(typeof(int), "0")]
103 | public int Decimal_Below { get; set; } = 0;
104 | public string Control_Text { get => this.Text; set=>this.Text=value; }
105 | ///
106 | /// 定时刷新 定时器
107 | ///
108 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
109 | [DefaultValue(typeof(string), "PLC_time")]
110 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
111 | ///
112 | /// PLC通讯对象
113 | ///
114 | TextBox_PLC pLC;
115 | #endregion
116 | ///
117 | /// 构造函数
118 | ///
119 | public DATextBox()
120 | {
121 | pLC = new TextBox_PLC();
122 | PLC_time.Start();
123 | PLC_time.Tick += new EventHandler(Time_tick);
124 | this.Text = "00";
125 | }
126 | bool write_ok=false;//太久用户不输入文本自动允许PLC写入数据
127 | protected override void OnClick(EventArgs e)//方法重写实现用户双击控件---进入键盘—实现参数写入与约束
128 | {
129 | /// <方法定时擦除用户是否在输入>
130 | write_ok = false;//不允许修改控件
131 | if (this.numerical.ToString() == "Hex_16_Bit" || this.numerical.ToString() == "Hex_32_Bit" || this.Plc.ToString()== "HMI")
132 | {
133 | keyboard_Hex board_Hex = new keyboard_Hex(this.Text, this);//实例化Hex键盘
134 | board_Hex.ShowDialog();//显示窗口
135 | this.Text = board_Hex.O_Text;//获取用户输入的文本
136 | }
137 | else
138 | {
139 | keyboard board = new keyboard(this.Text, this);//调出键盘
140 | board.ShowDialog();//显示窗口
141 | this.Text = board.O_Text;//获取用户输入的文本
142 | }
143 | write_ok = true;//允许修改控件
144 | //把控件文本写到PLC
145 | pLC.plc(this);
146 | }
147 | ///
148 | /// 定时器到达事件
149 | ///
150 | ///
151 | ///
152 | private void Time_tick(object send, EventArgs e)
153 | {
154 | lock (this)
155 | {
156 | pLC.Refresh(this);
157 | }
158 | }
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/DAThermometer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Bottom_Control.PLC参数设置界面;
8 | using Bottom_Control.按钮__TO__PLC方法;
9 | using Bottom_Control.控件类基;
10 | using Bottom_Control.文本__TO__PLC方法;
11 | using HZH_Controls.Controls;
12 |
13 | namespace Bottom_Control.基本控件
14 | {
15 | //==============================================================
16 | // 作者:BAtoDA
17 | // 时间:2021/2/18 21:42:07
18 | // 文件名:DAThermometer
19 | // 版本:V1.0.1
20 | // 说明: 实现上位机底层控件 温度计类 -不再公共运行时
21 | // 修改者:***
22 | // 修改说明:
23 | //==============================================================
24 | ///
25 | /// 实现上位机底层控件 温度计类 -不再公共运行时
26 | ///
27 | [ToolboxItem(true)]
28 | [Browsable(true)]
29 | [Description("实现上位机底层控件 表盘类 -不再公共运行时 ")]
30 | public class DAThermometer: UCThermometer, TextBox_base
31 | {
32 | #region 实现接口参数
33 | public event EventHandler Modification;
34 | [Description("选择PLC类型\r\n默认三菱PLC"), Category("PLC类型")]
35 | [DefaultValue(typeof(PLC), "Mitsubishi")]
36 | public PLC Plc
37 | {
38 | get => pLC_valu;
39 | set
40 | {
41 | if (plc_Enable)
42 | {
43 | this.Modification += new EventHandler(Modifications_Eeve);
44 | this.Modification(Convert.ToInt32(pLC_valu), new EventArgs());
45 | this.Modification -= new EventHandler(Modifications_Eeve);
46 | return;
47 | }
48 | pLC_valu = value;
49 | }
50 | }
51 | private PLC pLC_valu;
52 | [Description("是否启用PLC功能"), Category("PLC类型")]
53 | public bool PLC_Enable
54 | {
55 | get => plc_Enable;
56 | set => plc_Enable = value;
57 | }
58 | private bool plc_Enable = false;
59 |
60 | public void Modifications_Eeve(object send, EventArgs e)
61 | {
62 | TextboxDForm1 buttonBitForm = new TextboxDForm1(Convert.ToInt32(send), PLC_Contact, PLC_Address);
63 | buttonBitForm.ShowDialog();
64 | if (buttonBitForm.PLC_parameter.Length < 1) return;
65 | pLC_valu = buttonBitForm.pLC;
66 | PLC_Contact = buttonBitForm.PLC_parameter[1];
67 | plc_Address = buttonBitForm.PLC_parameter[2];
68 | }
69 | [Description("PLC读取触点"), Category("PLC类型")]
70 | public string PLC_Contact
71 | {
72 | get => plc_Contact;
73 | set
74 | {
75 | if (value == null || !TextBox_PLC.IsNull(value, Plc))
76 | throw new Exception("参数设置错误");
77 | plc_Contact = value;
78 | }
79 | }
80 | private string plc_Contact = "D";
81 | [Description("PLC访问地址"), Category("PLC类型")]
82 | public string PLC_Address
83 | {
84 | get => plc_Address;
85 | set
86 | {
87 | if (Button_PLC.Address(value))
88 | plc_Address = value;
89 | }
90 | }
91 | private string plc_Address = "0";
92 | [Description("设置访问PLC的类型 包含显示数据的类型"), Category("PLC-控件参数")]
93 | [DefaultValue(typeof(numerical_format), "Signed_16_Bit")]
94 | public numerical_format numerical { get; set; } = numerical_format.Signed_16_Bit;
95 | [Description("设置访问PLC小数点以上几位"), Category("PLC-控件参数")]
96 | [DefaultValue(typeof(int), "8")]
97 | public int Decimal_Above { get; set; } = 8;
98 | [Description("设置访问PLC小数点以下几位"), Category("PLC-控件参数")]
99 | [DefaultValue(typeof(int), "0")]
100 | public int Decimal_Below { get; set; } = 0;
101 | public string Control_Text { get => Convert.ToString(this.Value); set => this.Value = Convert.ToDecimal(value); }
102 | ///
103 | /// 定时刷新 定时器
104 | ///
105 | [Description("文本刷新定时器"), Category("PLC-控件参数")]
106 | [DefaultValue(typeof(string), "PLC_time")]
107 | public System.Windows.Forms.Timer PLC_time { get; } = new System.Windows.Forms.Timer() { Enabled = true, Interval = 200 };
108 | ///
109 | /// PLC通讯对象
110 | ///
111 | TextBox_PLC pLC;
112 | #endregion
113 | ///
114 | /// 构造函数
115 | ///
116 | public DAThermometer()
117 | {
118 | pLC = new TextBox_PLC();
119 | PLC_time.Start();
120 | PLC_time.Tick += new EventHandler(Time_tick);
121 | this.Text = "00";
122 | }
123 | ///
124 | /// 定时器到达事件
125 | ///
126 | ///
127 | ///
128 | private void Time_tick(object send, EventArgs e)
129 | {
130 | lock (this)
131 | {
132 | pLC.Refresh(this);
133 | }
134 | }
135 | protected override void Dispose(bool disposing)//重写释放托管资源
136 | {
137 | this.PLC_time.Dispose();
138 | base.Dispose(disposing);
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/Bottom_Control/基本控件/IhatetheqrcodeSQL.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Bottom_Control/控件类基/Button_base.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Reflection.Emit;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Bottom_Control
10 | {
11 | //==============================================================
12 | // 作者:BAtoDA
13 | // 时间:2021/2/15 12:55:35
14 | // 文件名:Button_Interface
15 | // 版本:V1.0.1
16 | // 说明: 上位机按钮类底层控件公共属性--必须继承实现该接口
17 | // 修改者:***
18 | // 修改说明:
19 | //==============================================================
20 | ///
21 | /// 按钮类 通讯类基 必须实现该接口
22 | ///
23 | interface Button_base
24 | {
25 | ///
26 | /// 修改参数界面启动事件
27 | ///
28 | event EventHandler Modification;
29 | ///
30 | /// 选择PLC类型枚举
31 | ///
32 | PLC Plc { get; set; }
33 | ///
34 | /// 指示是否启用PLC功能
35 | ///
36 | bool PLC_Enable { get; set; }
37 | ///
38 | /// 修改参数界面方法
39 | ///
40 | ///
41 | ///
42 | void Modifications_Eeve(object send, EventArgs e);
43 | ///
44 | /// PLC触点功能
45 | ///
46 | string PLC_Contact { get; set; }
47 | ///
48 | /// PLC访问具体地址
49 | ///
50 | string PLC_Address { get; set; }
51 | ///
52 | /// 触点为ON背景颜色
53 | ///
54 | Color Backdrop_ON { get; set; }
55 | ///
56 | /// 触点为OFF背景颜色
57 | ///
58 | Color Backdrop_OFF { get; set; }
59 | ///
60 | /// 控件文本为ON时显示的值
61 | ///
62 | string Text_ON { get; set; }
63 | ///
64 | /// 控件文本为OFF时显示的值
65 | ///
66 | string Text_OFF { get; set; }
67 | ///
68 | /// 按钮开关控制
69 | ///
70 | bool Command { get; set; }
71 | ///
72 | /// 指示该按钮类型-是位 还是 指示灯
73 | /// TRUE 位 FALSE 指示灯
74 | ///
75 | bool Button_select { get; set; }
76 | ///
77 | /// 按钮操作模式
78 | ///
79 | Button_pattern Pattern { get; set; }
80 | ///
81 | /// 控件刷新定时器
82 | ///
83 | System.Windows.Forms.Timer PLC_time { get; }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/Bottom_Control/控件类基/Combox_base.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Bottom_Control.控件类基
8 | {
9 | //==============================================================
10 | // 作者:BAtoDA
11 | // 时间:2021/2/19 16:11:55
12 | // 文件名:Combox_base
13 | // 版本:V1.0.1
14 | // 说明: 上位机下拉菜单类底层控件公共属性--必须继承实现该接口
15 | // 修改者:***
16 | // 修改说明:
17 | //==============================================================
18 | ///
19 | /// 上位机下拉菜单类底层控件公共属性
20 | ///
21 | interface Combox_base
22 | {
23 | ///
24 | /// 下拉菜单KEY值
25 | ///
26 | int[] KeyValuePair { get;}
27 | ///
28 | /// 下拉菜单Value 显示名称值
29 | ///
30 | string[] ValuePair { get;}
31 | ///
32 | /// 修改下拉菜单参数界面启动事件
33 | ///
34 | event EventHandler Combox_Modification;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Bottom_Control/控件类基/DataGridViewPLC_base.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Bottom_Control.基本控件
8 | {
9 | //==============================================================
10 | // 作者:BAtoDA
11 | // 时间:2021/2/20 16:52:59
12 | // 文件名:DataGridViewPLC_base
13 | // 版本:V1.0.1
14 | // 说明: DataGridView表格控件定时器读取PLC 接口规范
15 | // 修改者:***
16 | // 修改说明:
17 | //==============================================================
18 | ///
19 | /// DataGridView表格控件定时器读取接口规范
20 | ///
21 | interface DataGridViewPLC_base
22 | {
23 | ///
24 | /// 需要访问的PLC地址
25 | ///
26 | string[] PLC_address { get; set; }
27 | ///
28 | /// 显示表格的名称
29 | ///
30 | string[] DataGridView_Name { get; set; }
31 | ///
32 | /// 表格对应的数据类型
33 | ///
34 | numerical_format[] DataGridView_numerical { get; set; }
35 | ///
36 | /// 是否显示读取时间
37 | ///
38 | bool DataGridViewPLC_Time { get; set; }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Bottom_Control/控件类基/Doughnut_Base.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Bottom_Control.圆型图__TO__PLC
9 | {
10 | //==============================================================
11 | // 作者:BAtoDA
12 | // 时间:2021/2/21 9:51:40
13 | // 文件名:Doughnut_Base
14 | // 版本:V1.0.1
15 | // 说明: 实现控件上下左右对齐
16 | // 修改者:***
17 | // 修改说明:
18 | //==============================================================
19 | interface Doughnut_Base
20 | {
21 | ///
22 | /// 默认Chart图标名称
23 | ///
24 | string doughnut_Chart_Name { get; set; }
25 | ///
26 | /// 默认图标显示的名称
27 | ///
28 | string doughnut_Chart_Text { get; set; }
29 | ///
30 | /// 默认显示的文本字体
31 | ///
32 | Font doughnut_Chart_Font { get; set; }
33 | ///
34 | /// 设置字体颜色
35 | ///
36 | Color color { get; set; }
37 | ///
38 | /// 设置默认颜色为透明
39 | ///
40 | Color background_colo { get; set; }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Bottom_Control/控件类基/Flicker_base.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Bottom_Control.控件类基
9 | {
10 | //==============================================================
11 | // 作者:BAtoDA
12 | // 时间:2021/2/20 14:58:28
13 | // 文件名:Flicker_base
14 | // 版本:V1.0.1
15 | // 说明: 上位机按钮类闪烁控件底层控件公共属性--必须继承实现该接口
16 | // 修改者:***
17 | // 修改说明:
18 | //==============================================================
19 | interface Flicker_base
20 | {
21 | ///
22 | /// 值为0时 是否开启闪烁
23 | ///
24 | bool O_Flicker { get; set; }
25 | ///
26 | /// 值为0时闪烁颜色变换的队列
27 | ///
28 | Color[] O_FlickerColor { get; set; }
29 | ///
30 | /// 值为0时闪烁变换的时间
31 | ///
32 | int O_FlickerTime { get; set; }
33 | ///
34 | /// 值为1时 是否开启闪烁
35 | ///
36 | bool I_Flicker { get; set; }
37 | ///
38 | /// 值为1时闪烁颜色变换的队列
39 | ///
40 | Color[] I_FlickerColor { get; set; }
41 | ///
42 | /// 值为1时闪烁变换的时间
43 | ///
44 | int I_FlickerTime { get; set; }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Bottom_Control/控件类基/Histogram_base.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Bottom_Control.控件类基
9 | {
10 | //==============================================================
11 | // 作者:BAtoDA
12 | // 时间:2021/2/22 8:50:36
13 | // 文件名:Histogram_base
14 | // 版本:V1.0.1
15 | // 说明:Histogram柱形图表格控件定时器读取PLC 接口规范
16 | // 修改者:***
17 | // 修改说明:
18 | //==============================================================
19 | ///
20 | /// Histogram柱形图控件定时器读取PLC 接口规范
21 | ///
22 |
23 | interface Histogram_base
24 | {
25 | ///
26 | /// 默认Chart图标名称
27 | ///
28 | string Histogram_Chart_Name { get; set; }
29 | ///
30 | /// 默认图标显示的名称
31 | ///
32 | string Histogram_Chart_Text { get; set; }
33 | ///
34 | /// 默认显示的文本字体
35 | ///
36 | Font Histogram_Chart_Font { get; set; }
37 | ///
38 | /// 设置字体颜色
39 | ///
40 | Color Font_Color { get; set; }
41 | ///
42 | /// 设置默认颜色为透明
43 | ///
44 | Color Background_colo { get; set; }
45 | ///
46 | /// 默认柱形图小标题名称
47 | ///
48 | string[] Headline { get; set; }
49 | ///
50 | /// 默认柱形图小标题显示数据的地址
51 | ///
52 | string[] Total_address { get; set; }
53 | ///
54 | /// 默认标题数据类型
55 | ///
56 | numerical_format[] Histogram_numerical { get; set; }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Bottom_Control/控件类基/TextBox_base.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Bottom_Control.控件类基
9 | {
10 | //==============================================================
11 | // 作者:BAtoDA
12 | // 时间:2021/2/18 11:19:44
13 | // 文件名:TextBox_base
14 | // 版本:V1.0.1
15 | // 说明:上位机文本类底层控件公共属性--必须继承实现该接口
16 | // 修改者:***
17 | // 修改说明:
18 | //==============================================================
19 | ///
20 | /// 上位机文本类底层控件公共属性
21 | ///
22 | interface TextBox_base
23 | {
24 | ///
25 | /// 修改参数界面启动事件
26 | ///
27 | event EventHandler Modification;
28 | ///
29 | /// 选择PLC类型枚举
30 | ///
31 | PLC Plc { get; set; }
32 | ///
33 | /// 指示是否启用PLC功能
34 | ///
35 | bool PLC_Enable { get; set; }
36 | ///
37 | /// 修改参数界面方法
38 | ///
39 | ///
40 | ///
41 | void Modifications_Eeve(object send, EventArgs e);
42 | ///
43 | /// PLC触点功能
44 | ///
45 | string PLC_Contact { get; set; }
46 | ///
47 | /// PLC访问具体地址
48 | ///
49 | string PLC_Address { get; set; }
50 | ///
51 | /// 控件显示数据的类型
52 | ///
53 | numerical_format numerical { get; set; }
54 | ///
55 | /// 显示小数点以上
56 | ///
57 | int Decimal_Above { get; set; }
58 | ///
59 | /// 显示小数点以下
60 | ///
61 | int Decimal_Below { get; set; }
62 | ///
63 | /// 传递控件文本值
64 | ///
65 | string Control_Text { get; set; }
66 | ///
67 | /// 控件刷新定时器
68 | ///
69 | System.Windows.Forms.Timer PLC_time { get; }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Bottom_Control/文本输入键盘/keyboard_Hex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using Bottom_Control.基本控件;
11 | using CCWin;
12 | using CCWin.SkinClass;
13 | using CCWin.SkinControl;
14 |
15 | namespace 自定义Uppercomputer_20200727.文本输入键盘
16 | {
17 | public partial class keyboard_Hex:Skin_VS
18 | {
19 | string Name_1;//定义用户传入的文本
20 | DATextBox textBox;//获取该控件的参数
21 | public string O_Text { get => this.skinTextBox3.Text; } //输出文本自读---
22 | public keyboard_Hex(string Nmme, DATextBox textBox)//构造函数-
23 | {
24 | InitializeComponent();
25 | this.Name_1 = Nmme;
26 | this.textBox = textBox;
27 | }
28 | private void keyboard_Hex_Shown(object sender, EventArgs e)//加载控件状态
29 | {
30 | this.skinTextBox3.Text = this.Name_1.Trim();//写入上次值
31 | string[] data = Constraints_data(textBox.numerical.ToString());//获取最大值-最小值
32 | this.skinTextBox1.Text = data[0];//填充最大值
33 | this.skinTextBox2.Text = data[1];//填充最小值
34 | var skinButton_list = (from Control pi in this.Controls where pi is SkinButton select pi).ToList();//获取窗口控件集合
35 | foreach (SkinButton textBox in skinButton_list) textBox.Click += Button_KeyPress;//注册事件
36 | }
37 | private void Button_KeyPress(object sender, EventArgs e)//获取用户输入
38 | {
39 | SkinButton button = ((SkinButton)sender);//获取输入控件对象
40 | if (button.Text == "Clr") { if (this.skinTextBox3.Text.Trim() == "") return; this.skinTextBox3.Text = backspace(this.skinTextBox3.Text); }//实现移除最后一个字符
41 | if (button.Text == "Esc") { this.skinTextBox3.Text = Name_1; this.Close(); }//退回修改前数据
42 | if (button.Text == "Enter") this.Close();//关闭窗口
43 | if ((button.Text != "Clr") & (button.Text != "Esc") & (button.Text != "Bs") & (button.Text != "Enter"))//判断是否功能键不录入
44 | this.skinTextBox3.Text = Button_text_add(sender);//添加字符
45 | if (button.Text == "Bs") this.skinTextBox3.Text = "0";//清空字符
46 |
47 | }
48 | private string Button_text_add(object send)//实现刻录字符
49 | {
50 | string data = this.skinTextBox3.Text + ((SkinButton)send).Text.Trim();//在最后一个添加字符
51 | if (textBox.Plc.ToString() == "HMI") return data;//用户使用了宏指令内部寄存器直接刻录
52 | if (numerical_KeyPress_import(data, textBox.numerical.ToString()))//判断数据是否溢出
53 | {
54 | return backspace(data);//移除最后一位 返回数据
55 | }
56 | else
57 | {
58 | return data;//返回修改后数据
59 | }
60 | }
61 | private bool numerical_KeyPress_import(string Text, string Name)//获取用户输入的文本-与参数中的格式-判断输入是否正确
62 | {
63 | bool Handled = false;//初始化键盘输入状态
64 | int Hex_16_1=Convert.ToInt32(this.skinTextBox1.Text, 16),Hex_32_1= Convert.ToInt32(this.skinTextBox1.Text, 16);//short类型最大约束-与int 约束
65 | int data;
66 | if (Text.Trim().Length > 8) return true;//如果大于8直接返回方法---输入异常不合理
67 | switch (Name.Trim())
68 | {
69 | case "Hex_16_Bit":
70 | data = Convert.ToInt32(Text,16);//把数据转换成--int
71 | if ((data > 0) & (data > Hex_16_1)) Handled = true;//取消修改
72 | if ((data < 0)) Handled = true;//取消修改
73 | break;
74 | case "Hex_32_Bit":
75 | data = Convert.ToInt32(Text,16);//把数据转换成--int
76 | if ((data > 0) & (data > Hex_32_1)) Handled = true;//取消修改
77 | if ((data < 0)) Handled = true;//取消修改
78 | break;
79 | }
80 | return Handled;
81 | }
82 |
83 | private string backspace(string Name)//实现字符串移除最一个字符
84 | {
85 | return Name.Remove(Name.Length - 1, 1); //移除掉
86 | }
87 | private string[] Constraints_data(string Name)//实现约束最小值--最大值
88 | {
89 | string[] data = new string[2];//初始化最大值--最小值
90 | switch (Name)
91 | {
92 | case "Hex_16_Bit":
93 | //最大值
94 | if (textBox.Decimal_Above >= 4)
95 | data[0] = "7FFF";//大于限制默认填充最大值
96 | else
97 | for (int i = 0; i < textBox.Decimal_Above; i++)//先填充最大值
98 | {
99 | data[0] += "F";
100 | }
101 | //最小值
102 | data[1] = "0";//16进制最小值必须为0
103 | break;
104 | case "Hex_32_Bit":
105 | //最大值
106 | if (textBox.Decimal_Above >= 8)
107 | data[0] = "7FFFFFFF";//大于限制默认填充最大值
108 | else
109 | for (int i = 0; i
2 |
3 |
4 | System.Buffers
5 |
6 |
7 |
8 | Provides a resource pool that enables reusing instances of type .
9 | The type of the objects that are in the resource pool.
10 |
11 |
12 | Initializes a new instance of the class.
13 |
14 |
15 | Creates a new instance of the class.
16 | A new instance of the class.
17 |
18 |
19 | Creates a new instance of the class using the specifed configuration.
20 | The maximum length of an array instance that may be stored in the pool.
21 | The maximum number of array instances that may be stored in each bucket in the pool. The pool groups arrays of similar lengths into buckets for faster access.
22 | A new instance of the class with the specified configuration.
23 |
24 |
25 | Retrieves a buffer that is at least the requested length.
26 | The minimum length of the array.
27 | An array of type that is at least minimumLength in length.
28 |
29 |
30 | Returns an array to the pool that was previously obtained using the method on the same instance.
31 | A buffer to return to the pool that was previously obtained using the method.
32 | Indicates whether the contents of the buffer should be cleared before reuse. If bufferLength is set to true, and if the pool will store the buffer to enable subsequent reuse, the method will clear the array of its contents so that a subsequent caller using the method will not see the content of the previous caller. If bufferLength is set to false or if the pool will release the buffer, the array's contents are left unchanged.
33 |
34 |
35 | Gets a shared instance.
36 | A shared instance.
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Bottom_Control/第三方控件DLL/UI_Library_da.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BAtoDA/Bottom_Control/e2afbb588a2aa34c7c8e5517c081e341b9a4ea0b/Bottom_Control/第三方控件DLL/UI_Library_da.dll
--------------------------------------------------------------------------------
/Bottom_Control/第三方控件DLL/快速访问 - 快捷方式.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BAtoDA/Bottom_Control/e2afbb588a2aa34c7c8e5517c081e341b9a4ea0b/Bottom_Control/第三方控件DLL/快速访问 - 快捷方式.lnk
--------------------------------------------------------------------------------
/Bottom_Control/表格控件--TO--PLC/DataGridView_PLC.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 | using Bottom_Control.PLC通讯协议;
8 | using Bottom_Control.基本控件;
9 | using Bottom_Control.控件类基;
10 |
11 | namespace Bottom_Control.表格控件__TO__PLC
12 | {
13 | //==============================================================
14 | // 作者:BAtoDA
15 | // 时间:2021/2/20 22:14:07
16 | // 文件名:DataGridView_PLC
17 | // 版本:V1.0.1
18 | // 说明: 实现DataGridView表格控件读取PLC数据
19 | // 修改者:***
20 | // 修改说明:
21 | //==============================================================
22 | ///
23 | /// 实现DataGridView表格控件读取PLC数据
24 | ///
25 | class DataGridView_PLC
26 | {
27 | public List plc(TextBox_base textBox, DataGridViewPLC_base dataGridView,int Idx)//根据PLC类型写入
28 | {
29 | List Data = new List();
30 | switch (textBox.Plc)
31 | {
32 | case PLC.Mitsubishi:
33 | IPLC_interface mitsubishi = new Mitsubishi_realize();//实例化接口--实现三菱在线访问
34 | if (mitsubishi.PLC_ready)
35 | {
36 | for (int i = 0; i < Idx; i++)
37 | Data.Add(mitsubishi.PLC_read_D_register(textBox.PLC_Contact, dataGridView.PLC_address[i].ToString(), dataGridView.DataGridView_numerical[i]));
38 | }
39 | break;
40 | case PLC.Siemens:
41 | IPLC_interface Siemens = new Siemens_realize();//实例化接口--实现西门子在线访问
42 | if (Siemens.PLC_ready)
43 | {
44 | for (int i = 0; i < Idx; i++)
45 | Data.Add(Siemens.PLC_read_D_register(textBox.PLC_Contact, dataGridView.PLC_address[i].ToString(), dataGridView.DataGridView_numerical[i]));
46 | }
47 | break;
48 | case PLC.MODBUS_TCP:
49 | MODBUD_TCP MODBUD_TCP = new MODBUD_TCP();//实例化接口--实现MODBUS TCP
50 | if (MODBUD_TCP.IPLC_interface_PLC_ready)
51 | {
52 | for (int i = 0; i < Idx; i++)
53 | Data.Add(MODBUD_TCP.IPLC_interface_PLC_read_D_register(textBox.PLC_Contact, dataGridView.PLC_address[i].ToString(), dataGridView.DataGridView_numerical[i]));
54 | }
55 | break;
56 | }
57 | return Data;
58 | }
59 | public List plc(TextBox_base textBox, Histogram_base dataGridView, int Idx)//根据PLC类型写入
60 | {
61 | List Data = new List();
62 | switch (textBox.Plc)
63 | {
64 | case PLC.Mitsubishi:
65 | IPLC_interface mitsubishi = new Mitsubishi_realize();//实例化接口--实现三菱在线访问
66 | if (mitsubishi.PLC_ready)
67 | {
68 | for (int i = 0; i < Idx; i++)
69 | Data.Add(mitsubishi.PLC_read_D_register(textBox.PLC_Contact, dataGridView.Total_address[i].ToString(), dataGridView.Histogram_numerical[i]));
70 | }
71 | break;
72 | case PLC.Siemens:
73 | IPLC_interface Siemens = new Siemens_realize();//实例化接口--实现西门子在线访问
74 | if (Siemens.PLC_ready)
75 | {
76 | for (int i = 0; i < Idx; i++)
77 | Data.Add(Siemens.PLC_read_D_register(textBox.PLC_Contact, dataGridView.Total_address[i].ToString(), dataGridView.Histogram_numerical[i]));
78 | }
79 | break;
80 | case PLC.MODBUS_TCP:
81 | MODBUD_TCP MODBUD_TCP = new MODBUD_TCP();//实例化接口--实现MODBUS TCP
82 | if (MODBUD_TCP.IPLC_interface_PLC_ready)
83 | {
84 | for (int i = 0; i < Idx; i++)
85 | Data.Add(MODBUD_TCP.IPLC_interface_PLC_read_D_register(textBox.PLC_Contact, dataGridView.Total_address[i].ToString(), dataGridView.Histogram_numerical[i]));
86 | }
87 | break;
88 | }
89 | return Data;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/Bottom_Control/表格控件--TO--PLC/表格控件--TO--SQL/DADataGridView_SQL.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Data.SqlClient;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 | using CCWin.SkinControl;
10 |
11 | namespace Bottom_Control.表格控件__TO__PLC.表格控件__TO__SQL
12 | {
13 | //==============================================================
14 | // 作者:BAtoDA
15 | // 时间:2021/2/22 14:05:43
16 | // 文件名:DADataGridView_SQL
17 | // 版本:V1.0.1
18 | // 说明: 实现控件本类用于处理注册事件--进行数据查询修改等操作
19 | // 修改者:***
20 | // 修改说明:
21 | //==============================================================
22 | class DADataGridView_SQL
23 | {
24 | private DataTable dataTable;//定义网格ADO.NET缓存对象
25 | private SqlDataAdapter sqlDataAdapter;//定义更新数据对象
26 | SqlConnection sqlConnection;//SQL连接对象
27 | SqlCommandBuilder sqlCommandBuilder;
28 | public string connect;//连接字符串
29 | public string SQL_statement;//SQL语句
30 | public DADataGridView_SQL(string connect,string SqlSurface_Name)//构造函数--初始化缓存对象
31 | {
32 | this.connect = connect;
33 | this.SQL_statement = $"select * from {SqlSurface_Name}";
34 | this.sqlConnection = new SqlConnection(connect);//实例化SQL对象
35 | this.sqlDataAdapter = new SqlDataAdapter(SQL_statement, sqlConnection);//数据对象
36 | this.dataTable = new DataTable();//实例化缓存对象
37 | }
38 | public void skinDataGridView_update(DataGridView skinDataGridView)//获取数据库数据--更新表
39 | {
40 | this.dataTable = new DataTable();//实例化缓存对象
41 | this.sqlDataAdapter.Fill(this.dataTable);//获取表
42 | skinDataGridView.DataSource = this.dataTable;//绑定数据源
43 | }
44 | public void skinDataGridView_modification(DataGridView skinDataGridView)//获取数据库数据--修改表
45 | {
46 | this.dataTable = new DataTable();//实例化缓存对象
47 | this.sqlCommandBuilder = new SqlCommandBuilder(this.sqlDataAdapter);
48 | this.sqlDataAdapter.Update((DataTable)skinDataGridView.DataSource);
49 | }
50 | public void skinDataGridView_RemoveAt(DataGridView skinDataGridView)//获取数据库数据--删除行
51 | {
52 | skinDataGridView.Rows.RemoveAt(skinDataGridView.CurrentCell.RowIndex);
53 | this.sqlCommandBuilder = new SqlCommandBuilder(this.sqlDataAdapter);
54 | this.sqlDataAdapter.Update(this.dataTable);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Bottom_Control
2 | 关于说明
3 | 1: 无代码访问PLC的控件 通过Visual Studio 拖拽控件设置相应的参数就可以访问PLC简单易用 适用于工业开发作为底层减少项目代码量提高稳定性 正在全力开发
4 | 2:视频展示链接:https://pan.baidu.com/s/12TFRdkp64Kqo6_oK1gdbNw 提取码: lo33
5 | 3:项目控件使用视频展示 https://pan.baidu.com/s/1Sd7JBtRMBqxguB0ZFbR3Zg 提取码: pkve
6 | 
7 |
8 | 使用步骤
9 | 1:先拖拽plC_Open_Time1控件
10 | 2:设置好相应的PLC参数
11 | 3:然后拖拽出DAButton1控件
12 | 4:设置好PLC类型参数
13 | 5:在FORM窗口的Load 事件添加上plC_Open_Time1.Enabled = true;
14 | 6:plC_Open_Time1.Start(); 以上代码
15 |
16 | 注意
17 | 1:plC_Open_Time1控件只能使用一次 否则报错
18 | 2: 清理解决方案会导致plC_Open_Time1控件出现错误(已修复)
19 | 3:有些控件需要配合SQL 数据库使用前要熟知 否则出现报错导致项目崩溃不负责
20 |
21 | 关于用户自定义控件
22 | 1:控件类型分为Bit位线圈操作类型与字双字操作类型
23 | 2:分别继承类基Button_base TextBox_base实现了就可以设置相应的参数
24 | 3:控件操作PLC--Bit位 通过实例化Button_PLC类 调用plc(this)方法 方可 反之字操作类型实例化TextBox_PLC类型
25 | 4:每个控件都自带 System.Windows.Forms.Timer类型的定时器作为刷新UI
26 | 5:西门子S200 smart 访问V区 输入方式为DB 1.0 这样就是访问VB0
27 |
28 |
29 | 关于转换成Dll引用到其他项目的方法:
30 | 1.先把项目转换成类库然后编译
31 | 2.编译成功后去项目的DEbug文件夹把全部dll引导到你的项目
32 | 3.然后找到Bottom_Control.dll拖拽到IDE拖拽控件处更待IDE更新就可以拖拽控件方式
33 | 4.可以引用完成后直接清理解决方案然后重新生产的方法
34 |
--------------------------------------------------------------------------------