Merge branch 'release/AdapterRobotService'

This commit is contained in:
Samuele Locatelli
2021-09-23 19:08:06 +02:00
10 changed files with 435 additions and 47 deletions
+5
View File
@@ -354,6 +354,11 @@ namespace IOB_UT_NEXT
/// </summary>
SIEMENS_PRESSOIL_CEI,
/// <summary>
/// Adapter SIEMENS, interfaccia verisone RobotService (Donati, smerigliatrici)
/// </summary>
SIEMENS_ROBOTSERVICE,
/// <summary>
/// Adapter SIEMENS, interfaccia versione SAET (Valvital, forni / tempra)
/// </summary>
+5
View File
@@ -1264,6 +1264,11 @@ namespace IOB_WIN_NEXT
start.Enabled = true;
break;
case tipoAdapter.SIEMENS_ROBOTSERVICE:
iobObj = new IobSiemensRobotService(this, IOBConf);
start.Enabled = true;
break;
case tipoAdapter.SIEMENS_SAET:
iobObj = new IobSiemensSaet(this, IOBConf);
start.Enabled = true;
+1 -1
View File
@@ -69,7 +69,7 @@
},
"ContatoreParziale": {
"name": "ContatoreParziale",
"description": "Contapezzi Parziale2",
"description": "Contapezzi MES DBB208",
"memAddr": "DB6.DBB208",
"tipoMem": "DInt",
"index": 208,
+67
View File
@@ -0,0 +1,67 @@
;Configurazione IOB-WIN
[IOB]
;Macchina transfer COSMAP per Donati
CNCTYPE=SIEMENS_ROBOTSERVICE
PING_MS_TIMEOUT=500
[MACHINE]
VENDOR=RobotService
MODEL=SMER12
[CNC]
IP=192.168.51.138
CPUTYPE=S71500
RACK=0
SLOT=0
[SERVER]
MPIP=http://192.168.51.79
MPURL=/MP/IO
CMDBASE=/IOB/input/
CMDFLOG=/IOB/flog/
CMDALIVE=/IOB
CMDENABLED=/IOB/enabled/
CMDADV1=?valore=
CMDREBO=/sendReboot.aspx?idxMacchina=
[MEMORY]
ADDR_READ=DB15.DBB0
ADDR_WRITE=DB14.DBB0
SIZE_READ=10
SIZE_WRITE=517
[BLINK]
;MAX_COUNTER_BLINK = 30
MAX_COUNTER_BLINK = 15
;bit0 = 0
;bit1 = 0
;bit2 = 1
;bit3 = 1
;bit4 = 1
;bit5 = 0
;bit6 = 0
;bit7 = 0
BLINK_FILT=0
;BLINK_FILT=28
[OPTPAR]
;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
PZCOUNT_MODE=STD.DB15.DBDW2
DISABLE_PZCOUNT=FALSE
ENABLE_SEND_PZC_BLOCK=TRUE
MIN_SEND_PZC_BLOCK=0
MAX_SEND_PZC_BLOCK=100
; gestione custom timer
timerIntMs=30
; GEST DATI DYN
ENABLE_DYN_DATA=TRUE
FORCE_DYN_DATA=TRUE
; gestione scrittura string/char[]: true = string / false = char[]
WRITE_PRE=TRUE
; conf parametri memoria READ/WRITE
PARAM_CONF=1033.json
[BRANCH]
NAME=master
+52
View File
@@ -0,0 +1,52 @@
{
"mMapWrite": {
"setComm": {
"name": "setComm",
"description": "Commessa",
"tipoMem": "String",
"memAddr": "DB14.DBB0",
"index": 0,
"size": 50
},
"setArt": {
"name": "setArt",
"description": "Articolo",
"tipoMem": "String",
"memAddr": "DB14.DBB256",
"index": 256,
"size": 50
},
"setPzComm": {
"name": "setPzComm",
"description": "Qty",
"memAddr": "DB14.DBB512",
"tipoMem": "DInt",
"index": 512,
"size": 4
}
},
"mMapRead": {
"Contatore01": {
"name": "PezziFineCiclo",
"description": "Mancanti programmati",
"memAddr": "DB15.DBB6",
"tipoMem": "DInt",
"index": 6,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"ContatoreParziale": {
"name": "ContaPezzi",
"description": "Contapezzi MES DBB2",
"memAddr": "DB15.DBB2",
"tipoMem": "DInt",
"index": 2,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
}
}
}
+7
View File
@@ -178,6 +178,7 @@
<Compile Include="IobOpcUaEwon.cs" />
<Compile Include="IobSiemensAt2001.cs" />
<Compile Include="IobSiemensComeca.cs" />
<Compile Include="IobSiemensRobotService.cs" />
<Compile Include="IobSiemensCosmap.cs" />
<Compile Include="IobSiemensSimec.cs" />
<Compile Include="IobSiemensLasco.cs" />
@@ -223,6 +224,12 @@
</Compile>
<Compile Include="UAClient.cs" />
<Compile Include="utils.cs" />
<None Include="DATA\CONF\1033.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\1033.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\IobOpcUaClient.Config.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+1 -1
View File
@@ -18,7 +18,7 @@ namespace IOB_WIN_NEXT
* - S7 vers 1500
*
* STRUTTURA MEMORIA DB29: (lettura) 10byte,
* G:\Drive condivisi\30_Clienti\Donati\Schemi DB\COSMAP
* G:\Drive condivisi\30_Clienti\Donati\Schemi IOB-WIN\COSMAP
*
* Si intende lettura/scrittura con DB6.DBxx
*
+251
View File
@@ -0,0 +1,251 @@
using MapoSDK;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace IOB_WIN_NEXT
{
/// <summary>
/// Controllo Siemens specifico x impianti RobotSerice (es Smerigliature DONATI)
/// </summary>
public class IobSiemensRobotService : IobSiemens
{
/* --------------------------------------------------------------------------------
* Controlli SIEMENS RobotService
* - basasto su SIEMENS
* - S7 vers 1500
*
* STRUTTURA MEMORIA DB15: (lettura) 10byte,
* G:\Drive condivisi\30_Clienti\Donati\Schemi IOB-WIN\RobotService
*
*
* DB15
* B0.0 Bit PowerOn
* B0.1 Bit Run
* B0.2 Bit Contapezzi
* B0.3 Bit Allarme
* B0.4 Bit Manuale
* B0.5 Bit MagOutPieno
* B0.6 Bit MagInVuoto
* Contapezzi DInt 2
* PezziRiman DInt 6
*
*
* STRUTTURA MEMORIA DB14: (scrittura) 520byte,
* G:\Drive condivisi\30_Clienti\Donati\Schemi IOB-WIN\RobotService
*
*
* DB14
* Commessa Odl String[000..256] String (254)
* CodArt String[256..512] String (254)
* QtaRich DInt 512 numero pezzi lanciati
* PzCountRes Bool/Byte 516 al fronte di salita (0-->1) reset contapezzi e NON CONTA mentre è 1, se 0 conta
*
* -------------------------------------------------------------------------------- */
#region Public Constructors
/// <summary>
/// Classe base con i metodi x Siemens
/// </summary>
/// <param name="caller"></param>
/// <param name="adpConf"></param>
public IobSiemensRobotService(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
{
lgInfo("NEW IOB SIEMENS versione RobotService");
}
#endregion Public Constructors
#region Protected Methods
/// <summary>
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
/// </summary>
protected override void decodeToBaseBitmap()
{
// init a zero...
B_input = 0;
/* -----------------------------------------------------
* bitmap MAPO STANDARD
* B0: POWER_ON
* B1: RUN
* B2: pzCount
* B3: allarme
* B4: manuale
* B5: MagOutPieno
* B6: MagInVuoto
*
----------------------------------------------------- */
byte mainData = RawInput[0];
// copio il primo byte
int byteSignals = RawInput[0];
// bit 0 (poweron) imposto a 1 SE connected...
if (currPLC.IsConnected)
{
byteSignals += (1 << 0);
}
// salvo!
B_input = byteSignals;
// log opzionale!
if (verboseLog)
{
lgInfo($"Trasformazione dati: B0: {mainData} --> B_input: {B_input}");
}
}
#endregion Protected Methods
#region Public Methods
/// <summary>
/// Processo i task richiesti e li elimino dalla coda 1:1
/// </summary>
/// <param name="task2exe"></param>
public override Dictionary<string, string> executeTasks(Dictionary<string, string> task2exe)
{
lgInfo($"Chiamata executeTasks specifica IobSiemensCosmap: {task2exe.Count} task ricevuti");
// Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti...
Dictionary<string, string> taskDone = new Dictionary<string, string>();
bool taskOk = false;
string taskVal = "";
// inizio con 1 byte di default
byte[] MemBlock = new byte[1];
string memAddrWrite = "";
if (task2exe != null)
{
// cerco task specifici
foreach (var item in task2exe)
{
taskOk = false;
taskVal = "";
// converto richiesta in enum...
taskType tName = taskType.nihil;
Enum.TryParse(item.Key, out tName);
// controllo sulla KEY
switch (tName)
{
case taskType.nihil:
case taskType.fixStopSetup:
case taskType.forceSetPzCount:
case taskType.setProg:
case taskType.sendWatchDogMes2Plc:
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
break;
case taskType.setPzComm:
case taskType.setArt:
case taskType.setComm:
saveProdData(item);
int byteSize = 0;
// recupero dati da memMap... altrimenti NULLA
if (memMap.mMapWrite.ContainsKey(item.Key))
{
dataConf currMem = memMap.mMapWrite[item.Key];
byteSize = currMem.size;
memAddrWrite = currMem.memAddr;
MemBlock = new byte[byteSize];
if (currMem.tipoMem == plcDataType.String)
{
saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize);
}
else if (currMem.tipoMem == plcDataType.DInt)
{
int valDInt = 0;
int.TryParse(item.Value, out valDInt);
MemBlock = S7.Net.Types.DInt.ToByteArray(valDInt);
}
else if (currMem.tipoMem == plcDataType.Int)
{
short valInt = 0;
short.TryParse(item.Value, out valInt);
MemBlock = S7.Net.Types.Int.ToByteArray(valInt);
}
}
else
{
string rawMemConf = JsonConvert.SerializeObject(memMap, Formatting.Indented);
lgError($"Errore: non trovata chiave write in memMap.mMapWrite per {item.Key}{Environment.NewLine}Configurazione memoria R/W:{Environment.NewLine}{rawMemConf}");
}
taskVal = item.Value;
break;
case taskType.forceResetPzCount:
// processo scrittura BIT su DB6.DBB516
MemBlock = new byte[1];
MemBlock = S7.Net.Types.Byte.ToByteArray(1);
memAddrWrite = "DB14.DBB516";
break;
case taskType.startSetup:
// processo scrittura BIT su DB6.DBB516
MemBlock = new byte[1];
MemBlock = S7.Net.Types.Byte.ToByteArray(1);
memAddrWrite = "DB14.DBB516";
break;
case taskType.stopSetup:
// processo scrittura BIT su DB6.DBB516
MemBlock = new byte[1];
MemBlock = S7.Net.Types.Byte.ToByteArray(0);
memAddrWrite = "DB14.DBB516";
break;
case taskType.setParameter:
// richiedo da URL i parametri WRITE da popolare
lgInfo("setParameter --> processMemWriteRequests");
taskVal = processMemWriteRequests();
// se restituiscce "" faccio altra prova...
if (string.IsNullOrEmpty(taskVal))
{
// i parametri me li aspetto come stringa composta paramName|paramvalue
if (item.Value.Contains("|"))
{
string[] paramsJob = item.Value.Split('|');
taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}";
}
else
{
taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value";
}
}
break;
default:
taskVal = "SKIPPED | NO EXEC";
break;
}
lgInfo($"executeTask: {tName} | {taskVal}");
// aggiungo task!
taskDone.Add(item.Key, taskVal);
if (!string.IsNullOrEmpty(memAddrWrite))
{
// scrivo!
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
}
if (taskOk)
{
// aggiorno valore memoria...
memMap.mMapWrite[item.Key].value = item.Value;
lgInfo($"Eseguita con successo S7WriteBB per executeTasks: {item.Key} | {item.Value}");
}
else
{
lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}");
}
}
}
return taskDone;
}
#endregion Public Methods
}
}
+12 -11
View File
@@ -1,16 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<appSettings>
<add key="appName" value="S7.Test"/>
<!--conf file-->
<add key="dataPath" value="DATA"/>
<add key="dataConfPath" value="DATA\CONF"/>
<add key="dataDatPath" value="DATA\DAT"/>
<add key="MMapR" value="MMapR.map"/>
<add key="MMapW" value="MMapW.map"/>
<add key="charSep" value="|"/>
</appSettings>
<appSettings>
<add key="appName" value="S7.Test" />
<!--conf file-->
<add key="verbose" value="false" />
<add key="dataPath" value="DATA" />
<add key="dataConfPath" value="DATA\CONF" />
<add key="dataDatPath" value="DATA\DAT" />
<add key="MMapR" value="MMapR.map" />
<add key="MMapW" value="MMapW.map" />
<add key="charSep" value="|" />
</appSettings>
</configuration>
+34 -34
View File
@@ -37,6 +37,7 @@
this.label3 = new System.Windows.Forms.Label();
this.txtMemSize = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnReadChar = new System.Windows.Forms.Button();
this.btnReadString = new System.Windows.Forms.Button();
this.btnReadDWord = new System.Windows.Forms.Button();
this.btnReadWord = new System.Windows.Forms.Button();
@@ -58,6 +59,7 @@
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.tslRTime = new System.Windows.Forms.ToolStripStatusLabel();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.btnCharWrite = new System.Windows.Forms.Button();
this.btnNumWriteReal = new System.Windows.Forms.Button();
this.btnStrWrite = new System.Windows.Forms.Button();
this.btnNumWriteB = new System.Windows.Forms.Button();
@@ -71,8 +73,6 @@
this.label10 = new System.Windows.Forms.Label();
this.txtWriteAddr1 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.btnCharWrite = new System.Windows.Forms.Button();
this.btnReadChar = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@@ -85,9 +85,9 @@
this.txtIP.Location = new System.Drawing.Point(64, 19);
this.txtIP.Margin = new System.Windows.Forms.Padding(2);
this.txtIP.Name = "txtIP";
this.txtIP.Size = new System.Drawing.Size(83, 20);
this.txtIP.Size = new System.Drawing.Size(99, 20);
this.txtIP.TabIndex = 0;
this.txtIP.Text = "192.168.0.51";
this.txtIP.Text = "127.0.0.1";
this.txtIP.TextChanged += new System.EventHandler(this.txtIP_TextChanged);
//
// lblIP
@@ -112,7 +112,7 @@
this.cbCpuType.Location = new System.Drawing.Point(64, 50);
this.cbCpuType.Margin = new System.Windows.Forms.Padding(2);
this.cbCpuType.Name = "cbCpuType";
this.cbCpuType.Size = new System.Drawing.Size(83, 21);
this.cbCpuType.Size = new System.Drawing.Size(99, 21);
this.cbCpuType.TabIndex = 2;
this.cbCpuType.Text = "S7300";
this.cbCpuType.SelectedIndexChanged += new System.EventHandler(this.cbCpuType_SelectedIndexChanged);
@@ -192,6 +192,17 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Memoria: READ param";
//
// btnReadChar
//
this.btnReadChar.Location = new System.Drawing.Point(104, 74);
this.btnReadChar.Margin = new System.Windows.Forms.Padding(2);
this.btnReadChar.Name = "btnReadChar";
this.btnReadChar.Size = new System.Drawing.Size(76, 20);
this.btnReadChar.TabIndex = 12;
this.btnReadChar.Text = "R Char[]";
this.btnReadChar.UseVisualStyleBackColor = true;
this.btnReadChar.Click += new System.EventHandler(this.btnReadChar_Click);
//
// btnReadString
//
this.btnReadString.Location = new System.Drawing.Point(10, 74);
@@ -318,18 +329,18 @@
this.textBox2.BackColor = System.Drawing.SystemColors.Menu;
this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox2.Location = new System.Drawing.Point(226, 31);
this.textBox2.Location = new System.Drawing.Point(240, 31);
this.textBox2.Margin = new System.Windows.Forms.Padding(2);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(105, 44);
this.textBox2.Size = new System.Drawing.Size(91, 44);
this.textBox2.TabIndex = 7;
this.textBox2.Text = "S7-1200/S7-1500: 0/0\r\nS7-300/S7-400: 0/2\r\nSlot > 0 se eth ext";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(226, 11);
this.label6.Location = new System.Drawing.Point(236, 11);
this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(91, 13);
@@ -338,7 +349,7 @@
//
// txtSlot
//
this.txtSlot.Location = new System.Drawing.Point(190, 50);
this.txtSlot.Location = new System.Drawing.Point(201, 50);
this.txtSlot.Margin = new System.Windows.Forms.Padding(2);
this.txtSlot.Name = "txtSlot";
this.txtSlot.Size = new System.Drawing.Size(32, 20);
@@ -349,7 +360,7 @@
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(156, 52);
this.label5.Location = new System.Drawing.Point(167, 52);
this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(25, 13);
@@ -358,7 +369,7 @@
//
// txtRack
//
this.txtRack.Location = new System.Drawing.Point(190, 19);
this.txtRack.Location = new System.Drawing.Point(201, 19);
this.txtRack.Margin = new System.Windows.Forms.Padding(2);
this.txtRack.Name = "txtRack";
this.txtRack.Size = new System.Drawing.Size(32, 20);
@@ -369,7 +380,7 @@
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(156, 21);
this.label4.Location = new System.Drawing.Point(167, 21);
this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(33, 13);
@@ -441,6 +452,17 @@
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Memoria: WRITE param";
//
// btnCharWrite
//
this.btnCharWrite.Location = new System.Drawing.Point(548, 32);
this.btnCharWrite.Margin = new System.Windows.Forms.Padding(2);
this.btnCharWrite.Name = "btnCharWrite";
this.btnCharWrite.Size = new System.Drawing.Size(79, 24);
this.btnCharWrite.TabIndex = 12;
this.btnCharWrite.Text = "W Char[]";
this.btnCharWrite.UseVisualStyleBackColor = true;
this.btnCharWrite.Click += new System.EventHandler(this.btnCharWrite_Click);
//
// btnNumWriteReal
//
this.btnNumWriteReal.Location = new System.Drawing.Point(258, 13);
@@ -577,28 +599,6 @@
this.label7.TabIndex = 7;
this.label7.Text = "ADDR 1";
//
// btnCharWrite
//
this.btnCharWrite.Location = new System.Drawing.Point(548, 32);
this.btnCharWrite.Margin = new System.Windows.Forms.Padding(2);
this.btnCharWrite.Name = "btnCharWrite";
this.btnCharWrite.Size = new System.Drawing.Size(79, 24);
this.btnCharWrite.TabIndex = 12;
this.btnCharWrite.Text = "W Char[]";
this.btnCharWrite.UseVisualStyleBackColor = true;
this.btnCharWrite.Click += new System.EventHandler(this.btnCharWrite_Click);
//
// btnReadChar
//
this.btnReadChar.Location = new System.Drawing.Point(104, 74);
this.btnReadChar.Margin = new System.Windows.Forms.Padding(2);
this.btnReadChar.Name = "btnReadChar";
this.btnReadChar.Size = new System.Drawing.Size(76, 20);
this.btnReadChar.TabIndex = 12;
this.btnReadChar.Text = "R Char[]";
this.btnReadChar.UseVisualStyleBackColor = true;
this.btnReadChar.Click += new System.EventHandler(this.btnReadChar_Click);
//
// TestMainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);