├── .gitignore
├── HardwareSimulator
├── App.config
├── Elements
│ ├── cButton.Designer.cs
│ ├── cButton.cs
│ ├── cButton.resx
│ ├── cCheckBox.Designer.cs
│ ├── cCheckBox.cs
│ ├── cDisplay.Designer.cs
│ ├── cDisplay.cs
│ ├── cInput.Designer.cs
│ ├── cInput.cs
│ ├── cInput.resx
│ ├── cIntregrator.Designer.cs
│ ├── cIntregrator.cs
│ ├── cIntregrator.resx
│ ├── cLamp.Designer.cs
│ ├── cLamp.cs
│ ├── cPulse.Designer.cs
│ ├── cPulse.cs
│ ├── cPulse.resx
│ ├── cTableSet.Designer.cs
│ ├── cTableSet.cs
│ ├── cTrackbar.Designer.cs
│ ├── cTrackbar.cs
│ └── cTrackbar.resx
├── Json
│ └── elements.json
├── PlcSimAdvSimulator.csproj
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Thumbs.db
├── frmMain.Designer.cs
├── frmMain.cs
├── frmMain.resx
├── frmStart.Designer.cs
├── frmStart.cs
├── frmStart.resx
├── packages.config
└── simulation256.ico
├── LICENSE
├── Pictures
├── HardwareSimulation.png
├── PlcSimAdvanced30.png
├── SiemensVerbindung.png
├── TIA Portal.png
└── Thumbs.db
├── PlcSimAdvConfigurator
├── App.config
├── Defination.cs
├── Elements
│ ├── cInput.Designer.cs
│ ├── cInput.cs
│ ├── cInput.resx
│ ├── cIntregrator.Designer.cs
│ ├── cIntregrator.cs
│ ├── cIntregrator.resx
│ ├── cTableSet.Designer.cs
│ ├── cTableSet.cs
│ ├── cTrackBar.Designer.cs
│ ├── cTrackBar.cs
│ └── cTrackBar.resx
├── PlcSimAdvConfigurator.csproj
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── frmMain.Designer.cs
├── frmMain.cs
├── frmMain.resx
├── frmSelectDefault.Designer.cs
├── frmSelectDefault.cs
├── frmSelectDefault.resx
├── frmSelectPlc.Designer.cs
├── frmSelectPlc.cs
├── frmSelectPlc.resx
├── frmSelectVar.Designer.cs
├── frmSelectVar.cs
├── frmSelectVar.resx
└── packages.config
├── PlcSimAdvSimulator.sln
├── README.md
└── TiaProjekt
└── ProjektPlcSimAdvTest_20220518_0802.zap16
/HardwareSimulator/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cButton.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cButton
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.SuspendLayout();
35 | //
36 | // cButton
37 | //
38 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.cButton_MouseDown);
39 | this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.cButton_MouseUp);
40 | this.ResumeLayout(false);
41 |
42 | }
43 |
44 | #endregion
45 |
46 | // Serialized property.
47 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
48 |
49 | // Public and designer access to the property.
50 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
51 | public string ToolTip
52 | {
53 | get
54 | {
55 | return toolTip.GetToolTip(this);
56 | }
57 | set
58 | {
59 | toolTip.SetToolTip(this, value);
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cButton.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // cButton, button set/reset a bool value
6 | //
7 |
8 | using System;
9 | using System.ComponentModel;
10 | using System.Drawing;
11 | using System.Windows.Forms;
12 |
13 | namespace PlcSimAdvSimulator
14 | {
15 | public partial class cButton : Button
16 | {
17 | // the button can act in normal or toggle mode
18 | public enum ButtonModes
19 | {
20 | Button = 1,
21 | ToggleButton = 2
22 | }
23 |
24 | public cButton()
25 | {
26 | InitializeComponent();
27 | }
28 |
29 | // the button signal
30 | private bool plcButtonValue;
31 | public bool PlcButtonValue
32 | {
33 | get
34 | {
35 | return plcButtonValue;
36 | }
37 | set
38 | {
39 | plcButtonValue = value;
40 | UpdateColor();
41 | }
42 | }
43 |
44 | // output the button signal (main signal)
45 | public string PlcButtonTag { get; set; }
46 | // output the button signal
47 | public string PlcOutputTag { get; set; }
48 | // output the invert button signal
49 | public string PlcnOutputTag { get; set; }
50 |
51 | // holds the lamp value if used, otherwise the state is displayed
52 | private bool plcLampValue = false;
53 | public bool PlcLampValue
54 | {
55 | get
56 | {
57 | return plcLampValue;
58 | }
59 | set
60 | {
61 | plcLampValue = value;
62 | UpdateColor();
63 | }
64 | }
65 | public string PlcLampTag { get; set; }
66 |
67 | // default color for the active state
68 | Color plcActiveColor = Color.ForestGreen;
69 | [Description("Represents the ON color off the button"), Category("Design")]
70 | public Color PlcActiveColor
71 | {
72 | get
73 | {
74 | return plcActiveColor;
75 | }
76 | set
77 | {
78 | plcActiveColor = value;
79 | }
80 | }
81 |
82 | // selector for the lamp - lamp or state is displayed
83 | private ButtonModes buttonMode = ButtonModes.Button;
84 | public ButtonModes ButtonMode
85 | {
86 | get
87 | {
88 | return buttonMode;
89 | }
90 | set
91 | {
92 | buttonMode = value;
93 | this.Invalidate();
94 | }
95 | }
96 |
97 | // mouse events
98 | private void cButton_MouseDown(object sender, MouseEventArgs e)
99 | {
100 | if (buttonMode == ButtonModes.Button)
101 | {
102 | // button
103 | PlcButtonValue = true;
104 | }
105 | else
106 | {
107 | // toogle
108 | PlcButtonValue = !PlcButtonValue;
109 | }
110 | UpdateColor();
111 | }
112 |
113 | private void cButton_MouseUp(object sender, MouseEventArgs e)
114 | {
115 | if (buttonMode == ButtonModes.Button)
116 | {
117 | // button
118 | PlcButtonValue = false;
119 | }
120 | UpdateColor();
121 | }
122 |
123 | // update the backcolor as lamp or state
124 | private void UpdateColor()
125 | {
126 | if (PlcLampTag == null)
127 | {
128 | // no lamp, LED is indicator of the function
129 | if (PlcButtonValue)
130 | {
131 | this.BackColor = PlcActiveColor;
132 | }
133 | else
134 | {
135 | this.BackColor = SystemColors.Control;
136 | }
137 | this.Invalidate();
138 | }
139 | else
140 | {
141 | // lampd is defined
142 | if (PlcLampValue)
143 | {
144 | this.BackColor = PlcActiveColor;
145 | }
146 | else
147 | {
148 | this.BackColor = SystemColors.Control;
149 | }
150 | this.Invalidate();
151 | }
152 | }
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cButton.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 |
121 | False
122 |
123 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cCheckBox.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cCheckBox
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | components = new System.ComponentModel.Container();
35 | }
36 |
37 | #endregion
38 |
39 | // Serialized property.
40 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
41 |
42 | // Public and designer access to the property.
43 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
44 | public string ToolTip
45 | {
46 | get
47 | {
48 | return toolTip.GetToolTip(this);
49 | }
50 | set
51 | {
52 | toolTip.SetToolTip(this, value);
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cCheckBox.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // cCheckBox, checkbox set/reset a bool value
6 | //
7 |
8 | using System;
9 | using System.Drawing;
10 | using System.Windows.Forms;
11 |
12 | namespace PlcSimAdvSimulator
13 | {
14 | public partial class cCheckBox : CheckBox
15 | {
16 | private bool plcButtonValue;
17 | public bool PlcButtonValue
18 | {
19 | get
20 | {
21 | return plcButtonValue;
22 | }
23 | set
24 | {
25 | plcButtonValue = value;
26 | if (plcButtonValue)
27 | {
28 | this.Checked = true;
29 | }
30 | else
31 | {
32 | this.Checked = false;
33 | }
34 | }
35 | }
36 |
37 | // set / output the signal
38 | public string PlcOutputTag { get; set; }
39 | // output the invert signal
40 | public string PlcnOutputTag { get; set; }
41 |
42 | public cCheckBox()
43 | {
44 | InitializeComponent();
45 | this.CheckedChanged += CCheckBox_CheckedChanged;
46 | }
47 |
48 | private void CCheckBox_CheckedChanged(object sender, EventArgs e)
49 | {
50 | this.PlcButtonValue = this.Checked;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cDisplay.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cDisplay
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | components = new System.ComponentModel.Container();
35 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
36 | }
37 |
38 | #endregion
39 |
40 | // Serialized property.
41 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
42 |
43 | // Public and designer access to the property.
44 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
45 | public string ToolTip
46 | {
47 | get
48 | {
49 | return toolTip.GetToolTip(this);
50 | }
51 | set
52 | {
53 | toolTip.SetToolTip(this, value);
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cDisplay.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 PlcSimAdvSimulator
12 | {
13 | public partial class cDisplay : UserControl
14 | {
15 | public cDisplay()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | protected override void OnPaint(PaintEventArgs e)
21 | {
22 | base.OnPaint(e);
23 |
24 | Graphics g = e.Graphics;
25 |
26 | g.DrawRectangle(new Pen(new SolidBrush(Color.Black), 2.0f), new Rectangle(2, 2, e.ClipRectangle.Width - 4, e.ClipRectangle.Height - 4));
27 |
28 | SizeF sFont = g.MeasureString(DisplayText, new Font("Arial", 12.0f));
29 | g.DrawString(DisplayText, new Font("Arial", 12.0f), new SolidBrush(Color.Black),
30 | new Point(e.ClipRectangle.Width / 2 - ((int)sFont.Width / 2),
31 | e.ClipRectangle.Height / 3 - ((int)sFont.Height / 2)));
32 |
33 | float val = (float)DisplayValue * DisplayScale;
34 | string myString = Convert.ToInt32(val).ToString();
35 | if (displayMode == DisplayModes.Hex)
36 | myString = string.Format("{0:x}", DisplayValue).ToUpper();
37 |
38 | sFont = g.MeasureString(myString, new Font("Arial", 12.0f));
39 | g.DrawString(myString, new Font("Arial", 12.0f), new SolidBrush(Color.Black),
40 | new Point(e.ClipRectangle.Width / 2 - ((int)sFont.Width / 2),
41 | (e.ClipRectangle.Height / 3) * 2 - ((int)sFont.Height / 2)));
42 | }
43 |
44 |
45 | public string DisplayOutput
46 | {
47 | get; set;
48 | }
49 |
50 | private float displayScale = 1.0f;
51 | public float DisplayScale
52 | {
53 | get
54 | {
55 | return displayScale;
56 | }
57 | set
58 | {
59 | displayScale = value;
60 | }
61 | }
62 |
63 | private string displayText;
64 | public string DisplayText
65 | {
66 | get
67 | {
68 | return displayText;
69 | }
70 | set
71 | {
72 | displayText = value;
73 | this.Invalidate();
74 | }
75 | }
76 |
77 | private int displayValue;
78 | public int DisplayValue
79 | {
80 | get
81 | {
82 | return displayValue;
83 | }
84 | set
85 | {
86 | if (value != displayValue)
87 | {
88 | displayValue = value;
89 | this.Invalidate();
90 | }
91 | }
92 | }
93 |
94 | public enum DisplayModes
95 | {
96 | Dez = 1,
97 | Hex = 2,
98 | Real = 3
99 | }
100 |
101 | private DisplayModes displayMode = DisplayModes.Dez;
102 | public DisplayModes DisplayMode
103 | {
104 | get
105 | {
106 | return displayMode;
107 | }
108 | set
109 | {
110 | displayMode = value;
111 | this.Invalidate();
112 | }
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cInput.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cInput
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.txtName = new System.Windows.Forms.Label();
35 | this.txtInput = new System.Windows.Forms.TextBox();
36 | this.SuspendLayout();
37 | //
38 | // txtName
39 | //
40 | this.txtName.AutoSize = true;
41 | this.txtName.Location = new System.Drawing.Point(4, 4);
42 | this.txtName.Name = "txtName";
43 | this.txtName.Size = new System.Drawing.Size(35, 13);
44 | this.txtName.TabIndex = 2;
45 | this.txtName.Text = "Name";
46 | //
47 | // txtInput
48 | //
49 | this.txtInput.Location = new System.Drawing.Point(3, 40);
50 | this.txtInput.Name = "txtInput";
51 | this.txtInput.Size = new System.Drawing.Size(92, 20);
52 | this.txtInput.TabIndex = 3;
53 | this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged);
54 | this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown);
55 | //
56 | // cInput
57 | //
58 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
59 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
60 | this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
61 | this.Controls.Add(this.txtInput);
62 | this.Controls.Add(this.txtName);
63 | this.Name = "cInput";
64 | this.Size = new System.Drawing.Size(98, 98);
65 | this.SizeChanged += new System.EventHandler(this.cInput_SizeChanged);
66 | this.ResumeLayout(false);
67 | this.PerformLayout();
68 |
69 | }
70 |
71 | #endregion
72 |
73 | // Serialized property.
74 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
75 |
76 | // Public and designer access to the property.
77 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
78 | public string ToolTip
79 | {
80 | get
81 | {
82 | return toolTip.GetToolTip(this);
83 | }
84 | set
85 | {
86 | toolTip.SetToolTip(this, value);
87 | }
88 | }
89 | private Label txtName;
90 | private TextBox txtInput;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cInput.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // cPulse, deliver a pulse signal (50% / 50%)
6 | //
7 |
8 | using System;
9 | using System.Drawing;
10 | using System.Windows.Forms;
11 |
12 | namespace PlcSimAdvSimulator
13 | {
14 | public partial class cInput : UserControl
15 | {
16 | public string PlcOutputTag { get; set; }
17 |
18 | private int plcOutpuValue;
19 |
20 | public int PlcOutputValue
21 | {
22 | get
23 | {
24 | return plcOutpuValue;
25 | }
26 | set
27 | {
28 | int val = 0;
29 | int.TryParse(value.ToString(), out val);
30 |
31 | plcOutpuValue = val;
32 | txtInput.Text = val.ToString();
33 |
34 | Application.DoEvents();
35 |
36 | txtInput.BackColor = Color.White;
37 | }
38 | }
39 |
40 | public string caption;
41 | override public string Text
42 | {
43 | get
44 | {
45 | return caption;
46 | }
47 | set
48 | {
49 | caption = value;
50 | txtName.Text = caption;
51 | }
52 | }
53 |
54 | public cInput()
55 | {
56 | InitializeComponent();
57 | }
58 |
59 | private void cInput_SizeChanged(object sender, EventArgs e)
60 | {
61 | txtName.Location = new Point(10, 10);
62 | txtInput.Location = new Point(10, this.Height / 2);
63 | txtInput.Width = this.Width - 25;
64 | }
65 |
66 | private void txtInput_TextChanged(object sender, EventArgs e)
67 | {
68 | txtInput.BackColor = Color.Orange;
69 | }
70 |
71 | private void txtInput_KeyDown(object sender, KeyEventArgs e)
72 | {
73 | if (e.KeyCode == Keys.Enter)
74 | {
75 | int val = 0;
76 | int.TryParse(txtInput.Text, out val);
77 |
78 | plcOutpuValue = val;
79 | txtInput.Text = val.ToString();
80 |
81 | Application.DoEvents();
82 |
83 | txtInput.BackColor = Color.White;
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cInput.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 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cIntregrator.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cIntregrator
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.txtSet = new System.Windows.Forms.Label();
35 | this.txtActual = new System.Windows.Forms.Label();
36 | this.txtTarget = new System.Windows.Forms.Label();
37 | this.txtOn = new System.Windows.Forms.Label();
38 | this.SuspendLayout();
39 | //
40 | // txtSet
41 | //
42 | this.txtSet.AutoSize = true;
43 | this.txtSet.Location = new System.Drawing.Point(18, 17);
44 | this.txtSet.Name = "txtSet";
45 | this.txtSet.Size = new System.Drawing.Size(53, 13);
46 | this.txtSet.TabIndex = 0;
47 | this.txtSet.Text = "Set Value";
48 | //
49 | // txtActual
50 | //
51 | this.txtActual.AutoSize = true;
52 | this.txtActual.Location = new System.Drawing.Point(36, 78);
53 | this.txtActual.Name = "txtActual";
54 | this.txtActual.Size = new System.Drawing.Size(67, 13);
55 | this.txtActual.TabIndex = 1;
56 | this.txtActual.Text = "Actual Value";
57 | //
58 | // txtTarget
59 | //
60 | this.txtTarget.AutoSize = true;
61 | this.txtTarget.Location = new System.Drawing.Point(18, 34);
62 | this.txtTarget.Name = "txtTarget";
63 | this.txtTarget.Size = new System.Drawing.Size(68, 13);
64 | this.txtTarget.TabIndex = 2;
65 | this.txtTarget.Text = "Target Value";
66 | //
67 | // txtOn
68 | //
69 | this.txtOn.AutoSize = true;
70 | this.txtOn.Location = new System.Drawing.Point(121, 125);
71 | this.txtOn.Name = "txtOn";
72 | this.txtOn.Size = new System.Drawing.Size(15, 13);
73 | this.txtOn.TabIndex = 3;
74 | this.txtOn.Text = "O";
75 | //
76 | // cIntregrator
77 | //
78 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
79 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
80 | this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
81 | this.Controls.Add(this.txtOn);
82 | this.Controls.Add(this.txtTarget);
83 | this.Controls.Add(this.txtActual);
84 | this.Controls.Add(this.txtSet);
85 | this.Name = "cIntregrator";
86 | this.Size = new System.Drawing.Size(148, 148);
87 | this.ResumeLayout(false);
88 | this.PerformLayout();
89 |
90 | }
91 |
92 | #endregion
93 |
94 | private System.Windows.Forms.Label txtSet;
95 | private System.Windows.Forms.Label txtActual;
96 | private System.Windows.Forms.Label txtTarget;
97 | private System.Windows.Forms.Label txtOn;
98 |
99 | // Serialized property.
100 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
101 |
102 | // Public and designer access to the property.
103 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
104 | public string ToolTip
105 | {
106 | get
107 | {
108 | return toolTip.GetToolTip(this);
109 | }
110 | set
111 | {
112 | toolTip.SetToolTip(this, value);
113 | }
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cIntregrator.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // Intregrator, Set/Target/Actual Value with
6 | //
7 |
8 | using System;
9 | using System.Drawing;
10 | using System.Windows.Forms;
11 |
12 | namespace PlcSimAdvSimulator
13 | {
14 | public partial class cIntregrator : UserControl
15 | {
16 | private long start;
17 | private int direction;
18 |
19 | public cIntregrator()
20 | {
21 | InitializeComponent();
22 | }
23 |
24 | public string PlcSetValueTag { get; set; }
25 | public int PlcSetValue { get; set; }
26 |
27 | public string PlcTargetValueTag { get; set; }
28 | public int PlcTargetValue { get; set; }
29 |
30 | public string PlcActualValueTag { get; set; }
31 | public int PlcActualValue { get; set; }
32 |
33 | public string PlcGradientTag { get; set; }
34 | public int PlcGradient { get; set; }
35 |
36 | public string PlcSetTag { get; set; }
37 | public void PlcReset()
38 | {
39 | PlcActualValue = PlcSetValue;
40 | start = 0;
41 | }
42 | public string PlcStartTag { get; set; }
43 | public void PlcStart()
44 | {
45 | if (start == 0)
46 | {
47 | start = PlcTicks;
48 | if(PlcTargetValue > PlcActualValue)
49 | {
50 | direction = 1;
51 | }
52 | else
53 | {
54 | direction = -1;
55 | }
56 | }
57 | }
58 | public void PlcStop()
59 | {
60 | start = 0;
61 | }
62 |
63 | private long plcTicks;
64 | public long PlcTicks
65 | {
66 | get
67 | {
68 | return plcTicks;
69 | }
70 | set
71 | {
72 | plcTicks = value;
73 | DateTime dt = new DateTime(plcTicks);
74 |
75 | if (start != 0)
76 | {
77 | long span = (plcTicks - start) / 10000;
78 | long wert = (span * PlcGradient) / 1000;
79 |
80 | PlcActualValue = PlcActualValue + ((int)wert * direction);
81 |
82 | if (((PlcActualValue > PlcTargetValue) && (direction == 1)) ||
83 | ((PlcActualValue < PlcTargetValue) && (direction == -1)))
84 | {
85 | start = 0;
86 | PlcActualValue = PlcTargetValue;
87 | }
88 | else
89 | start = plcTicks;
90 | }
91 |
92 | try
93 | {
94 | if (txtSet.InvokeRequired)
95 | {
96 | txtSet.Invoke((MethodInvoker)(() => txtSet.Text = "SetValue: " + PlcSetValue.ToString()));
97 | txtTarget.Invoke((MethodInvoker)(() => txtTarget.Text = "TargetValue: " + PlcTargetValue.ToString()));
98 | txtActual.Invoke((MethodInvoker)(() => txtActual.Text = "Actual: " + PlcActualValue.ToString()));
99 | }
100 | else
101 | {
102 | txtSet.Text = "SetValue: " + PlcSetValue.ToString();
103 | txtTarget.Text = "TargetValue: " + PlcTargetValue.ToString();
104 | txtActual.Text = "Actual: " + PlcActualValue.ToString();
105 | }
106 |
107 | if ((dt.Second % 2) != 0)
108 | {
109 | txtOn.BackColor = Color.ForestGreen;
110 | }
111 | else
112 | {
113 | txtOn.BackColor = SystemColors.Control;
114 | }
115 | }
116 | catch { }
117 | }
118 | }
119 |
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cIntregrator.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 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cLamp.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cLamp
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | components = new System.ComponentModel.Container();
35 | }
36 |
37 | #endregion
38 |
39 | // Serialized property.
40 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
41 |
42 | // Public and designer access to the property.
43 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
44 | public string ToolTip
45 | {
46 | get
47 | {
48 | return toolTip.GetToolTip(this);
49 | }
50 | set
51 | {
52 | toolTip.SetToolTip(this, value);
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cLamp.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // cLamp, shows state of a bool value
6 | //
7 |
8 | using System;
9 | using System.ComponentModel;
10 | using System.Drawing;
11 | using System.Windows.Forms;
12 |
13 | namespace PlcSimAdvSimulator
14 | {
15 | public partial class cLamp : Label
16 | {
17 | // constructor
18 | public cLamp()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | // hold the state of the lamp
24 | private bool plcLampValue;
25 | public bool PlcLampValue
26 | {
27 | get
28 | {
29 | return plcLampValue;
30 | }
31 | set
32 | {
33 | bool update = false;
34 | if (value != plcLampValue)
35 | update = true;
36 |
37 | plcLampValue = value;
38 | if (value)
39 | this.BackColor = PlcActiveColor;
40 | else
41 | this.BackColor = SystemColors.Control;
42 |
43 | if (update)
44 | this.Invalidate();
45 |
46 | }
47 | }
48 |
49 | // input for the lamp
50 | public string PlcLampTag { get; set; }
51 |
52 | // output the signal
53 | public string PlcOutputTag { get; set; }
54 | // output the invert signal
55 | public string PlcnOutputTag { get; set; }
56 |
57 | // holds the active color
58 | Color plcActiveColor = Color.ForestGreen;
59 | [Description("Represents the ON color off the button"), Category("Design")]
60 | public Color PlcActiveColor
61 | {
62 | get
63 | {
64 | return plcActiveColor;
65 | }
66 | set
67 | {
68 | plcActiveColor = value;
69 | }
70 | }
71 |
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cPulse.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cPulse
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.txtTime = new System.Windows.Forms.Label();
35 | this.txtPulse = new System.Windows.Forms.Label();
36 | this.txtName = new System.Windows.Forms.Label();
37 | this.SuspendLayout();
38 | //
39 | // txtTime
40 | //
41 | this.txtTime.AutoSize = true;
42 | this.txtTime.Location = new System.Drawing.Point(30, 33);
43 | this.txtTime.Name = "txtTime";
44 | this.txtTime.Size = new System.Drawing.Size(41, 13);
45 | this.txtTime.TabIndex = 0;
46 | this.txtTime.Text = "500 ms";
47 | //
48 | // txtPulse
49 | //
50 | this.txtPulse.AutoSize = true;
51 | this.txtPulse.Location = new System.Drawing.Point(78, 75);
52 | this.txtPulse.Name = "txtPulse";
53 | this.txtPulse.Size = new System.Drawing.Size(15, 13);
54 | this.txtPulse.TabIndex = 1;
55 | this.txtPulse.Text = "O";
56 | //
57 | // txtName
58 | //
59 | this.txtName.AutoSize = true;
60 | this.txtName.Location = new System.Drawing.Point(4, 4);
61 | this.txtName.Name = "txtName";
62 | this.txtName.Size = new System.Drawing.Size(35, 13);
63 | this.txtName.TabIndex = 2;
64 | this.txtName.Text = "Name";
65 | //
66 | // cPulse
67 | //
68 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
69 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
70 | this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
71 | this.Controls.Add(this.txtName);
72 | this.Controls.Add(this.txtPulse);
73 | this.Controls.Add(this.txtTime);
74 | this.Name = "cPulse";
75 | this.Size = new System.Drawing.Size(98, 98);
76 | this.SizeChanged += new System.EventHandler(this.cPulse_SizeChanged);
77 | this.ResumeLayout(false);
78 | this.PerformLayout();
79 |
80 | }
81 |
82 | #endregion
83 |
84 | // Serialized property.
85 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
86 |
87 | // Public and designer access to the property.
88 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
89 | public string ToolTip
90 | {
91 | get
92 | {
93 | return toolTip.GetToolTip(this);
94 | }
95 | set
96 | {
97 | toolTip.SetToolTip(this, value);
98 | }
99 | }
100 |
101 | private System.Windows.Forms.Label txtTime;
102 | private Label txtPulse;
103 | private Label txtName;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cPulse.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // cPulse, deliver a pulse signal (50% / 50%)
6 | //
7 |
8 | using System;
9 | using System.Drawing;
10 | using System.Windows.Forms;
11 |
12 | namespace PlcSimAdvSimulator
13 | {
14 | public partial class cPulse : UserControl
15 | {
16 | private int plcTimeMS = 500;
17 | private bool plcOutpuValue;
18 | private long start;
19 | private long actual;
20 |
21 | public int PlcTimeMS
22 | {
23 | get
24 | {
25 | return plcTimeMS;
26 | }
27 | set
28 | {
29 | plcTimeMS = value;
30 | txtTime.Text = plcTimeMS.ToString() + " ms";
31 | }
32 | }
33 | public bool PlcOutputValue
34 | {
35 | get
36 | {
37 | if (start != 0)
38 | if ((actual / 10000) - (start / 10000) > (plcTimeMS / 2))
39 | {
40 | plcOutpuValue = !plcOutpuValue;
41 | start = 0;
42 | }
43 |
44 | if (plcOutpuValue)
45 | txtPulse.BackColor = Color.Green;
46 | else
47 | txtPulse.BackColor = SystemColors.Control;
48 |
49 | return plcOutpuValue;
50 | }
51 | }
52 |
53 | // output the signal
54 | public string PlcOutputTag { get; set; }
55 | // output the invert signal
56 | public string PlcnOutputTag { get; set; }
57 |
58 | public string caption;
59 | override public string Text
60 | {
61 | get
62 | {
63 | return caption;
64 | }
65 | set
66 | {
67 | caption = value;
68 | txtName.Text = caption;
69 | }
70 | }
71 |
72 | public long PlcTicks
73 | {
74 | set
75 | {
76 | if (start == 0)
77 | start = value;
78 | actual = value;
79 | }
80 | }
81 |
82 | public cPulse()
83 | {
84 | InitializeComponent();
85 | txtTime.Text = plcTimeMS.ToString() + " ms";
86 | }
87 |
88 | private void cPulse_SizeChanged(object sender, EventArgs e)
89 | {
90 | txtName.Location = new Point(10, 10);
91 | txtTime.Location = new Point(10, this.Height / 2);
92 | txtPulse.Location = new Point(this.Width - 30, this.Height - 30);
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cPulse.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 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cTableSet.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cTableSet
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | components = new System.ComponentModel.Container();
35 | }
36 |
37 | #endregion
38 |
39 | // Serialized property.
40 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
41 |
42 | // Public and designer access to the property.
43 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
44 | public string ToolTip
45 | {
46 | get
47 | {
48 | return toolTip.GetToolTip(this);
49 | }
50 | set
51 | {
52 | toolTip.SetToolTip(this, value);
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cTableSet.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // cLamp, shows state of a bool value
6 | //
7 |
8 | using System;
9 | using System.ComponentModel;
10 | using System.Drawing;
11 | using System.Windows.Forms;
12 |
13 | namespace PlcSimAdvSimulator
14 | {
15 | public partial class cTableSet : Label
16 | {
17 | public string PlcValueTag { get; set; }
18 |
19 | public string PlcTagStep01 { get; set; }
20 | public string PlcTagStep02 { get; set; }
21 | public string PlcTagStep03 { get; set; }
22 | public string PlcTagStep04 { get; set; }
23 | public string PlcTagStep05 { get; set; }
24 | public string PlcTagStep06 { get; set; }
25 | public string PlcTagStep07 { get; set; }
26 | public string PlcTagStep08 { get; set; }
27 | public string PlcTagStep09 { get; set; }
28 | public string PlcTagStep10 { get; set; }
29 |
30 | public int PlcValueStep01 { get; set; }
31 | public int PlcValueStep02 { get; set; }
32 | public int PlcValueStep03 { get; set; }
33 | public int PlcValueStep04 { get; set; }
34 | public int PlcValueStep05 { get; set; }
35 | public int PlcValueStep06 { get; set; }
36 | public int PlcValueStep07 { get; set; }
37 | public int PlcValueStep08 { get; set; }
38 | public int PlcValueStep09 { get; set; }
39 | public int PlcValueStep10 { get; set; }
40 |
41 | public cTableSet()
42 | {
43 | InitializeComponent();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cTrackbar.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | partial class cTrackBar
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.txtName = new System.Windows.Forms.Label();
35 | this.trackBar1 = new System.Windows.Forms.TrackBar();
36 | this.txtValue = new System.Windows.Forms.Label();
37 | ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
38 | this.SuspendLayout();
39 | //
40 | // txtName
41 | //
42 | this.txtName.AutoSize = true;
43 | this.txtName.Location = new System.Drawing.Point(0, 0);
44 | this.txtName.Name = "txtName";
45 | this.txtName.Size = new System.Drawing.Size(35, 13);
46 | this.txtName.TabIndex = 0;
47 | this.txtName.Text = "label1";
48 | //
49 | // trackBar1
50 | //
51 | this.trackBar1.Location = new System.Drawing.Point(6, 51);
52 | this.trackBar1.Name = "trackBar1";
53 | this.trackBar1.Size = new System.Drawing.Size(144, 45);
54 | this.trackBar1.TabIndex = 1;
55 | //
56 | // txtValue
57 | //
58 | this.txtValue.AutoSize = true;
59 | this.txtValue.Location = new System.Drawing.Point(3, 137);
60 | this.txtValue.Name = "txtValue";
61 | this.txtValue.Size = new System.Drawing.Size(35, 13);
62 | this.txtValue.TabIndex = 2;
63 | this.txtValue.Text = "label1";
64 | //
65 | // cTrackBar
66 | //
67 | this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
68 | this.Controls.Add(this.txtValue);
69 | this.Controls.Add(this.trackBar1);
70 | this.Controls.Add(this.txtName);
71 | this.Name = "cTrackBar";
72 | this.Size = new System.Drawing.Size(148, 148);
73 | this.SizeChanged += new System.EventHandler(this.TrackBar1_SizeChanged);
74 | ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
75 | this.ResumeLayout(false);
76 | this.PerformLayout();
77 |
78 | }
79 |
80 | #endregion
81 |
82 | // Serialized property.
83 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
84 | private Label txtName;
85 | private TrackBar trackBar1;
86 | private Label txtValue;
87 |
88 | // Public and designer access to the property.
89 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
90 | public string ToolTip
91 | {
92 | get
93 | {
94 | return toolTip.GetToolTip(this);
95 | }
96 | set
97 | {
98 | toolTip.SetToolTip(this, value);
99 | }
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cTrackbar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvSimulator
5 | {
6 | public partial class cTrackBar : UserControl
7 | {
8 | public cTrackBar()
9 | {
10 | InitializeComponent();
11 |
12 | txtValue.Text = "Actual Value: 0";
13 | trackBar1.ValueChanged += CTrackbar_ValueChanged;
14 | }
15 |
16 | private void TrackBar1_SizeChanged(object sender, EventArgs e)
17 | {
18 | txtName.Location = new System.Drawing.Point(0, 0);
19 | trackBar1.Location = new System.Drawing.Point(0, (this.Height - 50) / 2);
20 | trackBar1.Width = this.Width;
21 | txtValue.Location = new System.Drawing.Point(0, this.Height - 20);
22 | }
23 |
24 | private void CTrackbar_ValueChanged(object sender, EventArgs e)
25 | {
26 | PlcOutputValue = (Int16)trackBar1.Value;
27 |
28 | if (txtValue.InvokeRequired)
29 | {
30 | txtValue.Invoke((MethodInvoker)(() => txtValue.Text = "Actual Value: " + PlcOutputValue.ToString()));
31 | }
32 | else
33 | {
34 | txtValue.Text = "Actual Value: " + PlcOutputValue.ToString();
35 | }
36 | }
37 |
38 | private Int16 plcOutputValue;
39 | public Int16 PlcOutputValue
40 | {
41 | get
42 | {
43 | return plcOutputValue;
44 | }
45 | set
46 | {
47 | plcOutputValue = value;
48 | trackBar1.Value = (int)value;
49 | }
50 | }
51 |
52 | public string PlcOutputTag { get; set; }
53 |
54 | private int plcMaxValue;
55 | public int PlcMaxValue
56 | {
57 | set
58 | {
59 | trackBar1.Maximum = value;
60 | PlcOutputValue = (Int16)trackBar1.Value;
61 | txtValue.Text = "Actual Value: " + PlcOutputValue.ToString();
62 |
63 | plcMaxValue = value;
64 | }
65 | get
66 | {
67 | return plcMaxValue;
68 | }
69 | }
70 | private int plcMinValue;
71 | public int PlcMinValue
72 | {
73 | set
74 | {
75 | trackBar1.Minimum = value;
76 | PlcOutputValue = (Int16)trackBar1.Value;
77 | txtValue.Text = "Actual Value: " + PlcOutputValue.ToString();
78 |
79 | plcMinValue = value;
80 | }
81 | get
82 | {
83 | return plcMinValue;
84 | }
85 | }
86 | override public string Text
87 | {
88 | set
89 | {
90 | txtName.Text = value;
91 | }
92 | get
93 | {
94 | return txtName.Text;
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/HardwareSimulator/Elements/cTrackbar.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 |
--------------------------------------------------------------------------------
/HardwareSimulator/Json/elements.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "Control": "Settings",
4 | "PLC": "PLC"
5 | },
6 | {
7 | "Control": "cToggleButton",
8 | "Text": "ToggleButton Input 1",
9 | "Size": "100x50",
10 | "Location": "10,10",
11 | "Button": "Eingang_01",
12 | "ActiveColor": "Green",
13 | "Value": "True"
14 | },
15 | {
16 | "Control": "cButton",
17 | "Text": "Button Input 2",
18 | "Size": "100x50",
19 | "Location": "10,70",
20 | "Button": "Eingang_02",
21 | "ActiveColor": "Orange"
22 | },
23 | {
24 | "Control": "cCheckBox",
25 | "Text": "CheckBox Input 3",
26 | "Size": "100x50",
27 | "Location": "10,130",
28 | "Button": "Eingang_03"
29 | },
30 | {
31 | "Control": "cButtonLamp",
32 | "Text": "ButtonLamp Input 4 / Output 3",
33 | "Size": "100x50",
34 | "Location": "10,190",
35 | "Button": "Eingang_04",
36 | "Lamp": "Ausgang_03",
37 | "ActiveColor": "Red"
38 | },
39 | {
40 | "Control": "cLamp",
41 | "Text": "Input 1",
42 | "Size": "50x50",
43 | "Location": "150,10",
44 | "Lamp": "Eingang_01",
45 | "ActiveColor": "Yellow"
46 | },
47 | {
48 | "Control": "cLamp",
49 | "Text": "Input 2",
50 | "Size": "50x50",
51 | "Location": "150,70",
52 | "Lamp": "Eingang_02",
53 | "ActiveColor": "Blue"
54 | },
55 | {
56 | "Control": "cLamp",
57 | "Text": "Input 3",
58 | "Size": "50x50",
59 | "Location": "150,130",
60 | "Lamp": "Eingang_03",
61 | "ActiveColor": "Orange"
62 | },
63 | {
64 | "Control": "cLamp",
65 | "Text": "Input 4",
66 | "Size": "50x50",
67 | "Location": "150,190",
68 | "Lamp": "Eingang_04",
69 | "ActiveColor": "Coral"
70 | },
71 | {
72 | "Control": "cLamp",
73 | "Text": "Output 1",
74 | "Size": "50x50",
75 | "Location": "210,10",
76 | "Lamp": "Ausgang_01",
77 | "ActiveColor": "White"
78 | },
79 | {
80 | "Control": "cLamp",
81 | "Text": "Output 2",
82 | "Size": "50x50",
83 | "Location": "210,70",
84 | "Lamp": "Ausgang_02"
85 | },
86 | {
87 | "Control": "cLamp",
88 | "Text": "Output 3",
89 | "Size": "50x50",
90 | "Location": "210,130",
91 | "Lamp": "Ausgang_03",
92 | "ActiveColor": "Gold"
93 | },
94 | {
95 | "Control": "cLabel",
96 | "Text": "Hier eine Überschrift",
97 | "Size": "200x50",
98 | "Location": "300,10",
99 | "FontSize": "15"
100 | },
101 | {
102 | "Control": "cPulse",
103 | "Text": "Pulse I0.5",
104 | "Size": "100x100",
105 | "Location": "500,100",
106 | "Output": "Eingang_05",
107 | "TimeMS": "1000"
108 | },
109 | {
110 | "Control": "cIntregrator",
111 | "Text": "Simuation Durchfluss",
112 | "Size": "150x150",
113 | "Location": "500,300",
114 | "Actual": "Value_Actual",
115 | "SetPoint": "Value_Set",
116 | "Target": "Value_Target",
117 | "Gradiant": "Value_Gradient",
118 | "Start": "Eingang_02",
119 | "Set": "Eingang_04",
120 | "Value": "10000"
121 | },
122 | {
123 | "Control": "cTrackbar",
124 | "Text": "Analog",
125 | "Size": "150x100",
126 | "Location": "700,100",
127 | "Output": "AnalogValue",
128 | "Max": "27000",
129 | "Min": "100",
130 | "Value": "15000"
131 | }
132 | ]
--------------------------------------------------------------------------------
/HardwareSimulator/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // Programm.cs main entry point
6 | //
7 |
8 | using System;
9 | using System.Windows.Forms;
10 |
11 | namespace PlcSimAdvSimulator
12 | {
13 | static class Program
14 | {
15 | ///
16 | /// Der Haupteinstiegspunkt für die Anwendung.
17 | ///
18 | [STAThread]
19 | static void Main()
20 | {
21 | Application.EnableVisualStyles();
22 | Application.SetCompatibleTextRenderingDefault(false);
23 | Application.Run(new frmMain());
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/HardwareSimulator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Allgemeine Informationen über eine Assembly werden über die folgenden
6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7 | // die einer Assembly zugeordnet sind.
8 | [assembly: AssemblyTitle("PlcSimAdvSimulator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Mark König")]
12 | [assembly: AssemblyProduct("PlcSimAdvSimulator")]
13 | [assembly: AssemblyCopyright("Copyright © 2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
18 | // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
19 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
20 | [assembly: ComVisible(false)]
21 |
22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23 | [assembly: Guid("dab63f32-a56e-4c97-933e-2deb343f38d6")]
24 |
25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26 | //
27 | // Hauptversion
28 | // Nebenversion
29 | // Buildnummer
30 | // Revision
31 | //
32 | // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
33 | // indem Sie "*" wie unten gezeigt eingeben:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/HardwareSimulator/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion:4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7 | // der Code erneut generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PlcSimAdvSimulator.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
17 | ///
18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
19 | // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
21 | // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
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 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PlcSimAdvSimulator.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
51 | /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/HardwareSimulator/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 |
--------------------------------------------------------------------------------
/HardwareSimulator/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion:4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7 | // der Code erneut generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PlcSimAdvSimulator.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.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.UserScopedSettingAttribute()]
27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28 | [global::System.Configuration.DefaultSettingValueAttribute("")]
29 | public string LastConfigFile {
30 | get {
31 | return ((string)(this["LastConfigFile"]));
32 | }
33 | set {
34 | this["LastConfigFile"] = value;
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/HardwareSimulator/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/HardwareSimulator/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mking2203/PlcSimAdvancedHardware/6b90aec030e1f1505e5cbb6770849a93632e8818/HardwareSimulator/Thumbs.db
--------------------------------------------------------------------------------
/HardwareSimulator/frmMain.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 |
121 | 17, 17
122 |
123 |
124 | 104, 17
125 |
126 |
127 | 220, 17
128 |
129 |
130 | 335, 17
131 |
132 |
--------------------------------------------------------------------------------
/HardwareSimulator/frmStart.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace PlcSimAdvSimulator
3 | {
4 | partial class frmStart
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.label1 = new System.Windows.Forms.Label();
33 | this.progressBar1 = new System.Windows.Forms.ProgressBar();
34 | this.SuspendLayout();
35 | //
36 | // label1
37 | //
38 | this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
39 | this.label1.Location = new System.Drawing.Point(2, 9);
40 | this.label1.Name = "label1";
41 | this.label1.Size = new System.Drawing.Size(496, 86);
42 | this.label1.TabIndex = 0;
43 | this.label1.Text = "Loading";
44 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
45 | //
46 | // progressBar1
47 | //
48 | this.progressBar1.Location = new System.Drawing.Point(12, 122);
49 | this.progressBar1.Name = "progressBar1";
50 | this.progressBar1.Size = new System.Drawing.Size(476, 23);
51 | this.progressBar1.TabIndex = 1;
52 | //
53 | // frmStart
54 | //
55 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
56 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
57 | this.ClientSize = new System.Drawing.Size(500, 178);
58 | this.Controls.Add(this.progressBar1);
59 | this.Controls.Add(this.label1);
60 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
61 | this.MaximizeBox = false;
62 | this.MinimizeBox = false;
63 | this.Name = "frmStart";
64 | this.ShowIcon = false;
65 | this.ShowInTaskbar = false;
66 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
67 | this.Text = "PlcSimAdvanced Hardware Simulator";
68 | this.ResumeLayout(false);
69 |
70 | }
71 |
72 | #endregion
73 |
74 | private System.Windows.Forms.Label label1;
75 | private System.Windows.Forms.ProgressBar progressBar1;
76 | }
77 | }
--------------------------------------------------------------------------------
/HardwareSimulator/frmStart.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 PlcSimAdvSimulator
12 | {
13 | public partial class frmStart : Form
14 | {
15 | private string statusText = string.Empty;
16 | private int statusProcent = 0;
17 |
18 | public frmStart()
19 | {
20 | InitializeComponent();
21 | progressBar1.Value = 0;
22 | }
23 |
24 | public string StatusText
25 | {
26 | set
27 | {
28 | label1.Text = value;
29 | statusText = value;
30 | }
31 | }
32 | public int StatusProcent
33 | {
34 | set
35 | {
36 | progressBar1.Value = value;
37 | statusProcent = value;
38 | }
39 | }
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/HardwareSimulator/frmStart.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 |
--------------------------------------------------------------------------------
/HardwareSimulator/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HardwareSimulator/simulation256.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mking2203/PlcSimAdvancedHardware/6b90aec030e1f1505e5cbb6770849a93632e8818/HardwareSimulator/simulation256.ico
--------------------------------------------------------------------------------
/Pictures/HardwareSimulation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mking2203/PlcSimAdvancedHardware/6b90aec030e1f1505e5cbb6770849a93632e8818/Pictures/HardwareSimulation.png
--------------------------------------------------------------------------------
/Pictures/PlcSimAdvanced30.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mking2203/PlcSimAdvancedHardware/6b90aec030e1f1505e5cbb6770849a93632e8818/Pictures/PlcSimAdvanced30.png
--------------------------------------------------------------------------------
/Pictures/SiemensVerbindung.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mking2203/PlcSimAdvancedHardware/6b90aec030e1f1505e5cbb6770849a93632e8818/Pictures/SiemensVerbindung.png
--------------------------------------------------------------------------------
/Pictures/TIA Portal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mking2203/PlcSimAdvancedHardware/6b90aec030e1f1505e5cbb6770849a93632e8818/Pictures/TIA Portal.png
--------------------------------------------------------------------------------
/Pictures/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mking2203/PlcSimAdvancedHardware/6b90aec030e1f1505e5cbb6770849a93632e8818/Pictures/Thumbs.db
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | 20
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cInput.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvConfigurator
5 | {
6 | partial class cInput
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.txtName = new System.Windows.Forms.Label();
35 | this.txtInput = new System.Windows.Forms.TextBox();
36 | this.SuspendLayout();
37 | //
38 | // txtName
39 | //
40 | this.txtName.AutoSize = true;
41 | this.txtName.Location = new System.Drawing.Point(4, 4);
42 | this.txtName.Name = "txtName";
43 | this.txtName.Size = new System.Drawing.Size(35, 13);
44 | this.txtName.TabIndex = 2;
45 | this.txtName.Text = "Name";
46 | //
47 | // txtInput
48 | //
49 | this.txtInput.Enabled = false;
50 | this.txtInput.Location = new System.Drawing.Point(3, 40);
51 | this.txtInput.Name = "txtInput";
52 | this.txtInput.Size = new System.Drawing.Size(92, 20);
53 | this.txtInput.TabIndex = 3;
54 | this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged);
55 | this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown);
56 | //
57 | // cInput
58 | //
59 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
60 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
61 | this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
62 | this.Controls.Add(this.txtInput);
63 | this.Controls.Add(this.txtName);
64 | this.Name = "cInput";
65 | this.Size = new System.Drawing.Size(98, 98);
66 | this.SizeChanged += new System.EventHandler(this.cInput_SizeChanged);
67 | this.ResumeLayout(false);
68 | this.PerformLayout();
69 |
70 | }
71 |
72 | #endregion
73 |
74 | // Serialized property.
75 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
76 |
77 | // Public and designer access to the property.
78 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
79 | public string ToolTip
80 | {
81 | get
82 | {
83 | return toolTip.GetToolTip(this);
84 | }
85 | set
86 | {
87 | toolTip.SetToolTip(this, value);
88 | }
89 | }
90 | private Label txtName;
91 | private TextBox txtInput;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cInput.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // cPulse, deliver a pulse signal (50% / 50%)
6 | //
7 |
8 | using System;
9 | using System.Drawing;
10 | using System.Windows.Forms;
11 |
12 | namespace PlcSimAdvConfigurator
13 | {
14 | public partial class cInput : UserControl
15 | {
16 | public string PlcOutputTag { get; set; }
17 |
18 | private int plcOutpuValue;
19 |
20 | public int PlcOutputValue
21 | {
22 | get
23 | {
24 | return plcOutpuValue;
25 | }
26 | set
27 | {
28 | int val = 0;
29 | int.TryParse(value.ToString(), out val);
30 |
31 | plcOutpuValue = val;
32 | txtInput.Text = val.ToString();
33 |
34 | Application.DoEvents();
35 |
36 | txtInput.BackColor = Color.White;
37 | }
38 | }
39 |
40 | public string caption;
41 | override public string Text
42 | {
43 | get
44 | {
45 | return caption;
46 | }
47 | set
48 | {
49 | caption = value;
50 | txtName.Text = caption;
51 | }
52 | }
53 |
54 | public cInput()
55 | {
56 | InitializeComponent();
57 | }
58 |
59 | private void cInput_SizeChanged(object sender, EventArgs e)
60 | {
61 | txtName.Location = new Point(10, 10);
62 | txtInput.Location = new Point(10, this.Height / 2);
63 | txtInput.Width = this.Width - 25;
64 | }
65 |
66 | private void txtInput_TextChanged(object sender, EventArgs e)
67 | {
68 | txtInput.BackColor = Color.Orange;
69 | }
70 |
71 | private void txtInput_KeyDown(object sender, KeyEventArgs e)
72 | {
73 | if (e.KeyCode == Keys.Enter)
74 | {
75 | int val = 0;
76 | int.TryParse(txtInput.Text, out val);
77 |
78 | plcOutpuValue = val;
79 | txtInput.Text = val.ToString();
80 |
81 | Application.DoEvents();
82 |
83 | txtInput.BackColor = Color.White;
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cInput.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 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cIntregrator.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvConfigurator
5 | {
6 | partial class cIntregrator
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.txtSet = new System.Windows.Forms.Label();
35 | this.txtActual = new System.Windows.Forms.Label();
36 | this.txtTarget = new System.Windows.Forms.Label();
37 | this.txtOn = new System.Windows.Forms.Label();
38 | this.SuspendLayout();
39 | //
40 | // txtSet
41 | //
42 | this.txtSet.AutoSize = true;
43 | this.txtSet.Location = new System.Drawing.Point(18, 17);
44 | this.txtSet.Name = "txtSet";
45 | this.txtSet.Size = new System.Drawing.Size(53, 13);
46 | this.txtSet.TabIndex = 0;
47 | this.txtSet.Text = "Set Value";
48 | //
49 | // txtActual
50 | //
51 | this.txtActual.AutoSize = true;
52 | this.txtActual.Location = new System.Drawing.Point(36, 78);
53 | this.txtActual.Name = "txtActual";
54 | this.txtActual.Size = new System.Drawing.Size(67, 13);
55 | this.txtActual.TabIndex = 1;
56 | this.txtActual.Text = "Actual Value";
57 | //
58 | // txtTarget
59 | //
60 | this.txtTarget.AutoSize = true;
61 | this.txtTarget.Location = new System.Drawing.Point(18, 34);
62 | this.txtTarget.Name = "txtTarget";
63 | this.txtTarget.Size = new System.Drawing.Size(68, 13);
64 | this.txtTarget.TabIndex = 2;
65 | this.txtTarget.Text = "Target Value";
66 | //
67 | // txtOn
68 | //
69 | this.txtOn.AutoSize = true;
70 | this.txtOn.Location = new System.Drawing.Point(121, 125);
71 | this.txtOn.Name = "txtOn";
72 | this.txtOn.Size = new System.Drawing.Size(15, 13);
73 | this.txtOn.TabIndex = 3;
74 | this.txtOn.Text = "O";
75 | //
76 | // cIntregrator
77 | //
78 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
79 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
80 | this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
81 | this.Controls.Add(this.txtOn);
82 | this.Controls.Add(this.txtTarget);
83 | this.Controls.Add(this.txtActual);
84 | this.Controls.Add(this.txtSet);
85 | this.Name = "cIntregrator";
86 | this.Size = new System.Drawing.Size(148, 148);
87 | this.ResumeLayout(false);
88 | this.PerformLayout();
89 |
90 | }
91 |
92 | #endregion
93 |
94 | private System.Windows.Forms.Label txtSet;
95 | private System.Windows.Forms.Label txtActual;
96 | private System.Windows.Forms.Label txtTarget;
97 | private System.Windows.Forms.Label txtOn;
98 |
99 | // Serialized property.
100 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
101 |
102 | // Public and designer access to the property.
103 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
104 | public string ToolTip
105 | {
106 | get
107 | {
108 | return toolTip.GetToolTip(this);
109 | }
110 | set
111 | {
112 | toolTip.SetToolTip(this, value);
113 | }
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cIntregrator.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // Intregrator, Set/Target/Actual Value with
6 | //
7 |
8 | using System;
9 | using System.Drawing;
10 | using System.Windows.Forms;
11 |
12 | namespace PlcSimAdvConfigurator
13 | {
14 | public partial class cIntregrator : UserControl
15 | {
16 | private long start;
17 | private int direction;
18 |
19 | public cIntregrator()
20 | {
21 | InitializeComponent();
22 | }
23 |
24 | public string PlcSetValueTag { get; set; }
25 | public int PlcSetValue { get; set; }
26 |
27 | public string PlcTargetValueTag { get; set; }
28 | public int PlcTargetValue { get; set; }
29 |
30 | public string PlcActualValueTag { get; set; }
31 | public int PlcActualValue { get; set; }
32 |
33 | public string PlcGradientTag { get; set; }
34 | public int PlcGradient { get; set; }
35 |
36 | public string PlcSetTag { get; set; }
37 | public void PlcReset()
38 | {
39 | PlcActualValue = PlcSetValue;
40 | start = 0;
41 | }
42 | public string PlcStartTag { get; set; }
43 | public void PlcStart()
44 | {
45 | if (start == 0)
46 | {
47 | start = PlcTicks;
48 | if(PlcTargetValue > PlcActualValue)
49 | {
50 | direction = 1;
51 | }
52 | else
53 | {
54 | direction = -1;
55 | }
56 | }
57 | }
58 | public void PlcStop()
59 | {
60 | start = 0;
61 | }
62 |
63 | private long plcTicks;
64 | public long PlcTicks
65 | {
66 | get
67 | {
68 | return plcTicks;
69 | }
70 | set
71 | {
72 | plcTicks = value;
73 | DateTime dt = new DateTime(plcTicks);
74 |
75 | if (start != 0)
76 | {
77 | long span = (plcTicks - start) / 10000;
78 | long wert = (span * PlcGradient) / 1000;
79 |
80 | PlcActualValue = PlcActualValue + ((int)wert * direction);
81 |
82 | if (((PlcActualValue > PlcTargetValue) && (direction == 1)) ||
83 | ((PlcActualValue < PlcTargetValue) && (direction == -1)))
84 | {
85 | start = 0;
86 | PlcActualValue = PlcTargetValue;
87 | }
88 | else
89 | start = plcTicks;
90 | }
91 |
92 | try
93 | {
94 | if (txtSet.InvokeRequired)
95 | {
96 | txtSet.Invoke((MethodInvoker)(() => txtSet.Text = "SetValue: " + PlcSetValue.ToString()));
97 | txtTarget.Invoke((MethodInvoker)(() => txtTarget.Text = "TargetValue: " + PlcTargetValue.ToString()));
98 | txtActual.Invoke((MethodInvoker)(() => txtActual.Text = "Actual: " + PlcActualValue.ToString()));
99 | }
100 | else
101 | {
102 | txtSet.Text = "SetValue: " + PlcSetValue.ToString();
103 | txtTarget.Text = "TargetValue: " + PlcTargetValue.ToString();
104 | txtActual.Text = "Actual: " + PlcActualValue.ToString();
105 | }
106 |
107 | if ((dt.Second % 2) != 0)
108 | {
109 | txtOn.BackColor = Color.ForestGreen;
110 | }
111 | else
112 | {
113 | txtOn.BackColor = SystemColors.Control;
114 | }
115 | }
116 | catch { }
117 | }
118 | }
119 |
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cIntregrator.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 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cTableSet.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvConfigurator
5 | {
6 | partial class cTableSet
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | components = new System.ComponentModel.Container();
35 | }
36 |
37 | #endregion
38 |
39 | // Serialized property.
40 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
41 |
42 | // Public and designer access to the property.
43 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
44 | public string ToolTip
45 | {
46 | get
47 | {
48 | return toolTip.GetToolTip(this);
49 | }
50 | set
51 | {
52 | toolTip.SetToolTip(this, value);
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cTableSet.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 | // cLamp, shows state of a bool value
6 | //
7 |
8 | using System;
9 | using System.ComponentModel;
10 | using System.Drawing;
11 | using System.Windows.Forms;
12 |
13 | namespace PlcSimAdvConfigurator
14 | {
15 | public partial class cTableSet : Label
16 | {
17 | public string PlcValueTag { get; set; }
18 |
19 | public string PlcTagStep01 { get; set; }
20 | public string PlcTagStep02 { get; set; }
21 | public string PlcTagStep03 { get; set; }
22 | public string PlcTagStep04 { get; set; }
23 | public string PlcTagStep05 { get; set; }
24 | public string PlcTagStep06 { get; set; }
25 | public string PlcTagStep07 { get; set; }
26 | public string PlcTagStep08 { get; set; }
27 | public string PlcTagStep09 { get; set; }
28 | public string PlcTagStep10 { get; set; }
29 |
30 | public int PlcValueStep01 { get; set; }
31 | public int PlcValueStep02 { get; set; }
32 | public int PlcValueStep03 { get; set; }
33 | public int PlcValueStep04 { get; set; }
34 | public int PlcValueStep05 { get; set; }
35 | public int PlcValueStep06 { get; set; }
36 | public int PlcValueStep07 { get; set; }
37 | public int PlcValueStep08 { get; set; }
38 | public int PlcValueStep09 { get; set; }
39 | public int PlcValueStep10 { get; set; }
40 |
41 | public cTableSet()
42 | {
43 | InitializeComponent();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cTrackBar.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvConfigurator
5 | {
6 | partial class cTrackBar
7 | {
8 | ///
9 | /// Erforderliche Designervariable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Verwendete Ressourcen bereinigen.
15 | ///
16 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Vom Komponenten-Designer generierter Code
27 |
28 | ///
29 | /// Erforderliche Methode für die Designerunterstützung.
30 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.txtName = new System.Windows.Forms.Label();
35 | this.trackBar1 = new System.Windows.Forms.TrackBar();
36 | this.txtValue = new System.Windows.Forms.Label();
37 | ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
38 | this.SuspendLayout();
39 | //
40 | // txtName
41 | //
42 | this.txtName.AutoSize = true;
43 | this.txtName.Location = new System.Drawing.Point(0, 0);
44 | this.txtName.Name = "txtName";
45 | this.txtName.Size = new System.Drawing.Size(35, 13);
46 | this.txtName.TabIndex = 0;
47 | this.txtName.Text = "label1";
48 | //
49 | // trackBar1
50 | //
51 | this.trackBar1.Enabled = false;
52 | this.trackBar1.Location = new System.Drawing.Point(6, 51);
53 | this.trackBar1.Name = "trackBar1";
54 | this.trackBar1.Size = new System.Drawing.Size(144, 45);
55 | this.trackBar1.TabIndex = 1;
56 | //
57 | // txtValue
58 | //
59 | this.txtValue.AutoSize = true;
60 | this.txtValue.Location = new System.Drawing.Point(3, 137);
61 | this.txtValue.Name = "txtValue";
62 | this.txtValue.Size = new System.Drawing.Size(35, 13);
63 | this.txtValue.TabIndex = 2;
64 | this.txtValue.Text = "label1";
65 | //
66 | // cTrackBar
67 | //
68 | this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
69 | this.Controls.Add(this.txtValue);
70 | this.Controls.Add(this.trackBar1);
71 | this.Controls.Add(this.txtName);
72 | this.Name = "cTrackBar";
73 | this.Size = new System.Drawing.Size(148, 148);
74 | this.SizeChanged += new System.EventHandler(this.TrackBar1_SizeChanged);
75 | ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
76 | this.ResumeLayout(false);
77 | this.PerformLayout();
78 |
79 | }
80 |
81 | #endregion
82 |
83 | // Serialized property.
84 | private ToolTip toolTip = new System.Windows.Forms.ToolTip();
85 | private Label txtName;
86 | private TrackBar trackBar1;
87 | private Label txtValue;
88 |
89 | // Public and designer access to the property.
90 | [Description("Represents a small rectangular pop-up window"), Category("Design")]
91 | public string ToolTip
92 | {
93 | get
94 | {
95 | return toolTip.GetToolTip(this);
96 | }
97 | set
98 | {
99 | toolTip.SetToolTip(this, value);
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cTrackBar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace PlcSimAdvConfigurator
5 | {
6 | public partial class cTrackBar : UserControl
7 | {
8 |
9 | public delegate void MouseDownHandler(object sender, MouseEventArgs e);
10 | public event MouseDownHandler ModMouseDown;
11 | public delegate void ModMouseUpHandler(object sender, MouseEventArgs e);
12 | public event ModMouseUpHandler ModMouseUp;
13 | public delegate void ModMouseMoveHandler(object sender, MouseEventArgs e);
14 | public event ModMouseMoveHandler ModMouseMove;
15 |
16 | public cTrackBar()
17 | {
18 | InitializeComponent();
19 |
20 | txtValue.Text = "Actual Value: 0";
21 | trackBar1.ValueChanged += CTrackbar_ValueChanged;
22 |
23 | foreach (Control control in this.Controls)
24 | {
25 | control.MouseDown += new MouseEventHandler(control_MouseDown);
26 | control.MouseUp += new MouseEventHandler(control_MouseUp);
27 | control.MouseMove += new MouseEventHandler(control_MouseMove);
28 | }
29 | }
30 |
31 | private void control_MouseDown(object sender, MouseEventArgs e)
32 | {
33 | if (ModMouseDown != null)
34 | ModMouseDown.Invoke(this, e);
35 | }
36 | private void control_MouseUp(object sender, MouseEventArgs e)
37 | {
38 | if (ModMouseUp != null)
39 | ModMouseUp.Invoke(this, e);
40 | }
41 | private void control_MouseMove(object sender, MouseEventArgs e)
42 | {
43 | if (ModMouseMove != null)
44 | ModMouseMove.Invoke(this, e);
45 | }
46 |
47 | private void TrackBar1_SizeChanged(object sender, EventArgs e)
48 | {
49 | txtName.Location = new System.Drawing.Point(0, 0);
50 | trackBar1.Location = new System.Drawing.Point(0, (this.Height - 50) / 2);
51 | trackBar1.Width = this.Width;
52 | txtValue.Location = new System.Drawing.Point(0, this.Height - 20);
53 | }
54 |
55 | private void CTrackbar_ValueChanged(object sender, EventArgs e)
56 | {
57 | PlcOutputValue = (Int16)trackBar1.Value;
58 |
59 | if (txtValue.InvokeRequired)
60 | {
61 | txtValue.Invoke((MethodInvoker)(() => txtValue.Text = "Actual Value: " + PlcOutputValue.ToString()));
62 | }
63 | else
64 | {
65 | txtValue.Text = "Actual Value: " + PlcOutputValue.ToString();
66 | }
67 | }
68 |
69 | private Int16 plcOutputValue;
70 | public Int16 PlcOutputValue
71 | {
72 | get
73 | {
74 | return plcOutputValue;
75 | }
76 | set
77 | {
78 | plcOutputValue = value;
79 | trackBar1.Value = (int)value;
80 | }
81 | }
82 |
83 | public string PlcOutputTag { get; set; }
84 |
85 | private int plcMaxValue;
86 | public int PlcMaxValue
87 | {
88 | set
89 | {
90 | trackBar1.Maximum = value;
91 | PlcOutputValue = (Int16)trackBar1.Value;
92 | txtValue.Text = "Actual Value: " + PlcOutputValue.ToString();
93 |
94 | plcMaxValue = value;
95 | }
96 | get
97 | {
98 | return plcMaxValue;
99 | }
100 | }
101 | private int plcMinValue;
102 | public int PlcMinValue
103 | {
104 | set
105 | {
106 | trackBar1.Minimum = value;
107 | PlcOutputValue = (Int16)trackBar1.Value;
108 | txtValue.Text = "Actual Value: " + PlcOutputValue.ToString();
109 |
110 | plcMinValue = value;
111 | }
112 | get
113 | {
114 | return plcMinValue;
115 | }
116 | }
117 | override public string Text
118 | {
119 | set
120 | {
121 | txtName.Text = value;
122 | }
123 | get
124 | {
125 | return txtName.Text;
126 | }
127 | }
128 |
129 |
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Elements/cTrackBar.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 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation Configurator (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 |
6 | using System;
7 | using System.Windows.Forms;
8 | using Siemens.Simatic.Simulation.Runtime;
9 |
10 | namespace PlcSimAdvConfigurator
11 | {
12 | static class Program
13 | {
14 | public static string PlcName = string.Empty;
15 |
16 | ///
17 | /// Der Haupteinstiegspunkt für die Anwendung.
18 | ///
19 | [STAThread]
20 | static void Main()
21 | {
22 | Application.EnableVisualStyles();
23 | Application.SetCompatibleTextRenderingDefault(false);
24 |
25 | #region check siemens
26 | bool check = false;
27 |
28 | try
29 | {
30 | // test PlcSimAdvanced is installed
31 | if (SimulationRuntimeManager.IsRuntimeManagerAvailable)
32 | {
33 | // test PlcSimAdvanced - at least one season active
34 | if (SimulationRuntimeManager.RegisteredInstanceInfo.Length > 0)
35 | {
36 | frmSelectPlc frm = new frmSelectPlc();
37 | if (frm.ShowDialog() == DialogResult.OK)
38 | {
39 | // select PlcSimAdvanced instance
40 | PlcName = frm.PlcName;
41 | check = true;
42 | }
43 | }
44 | else
45 | {
46 | //no intance found
47 | MessageBox.Show("Could not find a PlcSimAdvanced instance. Load at least one instance.",
48 | "Instance not found",
49 | MessageBoxButtons.OK,
50 | MessageBoxIcon.Error);
51 | }
52 | }
53 | }
54 | catch
55 | {
56 | //not installed
57 | MessageBox.Show("Could not find PlcSimAdvanced. Installed?",
58 | "Siemens not found",
59 | MessageBoxButtons.OK,
60 | MessageBoxIcon.Error);
61 | }
62 |
63 | #endregion
64 |
65 |
66 |
67 | // start application
68 | if (check)
69 | Application.Run(new frmMain());
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Allgemeine Informationen über eine Assembly werden über die folgenden
6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7 | // die einer Assembly zugeordnet sind.
8 | [assembly: AssemblyTitle("PlcSimAdvConfigurator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Mark König")]
12 | [assembly: AssemblyProduct("PlcSimAdvConfigurator")]
13 | [assembly: AssemblyCopyright("Copyright © 2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
18 | // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
19 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
20 | [assembly: ComVisible(false)]
21 |
22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23 | [assembly: Guid("9e4c52ee-0703-406f-a06f-49a26a54a746")]
24 |
25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26 | //
27 | // Hauptversion
28 | // Nebenversion
29 | // Buildnummer
30 | // Revision
31 | //
32 | // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
33 | // indem Sie "*" wie unten gezeigt eingeben:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion: 4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
7 | // der Code neu generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace PlcSimAdvConfigurator.Properties
13 | {
14 | ///
15 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
16 | ///
17 | // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
18 | // über ein Tool wie ResGen oder Visual Studio automatisch generiert.
19 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
20 | // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
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 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
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("PlcSimAdvConfigurator.Properties.Resources", typeof(Resources).Assembly);
47 | resourceMan = temp;
48 | }
49 | return resourceMan;
50 | }
51 | }
52 |
53 | ///
54 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
55 | /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
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 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/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 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion:4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7 | // der Code erneut generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PlcSimAdvConfigurator.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.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.UserScopedSettingAttribute()]
27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28 | [global::System.Configuration.DefaultSettingValueAttribute("")]
29 | public string LastConfigFile {
30 | get {
31 | return ((string)(this["LastConfigFile"]));
32 | }
33 | set {
34 | this["LastConfigFile"] = value;
35 | }
36 | }
37 |
38 | [global::System.Configuration.UserScopedSettingAttribute()]
39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
40 | [global::System.Configuration.DefaultSettingValueAttribute("20")]
41 | public int SnapGrid {
42 | get {
43 | return ((int)(this["SnapGrid"]));
44 | }
45 | set {
46 | this["SnapGrid"] = value;
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 20
10 |
11 |
12 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/frmSelectDefault.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace PlcSimAdvConfigurator
3 | {
4 | partial class frmSelectDefault
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.txtVar = new System.Windows.Forms.Label();
33 | this.btnSave = new System.Windows.Forms.Button();
34 | this.btnCancel = new System.Windows.Forms.Button();
35 | this.groupBox1 = new System.Windows.Forms.GroupBox();
36 | this.radioFalse = new System.Windows.Forms.RadioButton();
37 | this.radioTrue = new System.Windows.Forms.RadioButton();
38 | this.groupBox1.SuspendLayout();
39 | this.SuspendLayout();
40 | //
41 | // txtVar
42 | //
43 | this.txtVar.AutoSize = true;
44 | this.txtVar.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
45 | this.txtVar.Location = new System.Drawing.Point(44, 157);
46 | this.txtVar.Name = "txtVar";
47 | this.txtVar.Size = new System.Drawing.Size(147, 24);
48 | this.txtVar.TabIndex = 2;
49 | this.txtVar.Text = "Actual selection:";
50 | //
51 | // btnSave
52 | //
53 | this.btnSave.Location = new System.Drawing.Point(268, 92);
54 | this.btnSave.Name = "btnSave";
55 | this.btnSave.Size = new System.Drawing.Size(80, 40);
56 | this.btnSave.TabIndex = 3;
57 | this.btnSave.Text = "Save";
58 | this.btnSave.UseVisualStyleBackColor = true;
59 | this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
60 | //
61 | // btnCancel
62 | //
63 | this.btnCancel.Location = new System.Drawing.Point(354, 92);
64 | this.btnCancel.Name = "btnCancel";
65 | this.btnCancel.Size = new System.Drawing.Size(80, 40);
66 | this.btnCancel.TabIndex = 5;
67 | this.btnCancel.Text = "Cancel";
68 | this.btnCancel.UseVisualStyleBackColor = true;
69 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
70 | //
71 | // groupBox1
72 | //
73 | this.groupBox1.Controls.Add(this.radioFalse);
74 | this.groupBox1.Controls.Add(this.radioTrue);
75 | this.groupBox1.Location = new System.Drawing.Point(48, 32);
76 | this.groupBox1.Name = "groupBox1";
77 | this.groupBox1.Size = new System.Drawing.Size(200, 100);
78 | this.groupBox1.TabIndex = 6;
79 | this.groupBox1.TabStop = false;
80 | this.groupBox1.Text = "Default value";
81 | //
82 | // radioFalse
83 | //
84 | this.radioFalse.AutoSize = true;
85 | this.radioFalse.Location = new System.Drawing.Point(24, 43);
86 | this.radioFalse.Name = "radioFalse";
87 | this.radioFalse.Size = new System.Drawing.Size(50, 17);
88 | this.radioFalse.TabIndex = 1;
89 | this.radioFalse.TabStop = true;
90 | this.radioFalse.Text = "False";
91 | this.radioFalse.UseVisualStyleBackColor = true;
92 | this.radioFalse.CheckedChanged += new System.EventHandler(this.radio_CheckedChanged);
93 | //
94 | // radioTrue
95 | //
96 | this.radioTrue.AutoSize = true;
97 | this.radioTrue.Location = new System.Drawing.Point(24, 20);
98 | this.radioTrue.Name = "radioTrue";
99 | this.radioTrue.Size = new System.Drawing.Size(47, 17);
100 | this.radioTrue.TabIndex = 0;
101 | this.radioTrue.TabStop = true;
102 | this.radioTrue.Text = "True";
103 | this.radioTrue.UseVisualStyleBackColor = true;
104 | this.radioTrue.CheckedChanged += new System.EventHandler(this.radio_CheckedChanged);
105 | //
106 | // frmSelectDefault
107 | //
108 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
109 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
110 | this.ClientSize = new System.Drawing.Size(482, 211);
111 | this.Controls.Add(this.groupBox1);
112 | this.Controls.Add(this.btnCancel);
113 | this.Controls.Add(this.btnSave);
114 | this.Controls.Add(this.txtVar);
115 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
116 | this.MaximizeBox = false;
117 | this.MinimizeBox = false;
118 | this.Name = "frmSelectDefault";
119 | this.ShowIcon = false;
120 | this.ShowInTaskbar = false;
121 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
122 | this.Text = "Select parameter";
123 | this.Load += new System.EventHandler(this.frmSelect_Load);
124 | this.groupBox1.ResumeLayout(false);
125 | this.groupBox1.PerformLayout();
126 | this.ResumeLayout(false);
127 | this.PerformLayout();
128 |
129 | }
130 |
131 | #endregion
132 | internal System.Windows.Forms.Label txtVar;
133 | private System.Windows.Forms.Button btnSave;
134 | private System.Windows.Forms.Button btnCancel;
135 | private System.Windows.Forms.GroupBox groupBox1;
136 | private System.Windows.Forms.RadioButton radioFalse;
137 | private System.Windows.Forms.RadioButton radioTrue;
138 | }
139 | }
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/frmSelectDefault.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using System.Windows.Forms;
4 |
5 | namespace PlcSimAdvConfigurator
6 | {
7 | public partial class frmSelectDefault : Form
8 | {
9 | public bool ActualSelection
10 | {
11 | get; set;
12 | }
13 |
14 | DataTable dt = new DataTable();
15 | public frmSelectDefault()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | private void radio_CheckedChanged(object sender, EventArgs e)
21 | {
22 | RadioButton r = (RadioButton)sender;
23 |
24 | if (r.Name == "radioFalse") ActualSelection = false;
25 | if (r.Name == "radioTrue") ActualSelection = true;
26 |
27 | txtVar.Text = "Aktuelle Variable: " + ActualSelection.ToString();
28 | }
29 |
30 | private void frmSelect_Load(object sender, EventArgs e)
31 | {
32 | if (ActualSelection)
33 | {
34 | radioTrue.Checked = true;
35 | }
36 | else
37 | {
38 | radioFalse.Checked = true;
39 | }
40 |
41 | txtVar.Text = "Aktuelle Variable: " + ActualSelection.ToString();
42 | }
43 |
44 | private void btnCancel_Click(object sender, EventArgs e)
45 | {
46 | this.DialogResult = DialogResult.Cancel;
47 | this.Close();
48 | }
49 |
50 | private void btnSave_Click(object sender, EventArgs e)
51 | {
52 | this.DialogResult = DialogResult.OK;
53 | this.Close();
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/frmSelectDefault.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 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/frmSelectPlc.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace PlcSimAdvConfigurator
3 | {
4 | partial class frmSelectPlc
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.listBox1 = new System.Windows.Forms.ListBox();
33 | this.btnCancel = new System.Windows.Forms.Button();
34 | this.btnSelect = new System.Windows.Forms.Button();
35 | this.SuspendLayout();
36 | //
37 | // listBox1
38 | //
39 | this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
40 | this.listBox1.FormattingEnabled = true;
41 | this.listBox1.ItemHeight = 16;
42 | this.listBox1.Location = new System.Drawing.Point(12, 12);
43 | this.listBox1.Name = "listBox1";
44 | this.listBox1.Size = new System.Drawing.Size(264, 212);
45 | this.listBox1.TabIndex = 0;
46 | //
47 | // btnCancel
48 | //
49 | this.btnCancel.Location = new System.Drawing.Point(201, 247);
50 | this.btnCancel.Name = "btnCancel";
51 | this.btnCancel.Size = new System.Drawing.Size(75, 23);
52 | this.btnCancel.TabIndex = 1;
53 | this.btnCancel.Text = "Cancel";
54 | this.btnCancel.UseVisualStyleBackColor = true;
55 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
56 | //
57 | // btnSelect
58 | //
59 | this.btnSelect.Location = new System.Drawing.Point(12, 247);
60 | this.btnSelect.Name = "btnSelect";
61 | this.btnSelect.Size = new System.Drawing.Size(75, 23);
62 | this.btnSelect.TabIndex = 2;
63 | this.btnSelect.Text = "Select";
64 | this.btnSelect.UseVisualStyleBackColor = true;
65 | this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
66 | //
67 | // frmSelectPlc
68 | //
69 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
70 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
71 | this.ClientSize = new System.Drawing.Size(287, 282);
72 | this.Controls.Add(this.btnSelect);
73 | this.Controls.Add(this.btnCancel);
74 | this.Controls.Add(this.listBox1);
75 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
76 | this.MaximizeBox = false;
77 | this.MinimizeBox = false;
78 | this.Name = "frmSelectPlc";
79 | this.ShowIcon = false;
80 | this.ShowInTaskbar = false;
81 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
82 | this.Text = "Select PLC";
83 | this.ResumeLayout(false);
84 |
85 | }
86 |
87 | #endregion
88 |
89 | private System.Windows.Forms.ListBox listBox1;
90 | private System.Windows.Forms.Button btnCancel;
91 | private System.Windows.Forms.Button btnSelect;
92 | }
93 | }
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/frmSelectPlc.cs:
--------------------------------------------------------------------------------
1 | //
2 | // PlcSimAdvanced Hardware Simulation Configurator (Siemens TIA Portal)
3 | // Mark König, 05/2022
4 | //
5 |
6 | using System;
7 | using System.Windows.Forms;
8 | using Siemens.Simatic.Simulation.Runtime;
9 |
10 | namespace PlcSimAdvConfigurator
11 | {
12 | public partial class frmSelectPlc : Form
13 | {
14 | public frmSelectPlc()
15 | {
16 | InitializeComponent();
17 |
18 | this.DialogResult = DialogResult.None;
19 |
20 | // add all instances
21 | foreach (SInstanceInfo s in SimulationRuntimeManager.RegisteredInstanceInfo)
22 | {
23 | listBox1.Items.Add(s.Name);
24 | }
25 |
26 | // select first instance
27 | if (listBox1.Items.Count > 0)
28 | listBox1.SelectedIndex = 0;
29 | }
30 |
31 | private void btnCancel_Click(object sender, EventArgs e)
32 | {
33 | this.Close();
34 | }
35 |
36 | private void btnSelect_Click(object sender, EventArgs e)
37 | {
38 | if (listBox1.SelectedIndex >= 0)
39 | {
40 | plcName = listBox1.SelectedItem.ToString();
41 | this.DialogResult = DialogResult.OK;
42 | }
43 | this.Close();
44 | }
45 |
46 | private string plcName;
47 | public string PlcName
48 | { get => plcName; set => plcName = value; }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/frmSelectPlc.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 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/frmSelectVar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using System.Windows.Forms;
4 | using Siemens.Simatic.Simulation.Runtime;
5 | using System.Text.RegularExpressions;
6 |
7 | namespace PlcSimAdvConfigurator
8 | {
9 | public partial class frmSelectVar : Form
10 | {
11 | private STagInfo[] myData;
12 | private EDataType myType;
13 | public string ActualSelection
14 | {
15 | get; set;
16 | }
17 |
18 | private DataTable dt = new DataTable();
19 | public frmSelectVar(STagInfo[] data, EDataType dataType)
20 | {
21 | InitializeComponent();
22 |
23 | myData = data;
24 | myType = dataType;
25 | }
26 |
27 | private void radio_CheckedChanged(object sender, EventArgs e)
28 | {
29 | UpdateDataTable();
30 | }
31 |
32 | private void txtFilter_TextChanged(object sender, EventArgs e)
33 | {
34 | UpdateDataTable();
35 | }
36 |
37 | private void UpdateDataTable()
38 | {
39 | DataTable dt = new DataTable();
40 | dt.Columns.Add("Variable");
41 |
42 | foreach (STagInfo info in myData)
43 | {
44 | if ((info.DataType == myType) && (myType == EDataType.Bool) ||
45 | (info.DataType != EDataType.Bool) && (myType != EDataType.Bool))
46 | {
47 | if ((radioAll.Checked) ||
48 | (radioInput.Checked && (info.Area == EArea.Input)) ||
49 | (radioOutput.Checked && (info.Area == EArea.Output)) ||
50 | (radioMarker.Checked && (info.Area == EArea.Marker)))
51 | {
52 | if (Regex.Match(info.Name, txtFilter.Text, RegexOptions.Singleline | RegexOptions.IgnoreCase).Success)
53 | {
54 | DataRow row = dt.NewRow();
55 | row[0] = info.Name;
56 |
57 | dt.Rows.Add(row);
58 | }
59 | }
60 | }
61 | }
62 |
63 | dataGridView1.DataSource = dt;
64 | }
65 |
66 | private void frmSelect_Load(object sender, EventArgs e)
67 | {
68 | UpdateDataTable();
69 |
70 | txtVar.Text = "Aktuelle Variable: " + ActualSelection;
71 | }
72 |
73 | private void btnClear_Click(object sender, EventArgs e)
74 | {
75 | txtFilter.Clear();
76 | }
77 |
78 | private void btnDelete_Click(object sender, EventArgs e)
79 | {
80 | ActualSelection = string.Empty;
81 | txtVar.Text = "Aktuelle Variable: " + ActualSelection;
82 | }
83 |
84 | private void btnCancel_Click(object sender, EventArgs e)
85 | {
86 | this.DialogResult = DialogResult.Cancel;
87 | this.Close();
88 | }
89 |
90 | private void btnSave_Click(object sender, EventArgs e)
91 | {
92 | this.DialogResult = DialogResult.OK;
93 | this.Close();
94 | }
95 |
96 | private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
97 | {
98 | if (e.RowIndex >= 0)
99 | {
100 | string key = (string)dataGridView1.Rows[e.RowIndex].Cells[0].Value;
101 |
102 | ActualSelection = key;
103 | txtVar.Text = "Aktuelle Variable: " + ActualSelection;
104 | }
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/frmSelectVar.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 |
--------------------------------------------------------------------------------
/PlcSimAdvConfigurator/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/PlcSimAdvSimulator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32428.217
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlcSimAdvSimulator", "HardwareSimulator\PlcSimAdvSimulator.csproj", "{DAB63F32-A56E-4C97-933E-2DEB343F38D6}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlcSimAdvConfigurator", "PlcSimAdvConfigurator\PlcSimAdvConfigurator.csproj", "{9E4C52EE-0703-406F-A06F-49A26A54A746}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|x64 = Debug|x64
14 | Release|Any CPU = Release|Any CPU
15 | Release|x64 = Release|x64
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {DAB63F32-A56E-4C97-933E-2DEB343F38D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {DAB63F32-A56E-4C97-933E-2DEB343F38D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {DAB63F32-A56E-4C97-933E-2DEB343F38D6}.Debug|x64.ActiveCfg = Debug|x64
21 | {DAB63F32-A56E-4C97-933E-2DEB343F38D6}.Debug|x64.Build.0 = Debug|x64
22 | {DAB63F32-A56E-4C97-933E-2DEB343F38D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {DAB63F32-A56E-4C97-933E-2DEB343F38D6}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {DAB63F32-A56E-4C97-933E-2DEB343F38D6}.Release|x64.ActiveCfg = Release|x64
25 | {DAB63F32-A56E-4C97-933E-2DEB343F38D6}.Release|x64.Build.0 = Release|x64
26 | {9E4C52EE-0703-406F-A06F-49A26A54A746}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {9E4C52EE-0703-406F-A06F-49A26A54A746}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {9E4C52EE-0703-406F-A06F-49A26A54A746}.Debug|x64.ActiveCfg = Debug|Any CPU
29 | {9E4C52EE-0703-406F-A06F-49A26A54A746}.Debug|x64.Build.0 = Debug|Any CPU
30 | {9E4C52EE-0703-406F-A06F-49A26A54A746}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {9E4C52EE-0703-406F-A06F-49A26A54A746}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {9E4C52EE-0703-406F-A06F-49A26A54A746}.Release|x64.ActiveCfg = Release|Any CPU
33 | {9E4C52EE-0703-406F-A06F-49A26A54A746}.Release|x64.Build.0 = Release|Any CPU
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {55109082-87B4-4A13-8664-522EDD8A4D28}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PlcSimAdvancedHardware
2 | Siemens PlcSimAdvanced Hardware Simulator
3 |
4 | Working with the Siemens Software PlcSimAdvanced I realized I can do a simulation of the PLC but not for the IO's. I know there are products out there, but quite expensive for small machines. I discovered the API which comes with the simulation. So I wrote a Hardware simulator where I can manipulate the inputs which leads me to a virtual commissioning.
5 |
6 | Actual functions:
7 | *Button (Bool)
8 | *Toogle-button (Bool)
9 | *Checkbox (Bool)
10 | *Lamps (Bool)
11 | *Trackbar (Dint Value like analog inputs)
12 | *Inregrator (raises value in certain speed)
13 | *Pulse generator (Bool)
14 | *Label (just to put some text)
15 |
16 | You can find my TIA 16 demo project also here.
17 |
18 | https://github.com/mking2203/PlcSimAdvancedHardware/blob/main/Pictures/PlcSimAdvanced30.png
19 |
20 | 1. start the simulator and start one instance of CPU
21 | 2. start the TIA Portal and download the file
22 | 3. the PLC should run now in virtual mode
23 | 4. copy the JSON file to the app folder and edit the PLC instance if needed
24 | 5. start the app
25 |
26 | With the buttons you can now manipulate the inputs and see the outputs.
27 |
28 | https://github.com/mking2203/PlcSimAdvancedHardware/blob/main/Pictures/HardwareSimulation.png
29 |
--------------------------------------------------------------------------------
/TiaProjekt/ProjektPlcSimAdvTest_20220518_0802.zap16:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mking2203/PlcSimAdvancedHardware/6b90aec030e1f1505e5cbb6770849a93632e8818/TiaProjekt/ProjektPlcSimAdvTest_20220518_0802.zap16
--------------------------------------------------------------------------------