OK meccanismo x rilevare variazione trigger...

This commit is contained in:
Samuele E. Locatelli
2020-07-03 14:29:44 +02:00
parent 6b6ef928da
commit 9d3fd84e5f
6 changed files with 504 additions and 594 deletions
+80 -72
View File
@@ -1,74 +1,82 @@
{
"confPLC": {
"ipAdrr": "192.168.214.1",
"tipoCpu": "S7300",
"rack": 0,
"slot": 2
"confPLC": {
"ipAdrr": "192.168.214.1",
"tipoCpu": "S7300",
"rack": 0,
"slot": 2
},
"triggerList": {
"DB700.DBB0": {
"Column": "Trigger",
"MemConf": "DB700.DBB0",
"DataType": "byte",
"memByteSize": 1,
"TriggerVal": "01"
}
},
"parametersList": {
"DB700.DBB8": {
"Column": "Valore 1",
"Index": 1,
"MemConf": "DB700.DBB8",
"DataType": "word",
"memByteSize": 2
},
"TriggerMemConf": "DB700.DBB0",
"parametersList": {
"DB700.DBB8": {
"Column": "Valore 1",
"Index": 1,
"MemConf": "DB700.DBB8",
"DataType": "word",
"memByteSize": 2
},
"DB700.DBB10": {
"Column": "Valore 2",
"Index": 2,
"MemConf": "DB700.DBB10",
"DataType": "word",
"memByteSize": 2
},
"DB700.DBB16": {
"Column": "Valore 3",
"Index": 3,
"MemConf": "DB700.DBB16",
"DataType": "dword",
"memByteSize": 4
},
"DB700.DBB20": {
"Column": "Valore 4",
"Index": 4,
"MemConf": "DB700.DBB20",
"DataType": "dword",
"memByteSize": 4
},
"DB700.DBB32": {
"Column": "Valore 5",
"Index": 5,
"MemConf": "DB700.DBB32",
"DataType": "real",
"memByteSize": 4
},
"DB700.DBB36": {
"Column": "Valore 6",
"Index": 6,
"MemConf": "DB700.DBB36",
"DataType": "real",
"memByteSize": 4
},
"DB700.DBB40": {
"Column": "Valore 7",
"Index": 7,
"MemConf": "DB700.DBB40",
"DataType": "real",
"memByteSize": 4
},
"DB700.DBB48": {
"Column": "Valore 8",
"Index": 8,
"MemConf": "DB700.DBB48",
"DataType": "string",
"memByteSize": 20
}
//"parametersList": {
// "DB701.DBD142": {
// "Column": "Valore assoluto",
// "Index": 7,
// "MemConf": "DB701.DBD142",
// "DataType": "real"
// }
//}
}
"DB700.DBB10": {
"Column": "Valore 2",
"Index": 2,
"MemConf": "DB700.DBB10",
"DataType": "word",
"memByteSize": 2
},
"DB700.DBB16": {
"Column": "Valore 3",
"Index": 3,
"MemConf": "DB700.DBB16",
"DataType": "dword",
"memByteSize": 4
},
"DB700.DBB20": {
"Column": "Valore 4",
"Index": 4,
"MemConf": "DB700.DBB20",
"DataType": "dword",
"memByteSize": 4
},
"DB700.DBB32": {
"Column": "Valore 5",
"Index": 5,
"MemConf": "DB700.DBB32",
"DataType": "real",
"memByteSize": 4
},
"DB700.DBB36": {
"Column": "Valore 6",
"Index": 6,
"MemConf": "DB700.DBB36",
"DataType": "real",
"memByteSize": 4
},
"DB700.DBB40": {
"Column": "Valore 7",
"Index": 7,
"MemConf": "DB700.DBB40",
"DataType": "real",
"memByteSize": 4
},
"DB700.DBB48": {
"Column": "Valore 8",
"Index": 8,
"MemConf": "DB700.DBB48",
"DataType": "string",
"memByteSize": 20
}
//"parametersList": {
// "DB701.DBD142": {
// "Column": "Valore assoluto",
// "Index": 7,
// "MemConf": "DB701.DBD142",
// "DataType": "real"
// }
//}
}
+64 -64
View File
@@ -1,67 +1,67 @@
{
"confPLC": {
"ipAdrr": "192.168.0.102",
"tipoCpu": "S71500",
"rack": 0,
"slot": 1
},
"TriggerMemConf": "DB999.DBB0",
"parametersList": {
"DB999.DBB8": {
"Column": "Valore 1",
"Index": 1,
"MemConf": "DB999.DBB8",
"DataType": "word",
"memByteSize": 2
},
"DB999.DBB10": {
"Column": "Valore 2",
"Index": 2,
"MemConf": "DB999.DBB10",
"DataType": "word",
"memByteSize": 2
},
"DB999.DBB16": {
"Column": "Valore 3",
"Index": 3,
"MemConf": "DB999.DBB16",
"DataType": "dword",
"memByteSize": 4
},
"DB999.DBB20": {
"Column": "Valore 4",
"Index": 4,
"MemConf": "DB999.DBB20",
"DataType": "dword",
"memByteSize": 4
},
"DB999.DBB32": {
"Column": "Valore 5",
"Index": 5,
"MemConf": "DB999.DBB32",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB36": {
"Column": "Valore 6",
"Index": 6,
"MemConf": "DB999.DBB36",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB40": {
"Column": "Valore 7",
"Index": 7,
"MemConf": "DB999.DBB40",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB48": {
"Column": "Valore 8",
"Index": 8,
"MemConf": "DB999.DBB48",
"DataType": "string",
"memByteSize": 20
}
"confPLC": {
"ipAdrr": "192.168.0.102",
"tipoCpu": "S71500",
"rack": 0,
"slot": 1
},
"triggerList": {
"DB999.DBB0": {
"Column": "Trigger",
"MemConf": "DB999.DBB0",
"DataType": "byte",
"memByteSize": 1,
"TriggerVal": "01"
}
},
"parametersList": {
"DB999.DBB8": {
"Column": "Valore 1",
"MemConf": "DB999.DBB8",
"DataType": "word",
"memByteSize": 2
},
"DB999.DBB10": {
"Column": "Valore 2",
"MemConf": "DB999.DBB10",
"DataType": "word",
"memByteSize": 2
},
"DB999.DBB16": {
"Column": "Valore 3",
"MemConf": "DB999.DBB16",
"DataType": "dword",
"memByteSize": 4
},
"DB999.DBB20": {
"Column": "Valore 4",
"MemConf": "DB999.DBB20",
"DataType": "dword",
"memByteSize": 4
},
"DB999.DBB32": {
"Column": "Valore 5",
"MemConf": "DB999.DBB32",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB36": {
"Column": "Valore 6",
"MemConf": "DB999.DBB36",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB40": {
"Column": "Valore 7",
"MemConf": "DB999.DBB40",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB48": {
"Column": "Valore 8",
"MemConf": "DB999.DBB48",
"DataType": "string",
"memByteSize": 20
}
}
}
+64 -64
View File
@@ -1,67 +1,67 @@
{
"confPLC": {
"ipAdrr": "192.168.0.102",
"tipoCpu": "S71500",
"rack": 0,
"slot": 1
},
"TriggerMemConf": "DB999.DBB0",
"parametersList": {
"DB999.DBB8": {
"Column": "Valore 1",
"Index": 1,
"MemConf": "DB999.DBB8",
"DataType": "word",
"memByteSize": 2
},
"DB999.DBB10": {
"Column": "Valore 2",
"Index": 2,
"MemConf": "DB999.DBB10",
"DataType": "word",
"memByteSize": 2
},
"DB999.DBB16": {
"Column": "Valore 3",
"Index": 3,
"MemConf": "DB999.DBB16",
"DataType": "dword",
"memByteSize": 4
},
"DB999.DBB20": {
"Column": "Valore 4",
"Index": 4,
"MemConf": "DB999.DBB20",
"DataType": "dword",
"memByteSize": 4
},
"DB999.DBB32": {
"Column": "Valore 5",
"Index": 5,
"MemConf": "DB999.DBB32",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB36": {
"Column": "Valore 6",
"Index": 6,
"MemConf": "DB999.DBB36",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB40": {
"Column": "Valore 7",
"Index": 7,
"MemConf": "DB999.DBB40",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB48": {
"Column": "Valore 8",
"Index": 8,
"MemConf": "DB999.DBB48",
"DataType": "string",
"memByteSize": 20
}
"confPLC": {
"ipAdrr": "192.168.0.102",
"tipoCpu": "S71500",
"rack": 0,
"slot": 1
},
"triggerList": {
"DB999.DBB0": {
"Column": "Trigger",
"MemConf": "DB999.DBB0",
"DataType": "byte",
"memByteSize": 1,
"TriggerVal": "01"
}
},
"parametersList": {
"DB999.DBB8": {
"Column": "Valore 1",
"MemConf": "DB999.DBB8",
"DataType": "word",
"memByteSize": 2
},
"DB999.DBB10": {
"Column": "Valore 2",
"MemConf": "DB999.DBB10",
"DataType": "word",
"memByteSize": 2
},
"DB999.DBB16": {
"Column": "Valore 3",
"MemConf": "DB999.DBB16",
"DataType": "dword",
"memByteSize": 4
},
"DB999.DBB20": {
"Column": "Valore 4",
"MemConf": "DB999.DBB20",
"DataType": "dword",
"memByteSize": 4
},
"DB999.DBB32": {
"Column": "Valore 5",
"MemConf": "DB999.DBB32",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB36": {
"Column": "Valore 6",
"MemConf": "DB999.DBB36",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB40": {
"Column": "Valore 7",
"MemConf": "DB999.DBB40",
"DataType": "real",
"memByteSize": 4
},
"DB999.DBB48": {
"Column": "Valore 8",
"MemConf": "DB999.DBB48",
"DataType": "string",
"memByteSize": 20
}
}
}
+180 -179
View File
@@ -28,189 +28,190 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IOB_Exporter));
this.txtCsvPath = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.lblPlcIp = new System.Windows.Forms.Label();
this.txtIP = new System.Windows.Forms.TextBox();
this.txtSlot = new System.Windows.Forms.TextBox();
this.lblPlcSlot = new System.Windows.Forms.Label();
this.txtRack = new System.Windows.Forms.TextBox();
this.lblPlcRack = new System.Windows.Forms.Label();
this.lblPlcCpu = new System.Windows.Forms.Label();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.tsslApp = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.txtCpuType = new System.Windows.Forms.TextBox();
this.txtLog = new System.Windows.Forms.TextBox();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// txtCsvPath
//
this.txtCsvPath.Enabled = false;
this.txtCsvPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtCsvPath.Location = new System.Drawing.Point(28, 40);
this.txtCsvPath.Name = "txtCsvPath";
this.txtCsvPath.Size = new System.Drawing.Size(172, 20);
this.txtCsvPath.TabIndex = 0;
this.txtCsvPath.Text = "c:\\TMP\\OutputFile.csv";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(25, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 1;
this.label1.Text = "CSV File";
//
// lblPlcIp
//
this.lblPlcIp.AutoSize = true;
this.lblPlcIp.Location = new System.Drawing.Point(279, 24);
this.lblPlcIp.Name = "lblPlcIp";
this.lblPlcIp.Size = new System.Drawing.Size(42, 13);
this.lblPlcIp.TabIndex = 2;
this.lblPlcIp.Text = "IP Addr";
//
// txtIP
//
this.txtIP.Enabled = false;
this.txtIP.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtIP.Location = new System.Drawing.Point(340, 21);
this.txtIP.Name = "txtIP";
this.txtIP.Size = new System.Drawing.Size(106, 20);
this.txtIP.TabIndex = 3;
this.txtIP.Text = "192.168.0.102";
this.txtIP.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// txtSlot
//
this.txtSlot.Enabled = false;
this.txtSlot.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtSlot.Location = new System.Drawing.Point(499, 47);
this.txtSlot.Margin = new System.Windows.Forms.Padding(2);
this.txtSlot.Name = "txtSlot";
this.txtSlot.Size = new System.Drawing.Size(29, 20);
this.txtSlot.TabIndex = 10;
this.txtSlot.Text = "1";
this.txtSlot.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// lblPlcSlot
//
this.lblPlcSlot.AutoSize = true;
this.lblPlcSlot.Location = new System.Drawing.Point(462, 49);
this.lblPlcSlot.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPlcSlot.Name = "lblPlcSlot";
this.lblPlcSlot.Size = new System.Drawing.Size(25, 13);
this.lblPlcSlot.TabIndex = 8;
this.lblPlcSlot.Text = "Slot";
//
// txtRack
//
this.txtRack.Enabled = false;
this.txtRack.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtRack.Location = new System.Drawing.Point(499, 21);
this.txtRack.Margin = new System.Windows.Forms.Padding(2);
this.txtRack.Name = "txtRack";
this.txtRack.Size = new System.Drawing.Size(29, 20);
this.txtRack.TabIndex = 11;
this.txtRack.Text = "0";
this.txtRack.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// lblPlcRack
//
this.lblPlcRack.AutoSize = true;
this.lblPlcRack.Location = new System.Drawing.Point(462, 23);
this.lblPlcRack.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPlcRack.Name = "lblPlcRack";
this.lblPlcRack.Size = new System.Drawing.Size(33, 13);
this.lblPlcRack.TabIndex = 9;
this.lblPlcRack.Text = "Rack";
//
// lblPlcCpu
//
this.lblPlcCpu.AutoSize = true;
this.lblPlcCpu.Location = new System.Drawing.Point(279, 49);
this.lblPlcCpu.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPlcCpu.Name = "lblPlcCpu";
this.lblPlcCpu.Size = new System.Drawing.Size(56, 13);
this.lblPlcCpu.TabIndex = 7;
this.lblPlcCpu.Text = "CPU Type";
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IOB_Exporter));
this.txtCsvPath = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.lblPlcIp = new System.Windows.Forms.Label();
this.txtIP = new System.Windows.Forms.TextBox();
this.txtSlot = new System.Windows.Forms.TextBox();
this.lblPlcSlot = new System.Windows.Forms.Label();
this.txtRack = new System.Windows.Forms.TextBox();
this.lblPlcRack = new System.Windows.Forms.Label();
this.lblPlcCpu = new System.Windows.Forms.Label();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.tsslApp = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.txtCpuType = new System.Windows.Forms.TextBox();
this.txtLog = new System.Windows.Forms.TextBox();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// txtCsvPath
//
this.txtCsvPath.Enabled = false;
this.txtCsvPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtCsvPath.Location = new System.Drawing.Point(28, 40);
this.txtCsvPath.Name = "txtCsvPath";
this.txtCsvPath.Size = new System.Drawing.Size(172, 20);
this.txtCsvPath.TabIndex = 0;
this.txtCsvPath.Text = "c:\\TMP\\OutputFile.csv";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(25, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 1;
this.label1.Text = "CSV File";
//
// lblPlcIp
//
this.lblPlcIp.AutoSize = true;
this.lblPlcIp.Location = new System.Drawing.Point(279, 24);
this.lblPlcIp.Name = "lblPlcIp";
this.lblPlcIp.Size = new System.Drawing.Size(42, 13);
this.lblPlcIp.TabIndex = 2;
this.lblPlcIp.Text = "IP Addr";
//
// txtIP
//
this.txtIP.Enabled = false;
this.txtIP.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtIP.Location = new System.Drawing.Point(340, 21);
this.txtIP.Name = "txtIP";
this.txtIP.Size = new System.Drawing.Size(106, 20);
this.txtIP.TabIndex = 3;
this.txtIP.Text = "192.168.0.102";
this.txtIP.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// txtSlot
//
this.txtSlot.Enabled = false;
this.txtSlot.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtSlot.Location = new System.Drawing.Point(499, 47);
this.txtSlot.Margin = new System.Windows.Forms.Padding(2);
this.txtSlot.Name = "txtSlot";
this.txtSlot.Size = new System.Drawing.Size(29, 20);
this.txtSlot.TabIndex = 10;
this.txtSlot.Text = "1";
this.txtSlot.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// lblPlcSlot
//
this.lblPlcSlot.AutoSize = true;
this.lblPlcSlot.Location = new System.Drawing.Point(462, 49);
this.lblPlcSlot.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPlcSlot.Name = "lblPlcSlot";
this.lblPlcSlot.Size = new System.Drawing.Size(25, 13);
this.lblPlcSlot.TabIndex = 8;
this.lblPlcSlot.Text = "Slot";
//
// txtRack
//
this.txtRack.Enabled = false;
this.txtRack.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtRack.Location = new System.Drawing.Point(499, 21);
this.txtRack.Margin = new System.Windows.Forms.Padding(2);
this.txtRack.Name = "txtRack";
this.txtRack.Size = new System.Drawing.Size(29, 20);
this.txtRack.TabIndex = 11;
this.txtRack.Text = "0";
this.txtRack.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// lblPlcRack
//
this.lblPlcRack.AutoSize = true;
this.lblPlcRack.Location = new System.Drawing.Point(462, 23);
this.lblPlcRack.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPlcRack.Name = "lblPlcRack";
this.lblPlcRack.Size = new System.Drawing.Size(33, 13);
this.lblPlcRack.TabIndex = 9;
this.lblPlcRack.Text = "Rack";
//
// lblPlcCpu
//
this.lblPlcCpu.AutoSize = true;
this.lblPlcCpu.Location = new System.Drawing.Point(279, 49);
this.lblPlcCpu.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPlcCpu.Name = "lblPlcCpu";
this.lblPlcCpu.Size = new System.Drawing.Size(56, 13);
this.lblPlcCpu.TabIndex = 7;
this.lblPlcCpu.Text = "CPU Type";
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsslApp,
this.toolStripProgressBar1});
this.statusStrip1.Location = new System.Drawing.Point(0, 421);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(658, 22);
this.statusStrip1.TabIndex = 12;
this.statusStrip1.Text = "statusStrip1";
//
// tsslApp
//
this.tsslApp.Name = "tsslApp";
this.tsslApp.Size = new System.Drawing.Size(16, 17);
this.tsslApp.Text = "...";
//
// toolStripProgressBar1
//
this.toolStripProgressBar1.Name = "toolStripProgressBar1";
this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 16);
//
// txtCpuType
//
this.txtCpuType.Enabled = false;
this.txtCpuType.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtCpuType.Location = new System.Drawing.Point(340, 47);
this.txtCpuType.Name = "txtCpuType";
this.txtCpuType.Size = new System.Drawing.Size(106, 20);
this.txtCpuType.TabIndex = 13;
this.txtCpuType.Text = "S71200";
this.txtCpuType.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// txtLog
//
this.txtLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.statusStrip1.Location = new System.Drawing.Point(0, 421);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(658, 22);
this.statusStrip1.TabIndex = 12;
this.statusStrip1.Text = "statusStrip1";
//
// tsslApp
//
this.tsslApp.Name = "tsslApp";
this.tsslApp.Size = new System.Drawing.Size(16, 17);
this.tsslApp.Text = "...";
//
// toolStripProgressBar1
//
this.toolStripProgressBar1.Name = "toolStripProgressBar1";
this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 16);
//
// txtCpuType
//
this.txtCpuType.Enabled = false;
this.txtCpuType.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtCpuType.Location = new System.Drawing.Point(340, 47);
this.txtCpuType.Name = "txtCpuType";
this.txtCpuType.Size = new System.Drawing.Size(106, 20);
this.txtCpuType.TabIndex = 13;
this.txtCpuType.Text = "S71200";
this.txtCpuType.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// txtLog
//
this.txtLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtLog.BackColor = System.Drawing.Color.Black;
this.txtLog.Enabled = false;
this.txtLog.ForeColor = System.Drawing.SystemColors.MenuHighlight;
this.txtLog.Location = new System.Drawing.Point(13, 82);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.Size = new System.Drawing.Size(633, 336);
this.txtLog.TabIndex = 14;
this.txtLog.Text = "...";
//
// IOB_Exporter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(658, 443);
this.Controls.Add(this.txtLog);
this.Controls.Add(this.txtCpuType);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.txtSlot);
this.Controls.Add(this.lblPlcSlot);
this.Controls.Add(this.txtRack);
this.Controls.Add(this.lblPlcRack);
this.Controls.Add(this.lblPlcCpu);
this.Controls.Add(this.txtIP);
this.Controls.Add(this.lblPlcIp);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtCsvPath);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "IOB_Exporter";
this.Text = "MAPO IOB Exporter";
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
this.txtLog.BackColor = System.Drawing.Color.Black;
this.txtLog.ForeColor = System.Drawing.SystemColors.MenuHighlight;
this.txtLog.Location = new System.Drawing.Point(13, 73);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.ReadOnly = true;
this.txtLog.Size = new System.Drawing.Size(633, 345);
this.txtLog.TabIndex = 14;
this.txtLog.Text = "- - -";
this.txtLog.WordWrap = false;
//
// IOB_Exporter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(658, 443);
this.Controls.Add(this.txtLog);
this.Controls.Add(this.txtCpuType);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.txtSlot);
this.Controls.Add(this.lblPlcSlot);
this.Controls.Add(this.txtRack);
this.Controls.Add(this.lblPlcRack);
this.Controls.Add(this.lblPlcCpu);
this.Controls.Add(this.txtIP);
this.Controls.Add(this.lblPlcIp);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtCsvPath);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "IOB_Exporter";
this.Text = "MAPO IOB Exporter";
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
+72 -175
View File
@@ -81,6 +81,7 @@ namespace IOB.WIN.FileExp
private void myInit()
{
lg = LogManager.GetCurrentClassLogger();
txtLog.Text = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ----------------------------------------------------";
tsslApp.Text = $"{utils.CRS("appName")}";
fixVisibility();
prevValues = new Dictionary<string, string>();
@@ -89,11 +90,11 @@ namespace IOB.WIN.FileExp
loadPlc();
startUiTimer();
startCheckTimer();
#if false
startSampleTimer();
#endif
startPlcSampleTimer();
}
/// <summary>
/// Fix visibilità parametri conf in debug
/// </summary>
private void fixVisibility()
{
bool showParams = false;
@@ -109,7 +110,9 @@ namespace IOB.WIN.FileExp
txtRack.Visible = showParams;
txtSlot.Visible = showParams;
}
/// <summary>
/// avvio timer update UI
/// </summary>
private void startUiTimer()
{
// setup progressBar
@@ -119,14 +122,9 @@ namespace IOB.WIN.FileExp
uiTimer.Tick += UiTimer_Tick;
uiTimer.Start();
}
private void startSampleTimer()
{
int sampleTimerMs = utils.CRI("sampleTimerMs");
sampleTimerMs = sampleTimerMs < 100 ? 100 : sampleTimerMs;
sampleTimer.Interval = sampleTimerMs;
sampleTimer.Tick += SampleTimer_Tick;
sampleTimer.Start();
}
/// <summary>
/// Avvio timer controlli periodici (PLC; file...)
/// </summary>
private void startCheckTimer()
{
// check preliminare...
@@ -136,6 +134,19 @@ namespace IOB.WIN.FileExp
checkTimer.Tick += CheckTimer_Tick;
checkTimer.Start();
}
/// <summary>
/// Avvio timer campionamento PLC
/// </summary>
private void startPlcSampleTimer()
{
int sampleTimerMs = utils.CRI("sampleTimerMs");
// limite in lettura a 5 hz
sampleTimerMs = sampleTimerMs < 200 ? 200 : sampleTimerMs;
sampleTimer.Interval = sampleTimerMs;
sampleTimer.Tick += plcSampleTimer_Tick;
sampleTimer.Start();
}
/// <summary>
/// init PLC
/// </summary>
@@ -172,7 +183,6 @@ namespace IOB.WIN.FileExp
protected void loadMemConf()
{
lgInfo("Starting loadMemConf");
// recupero conf da resources
Assembly myAssembly = Assembly.GetExecutingAssembly();
//var resNames = myAssembly.GetManifestResourceNames();
@@ -183,7 +193,7 @@ namespace IOB.WIN.FileExp
string jsonData = fileReader.ReadToEnd();
if (!string.IsNullOrEmpty(jsonData))
{
lgInfo("Setup File found!");
lgInfo("Setup OK!");
try
{
currDataProxy = JsonConvert.DeserializeObject<dataProxy>(jsonData);
@@ -196,7 +206,6 @@ namespace IOB.WIN.FileExp
currDataProxy.parametersList.Remove(currDataProxy.parametersList.LastOrDefault().Key);
}
}
lgInfo("Completed data deserialization");
}
catch
@@ -209,11 +218,10 @@ namespace IOB.WIN.FileExp
if (currDataProxy == null)
{
lgInfo($"File NOT found: {setupFile} - creating new");
lgInfo($"Setup File NOT found: {setupFile} - creating new");
dataConf newParam = new dataConf()
{
Column = "Valore assoluto",
Index = 8,
MemConf = "DB701.DBD142",
DataType = "real"
};
@@ -222,7 +230,7 @@ namespace IOB.WIN.FileExp
// creo nuovo obj...
currDataProxy = new dataProxy()
{
TriggerMemConf = "DB700.DBB0",
triggerList = null,
confPLC = new connParam()
{
ipAdrr = "192.168.0.102",
@@ -288,6 +296,7 @@ namespace IOB.WIN.FileExp
// verifico esistenza file sennò creo
if (!File.Exists(outFilePath))
{
lgInfo("Target file not found: creating new!");
string fileContent = "";
// se non esiste --> creo con headers se richiesto!
if (utils.CRB("csvHeader"))
@@ -309,25 +318,19 @@ namespace IOB.WIN.FileExp
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SampleTimer_Tick(object sender, EventArgs e)
private void plcSampleTimer_Tick(object sender, EventArgs e)
{
// rileggo il file
// leggo aree di memoria triggers dal PLC
reloadTriggersFromPLC();
// verifico valore confrontando con i precedenti...
if (dataChanged())
{
// loggo!
lgInfo("Data Change on PLC");
//rileggo dal PLC
readDataFromPLC();
// invio a PLC
// invio su file
saveToFile();
}
}
#endregion
#region helper methods
@@ -366,10 +369,12 @@ namespace IOB.WIN.FileExp
private bool dataChanged()
{
bool answ = false;
// se i 2 vettori sono diversi
// se i 2 vettori sono diversi in numero
if (currValues.Count != prevValues.Count)
{
resetPrevVal();
// loggo!
lgInfo("Trigger activated on PLC: different count");
return true;
}
// verifico ogni singolo valore...
@@ -378,11 +383,27 @@ namespace IOB.WIN.FileExp
// cerco...
if (prevValues.ContainsKey(item.Key))
{
// verifico se diversi --> trovato cambio!
answ = currValues[item.Key] != prevValues[item.Key];
// verifico se diversi --> trovato cambio, indago!
if (currValues[item.Key] != prevValues[item.Key])
{
// loggo!
lgInfo($"Difference found: {prevValues[item.Key]} --> {currValues[item.Key]}");
// solo se il NUOVO valore è pari al trigger cercato...
if (currValues[item.Key] == currDataProxy.triggerList[item.Key].TriggerVal)
{
lgInfo($"Valid Trigger found: {currDataProxy.triggerList[item.Key].TriggerVal}");
answ = true;
}
else
{
// senza segnalare cambio recepisco nuovo valore...
resetPrevVal();
}
}
}
else
{
lgInfo($"Trigger activated on PLC: new value found --> {item.Key}");
answ = true;
}
// se ho cambiamenti --> esco!
@@ -413,148 +434,21 @@ namespace IOB.WIN.FileExp
/// </summary>
protected void reloadTriggersFromPLC()
{
#if false
if (File.Exists(currDataProxy.csvFilePath))
// init
memAddress memoria = null;
int numByte = 0;
// leggo triggers dal PLC
foreach (var item in currDataProxy.triggerList)
{
// leggo...
using (StreamReader sr = new StreamReader(currDataProxy.csvFilePath))
{
string currentLine;
//se ha header salto la prima riga...
if (currDataProxy.csvFileEnableWrite)
{
if ((currentLine = sr.ReadLine()) == null)
{
// vuoto: loggo ed esco!
lgError("Errore intestazione vuota!");
return;
}
}
// ora leggo la riga successiva... SE !=null
if ((currentLine = sr.ReadLine()) != null)
{
// splitto riga e cerco valore...
var valori = currentLine.Split(currDataProxy.csvSeparator);
// cerco parametri!
try
{
foreach (var item in currDataProxy.parametersList)
{
// cerco!
if (valori.Count() >= item.Value.Index)
{
upsertValue(item.Key, valori[item.Value.Index]);
}
}
}
catch (Exception exc)
{
lgError($"Eccezione i decodifica riga misura: {Environment.NewLine}{exc}");
}
loaderLogCounter--;
if (loaderLogCounter < 0)
{
// loggo che ho letto file e che contiene una certa riga...
lgInfo($"Verifica periodica riga file, contenuto:{Environment.NewLine}{currentLine}");
loaderLogCounter = 30;
}
}
else
{
// vuoto: loggo ed esco!
lgError("Errore riga vuota!");
return;
}
loaderLogCounter--;
if (loaderLogCounter < 0)
{
// loggo che ho letto file e che contiene una certa riga...
lgInfo("Check periodico file presente OK");
loaderLogCounter = 30;
}
}
memoria = new memAddress(item.Value.MemConf);
numByte = item.Value.memByteSize;
// leggo!
var currMem = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
// salvo
upsertValue(item.Value.MemConf, BitConverter.ToString(currMem));
}
else
{
lgError($"Errore! file non trovato: {currDataProxy.csvFilePath}");
}
#endif
}
/// <summary>
/// Effettua rilettura da file
/// </summary>
protected void readDataFromPLC()
{
#if false
if (File.Exists(currDataProxy.csvFilePath))
{
// leggo...
using (StreamReader sr = new StreamReader(currDataProxy.csvFilePath))
{
string currentLine;
//se ha header salto la prima riga...
if (currDataProxy.csvFileEnableWrite)
{
if ((currentLine = sr.ReadLine()) == null)
{
// vuoto: loggo ed esco!
lgError("Errore intestazione vuota!");
return;
}
}
// ora leggo la riga successiva... SE !=null
if ((currentLine = sr.ReadLine()) != null)
{
// splitto riga e cerco valore...
var valori = currentLine.Split(currDataProxy.csvSeparator);
// cerco parametri!
try
{
foreach (var item in currDataProxy.parametersList)
{
// cerco!
if (valori.Count() >= item.Value.Index)
{
upsertValue(item.Key, valori[item.Value.Index]);
}
}
}
catch (Exception exc)
{
lgError($"Eccezione i decodifica riga misura: {Environment.NewLine}{exc}");
}
loaderLogCounter--;
if (loaderLogCounter < 0)
{
// loggo che ho letto file e che contiene una certa riga...
lgInfo($"Verifica periodica riga file, contenuto:{Environment.NewLine}{currentLine}");
loaderLogCounter = 30;
}
}
else
{
// vuoto: loggo ed esco!
lgError("Errore riga vuota!");
return;
}
loaderLogCounter--;
if (loaderLogCounter < 0)
{
// loggo che ho letto file e che contiene una certa riga...
lgInfo("Check periodico file presente OK");
loaderLogCounter = 30;
}
}
}
else
{
lgError($"Errore! file non trovato: {currDataProxy.csvFilePath}");
}
#endif
}
protected void upsertValue(string key, string value)
{
@@ -568,7 +462,6 @@ namespace IOB.WIN.FileExp
{
currValues.Add(key, value);
}
}
/// <summary>
@@ -618,10 +511,14 @@ namespace IOB.WIN.FileExp
}
return answ;
}
private void appenRTLog(string contenuto)
/// <summary>
/// Aggiorno log in area console
/// </summary>
/// <param name="contenuto"></param>
private void appendRTLog(string contenuto)
{
// se troppe righe trimmo...
string fullLog = limitLine2show($"{contenuto}{Environment.NewLine}{txtLog.Text}");
string fullLog = limitLine2show($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} {contenuto}{Environment.NewLine}{txtLog.Text}");
// update
txtLog.Text = fullLog;
}
@@ -647,19 +544,19 @@ namespace IOB.WIN.FileExp
protected void lgInfo(string contenuto)
{
lg.Info(contenuto);
appenRTLog(contenuto);
appendRTLog($"| INFO | {contenuto}");
}
protected void lgError(string contenuto)
{
lg.Error(contenuto);
appenRTLog(contenuto);
appendRTLog($"| ERROR | {contenuto}");
}
protected void lgError(Exception exc, string contenuto)
{
lg.Error(exc, contenuto);
appenRTLog(contenuto);
appendRTLog($"| EXC | {contenuto}");
}
#endregion
+44 -40
View File
@@ -6,49 +6,53 @@ using System.Threading.Tasks;
namespace IOB.WIN.FileExp
{
/// <summary>
/// classe costruzione dataproxy
/// </summary>
public class dataProxy
{
/// <summary>
/// classe costruzione dataproxy
/// Configurazione PLC
/// </summary>
public class dataProxy
{
/// <summary>
/// Configurazione PLC
/// </summary>
public connParam confPLC { get; set; }
/// <summary>
/// Area memoria da usare come trigger x scrittura
/// </summary>
public string TriggerMemConf { get; set; } = "";
/// <summary>
/// Elenco parametri da salvare
/// </summary>
public Dictionary<string, dataConf> parametersList { get; set; } = new Dictionary<string, dataConf>();
}
public connParam confPLC { get; set; }
/// <summary>
/// Aree memoria da usare come trigger x scatenare salvataggio valori
/// </summary>
public Dictionary<string, triggerConf> triggerList { get; set; } = new Dictionary<string, triggerConf>();
/// <summary>
/// Elenco parametri da salvare
/// </summary>
public Dictionary<string, dataConf> parametersList { get; set; } = new Dictionary<string, dataConf>();
}
public class triggerConf:dataConf
{
/// <summary>
/// Configurazione item memoria gestito
/// Valore trigger che scatena evento (SE trovato post cambio valore)
/// </summary>
public class dataConf
{
/// <summary>
/// Colonna (intestazione) se non presente indice
/// </summary>
public string Column { get; set; } = "";
/// <summary>
/// Indice colonna (se presente usa questo)
/// </summary>
public int Index { get; set; } = -1;
/// <summary>
/// Area memoria da cui leggere i dati
/// </summary>
public string MemConf { get; set; } = "";
/// <summary>
/// Tipo di dati
/// </summary>
public string DataType { get; set; } = "";
/// <summary>
/// Dimensione memoria in Byte
/// </summary>
public int memByteSize { get; set; } = 1;
}
public string TriggerVal { get; set; } = "";
}
/// <summary>
/// Configurazione item memoria gestito
/// </summary>
public class dataConf
{
/// <summary>
/// Colonna (intestazione) se non presente indice
/// </summary>
public string Column { get; set; } = "";
/// <summary>
/// Area memoria da cui leggere i dati
/// </summary>
public string MemConf { get; set; } = "";
/// <summary>
/// Tipo di dati
/// </summary>
public string DataType { get; set; } = "";
/// <summary>
/// Dimensione memoria in Byte
/// </summary>
public int memByteSize { get; set; } = 1;
}
}