diff --git a/MTC_Adapter/MTC_Adapter/AdapterESA.cs b/MTC_Adapter/MTC_Adapter/AdapterESA.cs
index 7c7e7bf..703d969 100644
--- a/MTC_Adapter/MTC_Adapter/AdapterESA.cs
+++ b/MTC_Adapter/MTC_Adapter/AdapterESA.cs
@@ -31,6 +31,10 @@ namespace MTC_Adapter
/// Configurazione valori da leggere IOT_String
///
public otherData[] mapIOT_String;
+ ///
+ /// variabile globale x usare IOT MEMORI (!!! da eliminare alla fine dei test)
+ ///
+ protected bool useIotMem = true;
///
/// Carico file conf dati IOT
@@ -88,8 +92,8 @@ namespace MTC_Adapter
/// dimensione (in byte) della memoria
protected void loadConfFile(ref otherData[] vettoreConf, string nomeFile, int memSize)
{
- // carico dati x Maintenance
- if (utils.CRB("verbose")) lg.Info("Inizio caricamento vettore mappa " + nomeFile);
+ //// carico dati x Maintenance
+ //if (utils.CRB("verbose")) lg.Info("Inizio caricamento vettore mappa " + nomeFile);
int totRighe = 0;
string linea;
totRighe = File.ReadLines(nomeFile).Count();
@@ -141,7 +145,9 @@ namespace MTC_Adapter
if (utils.CRB("verbose")) lg.Info("step 01: impostato INI File {0}", iniPath);
- ncDevice = new thdNcEsaGvKvara(EsaIni);
+ loadOtherFile();
+
+ ncDevice = new thdNcEsaGvKvara(EsaIni, mapIOT_Byte.Length, mapIOT_Word.Length, mapIOT_DWord.Length, mapIOT_String.Length);
if (utils.CRB("verbose")) lg.Info("step 02: avviato thdNcEsaGvKvara da INI File {0}", iniPath);
@@ -211,7 +217,7 @@ namespace MTC_Adapter
// accodo dati path in DataMonitor......
StringBuilder sb = new StringBuilder();
- //2017.03 RIVEDERE DA QUI x lettura globale
+ //2017.03.07 RIVEDERE DA QUI x lettura globale
if (connectionOk)
{
@@ -277,7 +283,7 @@ namespace MTC_Adapter
needSave = procNumCU(needSave);
// per ESA calcolo a mano se ci sia stato impiego assi... salvo le istantanee mov precedenti...
- double precVal=0;
+ double precVal = 0;
DateTime adesso = DateTime.Now;
TimeSpan accumTime = adesso.Subtract(lastChekAccumTimeAxis);
@@ -473,86 +479,177 @@ namespace MTC_Adapter
// HARD CODE: forzo path 1 (indice 0...)
int idxPath = 0;
- // verifica macchina accesa...
- Byte V73 = ncDevice.PLC_MemoryAreaV[5];
- if (((StFlag8)V73).HasFlag(StFlag8.B2))
+ // 2017.03.07 IN BLOCCO processo TUTTI i valori della memoria BYTE...
+ if (useIotMem)
{
- mPower.Value = "ON";
+
+ ncDevice.ReadBufferByte();
+ // accodo dati path in DataMonitor......
+ StringBuilder sb = new StringBuilder();
+ // uno ad uno vado a inserirli nella mappa dei dati dell'adapter...
+ for (int i = 0; i < mapIOT_Byte.Length; i++)
+ {
+ if (mapIOT_Byte[i].varName == "IOT_EXEC")
+ {
+ //mProtectionStatus.Value = status;
+ // 2017.03.07 VERIFICARE!!!: per ora ON = NO EMERGENZA...
+ if (ncDevice.PLC_MemoryAreaIOT_Byte[i] == 0)
+ {
+ mPower.Value = "ON";
+ }
+ else
+ {
+ mPower.Value = "OFF";
+ }
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_HOLD")
+ {
+ if (ncDevice.PLC_MemoryAreaIOT_Byte[i] != 0)
+ {
+ vettPath[idxPath].mPathExeMode.Value = "FEED_HOLD"; //"FEEDHOLD";
+ }
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_EMG")
+ {
+ // 2017.03.07 controllo bit emergenza...
+ if (ncDevice.PLC_MemoryAreaIOT_Byte[i] != 0)
+ {
+ mEStop.Value = "TRIGGERED";
+ }
+ else
+ {
+ mEStop.Value = "ARMED";
+ }
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_ALRM")
+ {
+ if (ncDevice.PLC_MemoryAreaIOT_Byte[i] != 0)
+ {
+ // carico IN BLOCCO memoria allarmi...
+ // FARE!!!
+ }
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_OVRF")
+ {
+ // -------------------------------------------
+ // recupero dati FeedOverride
+ // FeedOver: 100% = 213 (il pannello è 0-120 --> 0-255, quindi 100% è 100/120*255=213)
+ FeedRateOver = Convert.ToInt16((decimal)(ncDevice.PLC_MemoryAreaIOT_Byte[i] * 100) / 213);
+ sb.AppendLine(string.Format("FeedRateOver: {0} %", FeedRateOver));
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_OVRS")
+ {
+ // -------------------------------------------
+ // recupero dati SpeedOverride
+ // SpeedOver: 50% = 128
+ SpeedRateOver = Convert.ToInt16((decimal)(ncDevice.PLC_MemoryAreaIOT_Byte[i] * 100) / 255);
+ sb.AppendLine(string.Format("SpeedRateOver: {0} %", SpeedRateOver));
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_LUB_EMPTY")
+ {
+ if (ncDevice.PLC_MemoryAreaIOT_Byte[i] != 0)
+ {
+ // CREARE allarme serbatoio vuoto... !!!FARE
+ }
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_C_LUB")
+ {
+ if (ncDevice.PLC_MemoryAreaIOT_Byte[i] != 0)
+ {
+ vettLubro[0].mLubroNum.Value = ncDevice.PLC_MemoryAreaIOT_Byte[i];
+ }
+ }
+ else
+ {
+
+ }
+ }
}
else
{
- mPower.Value = "OFF";
- }
+ // verifica macchina accesa...
+ Byte V73 = ncDevice.PLC_MemoryAreaV[5];
- // switch su EXE mode...
- /*
- * MODO_X V[70/71] --> byte (2-3)
- * V70.2 = Modo RUN
- * V70.3 = Modo FeedHold
- * V71.5 = Ready
- * */
- Byte V70 = ncDevice.PLC_MemoryAreaV[2];
- Byte V71 = ncDevice.PLC_MemoryAreaV[3];
- if (((StFlag8)V70).HasFlag(StFlag8.B3))
- {
- vettPath[idxPath].mPathExeMode.Value = "FEED_HOLD"; //"FEEDHOLD";
- }
- else if (((StFlag8)V70).HasFlag(StFlag8.B2))
- {
- vettPath[idxPath].mPathExeMode.Value = "ACTIVE";
- }
- else if (((StFlag8)V71).HasFlag(StFlag8.B5))
- {
- vettPath[idxPath].mPathExeMode.Value = "READY";
- }
- //// appunto: modi da creare
- //STOPPED/HOLD(da creare)
- //INTERRUPTED(da creare)
- //OPTIONAL_STOP(da creare)
- //PROGRAM_STOPPED(da creare)
- //PROGRAM_COMPLETED(da creare)
+ if (((StFlag8)V73).HasFlag(StFlag8.B2))
+ {
+ mPower.Value = "ON";
+ }
+ else
+ {
+ mPower.Value = "OFF";
+ }
+
+ // switch su EXE mode...
+ /*
+ * MODO_X V[70/71] --> byte (2-3)
+ * V70.2 = Modo RUN
+ * V70.3 = Modo FeedHold
+ * V71.5 = Ready
+ * */
+ Byte V70 = ncDevice.PLC_MemoryAreaV[2];
+ Byte V71 = ncDevice.PLC_MemoryAreaV[3];
+
+ if (((StFlag8)V70).HasFlag(StFlag8.B3))
+ {
+ vettPath[idxPath].mPathExeMode.Value = "FEED_HOLD"; //"FEEDHOLD";
+ }
+ else if (((StFlag8)V70).HasFlag(StFlag8.B2))
+ {
+ vettPath[idxPath].mPathExeMode.Value = "ACTIVE";
+ }
+ else if (((StFlag8)V71).HasFlag(StFlag8.B5))
+ {
+ vettPath[idxPath].mPathExeMode.Value = "READY";
+ }
+ //// appunto: modi da creare
+ //STOPPED/HOLD(da creare)
+ //INTERRUPTED(da creare)
+ //OPTIONAL_STOP(da creare)
+ //PROGRAM_STOPPED(da creare)
+ //PROGRAM_COMPLETED(da creare)
- // switch su run mode...
- /*
- * MODO_X V[74].W --> byte (6)
- * 0 = Modo NESSUNO
- * 1 = Modo MANUALE
- * 2 = Modo AUTOMATICO
- * 3 = Modo POM
- * 4 = Modo MDI
- * 5 = Modo SEMIAUTOMATICO
- * 6 = Modo RAP
- * 7 = Modo TES
- * */
- uint V74 = ncDevice.PLC_MemoryAreaV[6];
- switch (V74)
- {
- case 1:
- vettPath[idxPath].mPathRunMode.Value = "EDIT";
- break;
- case 2:
- vettPath[idxPath].mPathRunMode.Value = "AUTOMATIC";
- break;
- case 3:
- vettPath[idxPath].mPathRunMode.Value = "MANUAL";
- break;
- case 4:
- vettPath[idxPath].mPathRunMode.Value = "MANUAL_DATA_INPUT";
- break;
- case 5:
- vettPath[idxPath].mPathRunMode.Value = "SEMI_AUTOMATIC"; //"SEMIAUTO";
- break;
- case 6:
- vettPath[idxPath].mPathRunMode.Value = "MANUAL"; //"RAP";
- break;
- case 7:
- vettPath[idxPath].mPathRunMode.Value = "MANUAL"; //"TES";
- break;
- case 0:
- default:
- vettPath[idxPath].mPathRunMode.Value = "NA";
- break;
+ // switch su run mode...
+ /*
+ * MODO_X V[74].W --> byte (6)
+ * 0 = Modo NESSUNO
+ * 1 = Modo MANUALE
+ * 2 = Modo AUTOMATICO
+ * 3 = Modo POM
+ * 4 = Modo MDI
+ * 5 = Modo SEMIAUTOMATICO
+ * 6 = Modo RAP
+ * 7 = Modo TES
+ * */
+ uint V74 = ncDevice.PLC_MemoryAreaV[6];
+ switch (V74)
+ {
+ case 1:
+ vettPath[idxPath].mPathRunMode.Value = "EDIT";
+ break;
+ case 2:
+ vettPath[idxPath].mPathRunMode.Value = "AUTOMATIC";
+ break;
+ case 3:
+ vettPath[idxPath].mPathRunMode.Value = "MANUAL";
+ break;
+ case 4:
+ vettPath[idxPath].mPathRunMode.Value = "MANUAL_DATA_INPUT";
+ break;
+ case 5:
+ vettPath[idxPath].mPathRunMode.Value = "SEMI_AUTOMATIC"; //"SEMIAUTO";
+ break;
+ case 6:
+ vettPath[idxPath].mPathRunMode.Value = "MANUAL"; //"RAP";
+ break;
+ case 7:
+ vettPath[idxPath].mPathRunMode.Value = "MANUAL"; //"TES";
+ break;
+ case 0:
+ default:
+ vettPath[idxPath].mPathRunMode.Value = "NA";
+ break;
+ }
}
}
@@ -682,26 +779,28 @@ namespace MTC_Adapter
public override void processAlarm()
{
base.processAlarm();
-
- // ora controllo "allarmi speciali" se si sono...
- if (AlarmFlags != null)
+ if (!useIotMem)
{
- // variabili helper
- StFlag32 AlarmBlock = 0;
- int eStopCode = utils.CRI("eStopCode") - 1; // è base zero memoria, ma allarmi base 1...
+ // ora controllo "allarmi speciali" se si sono...
+ if (AlarmFlags != null)
+ {
+ // variabili helper
+ StFlag32 AlarmBlock = 0;
+ int eStopCode = utils.CRI("eStopCode") - 1; // è base zero memoria, ma allarmi base 1...
- int memStart = (int)Math.Floor((double)eStopCode / 8);
- // leggo 32bit alla volta...
- AlarmBlock = (StFlag32)BitConverter.ToUInt32(AlarmFlags, memStart);
- int eStopIndex = eStopCode - memStart * 8;
- // converto! e aggiungo allarmi sollevati al corretto controller allarmi...
- if (AlarmBlock.HasFlag((StFlag32)Math.Pow(2, eStopIndex)))
- {
- mEStop.Value = "TRIGGERED";
- }
- else
- {
- mEStop.Value = "ARMED";
+ int memStart = (int)Math.Floor((double)eStopCode / 8);
+ // leggo 32bit alla volta...
+ AlarmBlock = (StFlag32)BitConverter.ToUInt32(AlarmFlags, memStart);
+ int eStopIndex = eStopCode - memStart * 8;
+ // converto! e aggiungo allarmi sollevati al corretto controller allarmi...
+ if (AlarmBlock.HasFlag((StFlag32)Math.Pow(2, eStopIndex)))
+ {
+ mEStop.Value = "TRIGGERED";
+ }
+ else
+ {
+ mEStop.Value = "ARMED";
+ }
}
}
}
diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs
index efc772c..ad74bc1 100644
--- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs
+++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs
@@ -1311,7 +1311,7 @@ namespace MTC_Adapter
{
contDistMovAssi[i] = getStoredValUInt(string.Format("Axis_{0:00}_DistDone", i + 1));
contNumInvAssi[i] = getStoredValUInt(string.Format("Axis_{0:00}_InvDDone", i + 1));
- contAccTimeAssi[i] = getStoredValUInt(string.Format("Axis_{0:00}_AccTime", i + 1));
+ contAccTimeAssi[i] = getStoredValDouble(string.Format("Axis_{0:00}_AccTime", i + 1));
}
for (int i = 0; i < currAdpConf.nVacuumPump; i++)
diff --git a/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara.ini b/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara.ini
index 78bda4a..5925cde 100644
--- a/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara.ini
+++ b/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara.ini
@@ -79,6 +79,15 @@ SysDefCn=C:\KVARA\DISCOI
; modo sincronizzato con il plc
;PlcSyncAddress=2103
+;CONFIGURAZIONE DELLE AREE DI MEMORIA IOT (dimensioni vari array...)
+IOT_AreaAddressByte=IOT.BYTE
+IOT_AreaAddressWord=IOT.WORD
+IOT_AreaAddressDWord=IOT.DWORD
+IOT_AreaAddressString=IOT.STRING
+;IOT_ByteAreaByteSize=20
+;IOT_WordAreaByteSize=38
+;IOT_DWordAreaByteSize=70
+;IOT_StringAreaByteSize=4
[XILOG]
Enable=1
diff --git a/MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs b/MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs
index 5e9a36b..f546074 100644
--- a/MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs
+++ b/MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs
@@ -38,10 +38,10 @@ namespace SCMCncLib
private UInt16 ETKAreaByteSize;
private UInt16 AlarmByteSize;
- private UInt16 IOTByteAreaByteSize;
- private UInt16 IOTWordAreaByteSize;
- private UInt16 IOTDWordAreaByteSize;
- private UInt16 IOTStringAreaByteSize;
+ private UInt16 IOT_ByteAreaByteSize;
+ private UInt16 IOT_WordAreaByteSize;
+ private UInt16 IOT_DWordAreaByteSize;
+ private UInt16 IOT_StringAreaByteSize;
private string SysLink = "";
@@ -61,7 +61,7 @@ namespace SCMCncLib
private string EOKAreaAddressName;
private TS_REG EOKAreaAddress;
-
+
private string ETKAreaAddressName;
private TS_REG ETKAreaAddress;
@@ -69,17 +69,17 @@ namespace SCMCncLib
private TS_REG PlcErrAreaAddress;
- private string IOTByteAreaAddressName;
- private TS_REG IOTByteAreaAddress;
+ private string IOT_ByteAreaAddressName;
+ private TS_REG IOT_ByteAreaAddress;
- private string IOTWordAreaAddressName;
- private TS_REG IOTWordAreaAddress;
+ private string IOT_WordAreaAddressName;
+ private TS_REG IOT_WordAreaAddress;
- private string IOTDWordAreaAddressName;
- private TS_REG IOTDWordAreaAddress;
+ private string IOT_DWordAreaAddressName;
+ private TS_REG IOT_DWordAreaAddress;
- private string IOTStringAreaAddressName;
- private TS_REG IOTStringAreaAddress;
+ private string IOT_StringAreaAddressName;
+ private TS_REG IOT_StringAreaAddress;
///
/// Memorie a 4 byte (32 bit)
@@ -111,23 +111,35 @@ namespace SCMCncLib
/// memorie a 1 byte (8 bit) x area Allarmi (V[300] - 256 bit)
///
public Byte[] PLC_MemoryAreaAllarmi;
-
+
+ #region memorie IOT NUOVE
+
+ ///
+ /// Area IOT_Byte: memoria temp di UINT di 4 byte (32 bit)
+ ///
+ public UInt32[] PLC_MemoryAreaIOT_Byte_tmp;
+ ///
+ /// Area IOT_Word: memoria temp di UINT di 4 byte (32 bit)
+ ///
+ public UInt32[] PLC_MemoryAreaIOT_Word_tmp;
///
/// memorie a 1 byte (8 bit) x area IOT.Byte
///
- public UInt32[] PLC_MemoryAreaIOTByte;
+ public Byte[] PLC_MemoryAreaIOT_Byte;
///
/// memorie a 2 byte (16 bit) x area IOT.Word
///
- public uint[] PLC_MemoryAreaIOTWord;
+ public UInt16[] PLC_MemoryAreaIOT_Word;
///
/// memorie a 4 byte (32 bit) x area IOT.DWord
///
- public UInt32[] PLC_MemoryAreaIOTDWord;
+ public UInt32[] PLC_MemoryAreaIOT_DWord;
///
/// memorie stringa x area IOT.String
///
- public UInt32[] PLC_MemoryAreaIOTString;
+ public string[] PLC_MemoryAreaIOT_String;
+
+ #endregion
// esa constants
#region ESA_PLC_CONSTANTS
@@ -149,7 +161,7 @@ namespace SCMCncLib
[DllImport("KvCom3x", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "_read_regbuffer@16")]
private static extern int read_regbuffer(ref TS_REG pReg, UInt16 Offset, UInt16 Count, [MarshalAs(UnmanagedType.LPArray)] UInt32[] pDst);
-
+
[DllImport("KvCom3x", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "_write_regbuffer@16")]
private static extern int write_regbuffer(ref TS_REG pReg, UInt16 Offset, UInt16 Count, [MarshalAs(UnmanagedType.LPArray)] UInt32[] pSrc);
@@ -183,7 +195,7 @@ namespace SCMCncLib
/// Initializes a new instance of the class.
///
/// The f ini.
- public thdNcEsaGvKvara(IniFile fIni) : base(fIni)
+ public thdNcEsaGvKvara(IniFile fIni, int IAS_Byte, int IAS_Word, int IAS_DWord, int IAS_String) : base(fIni)
{
DeviceType = NC_DEVICE_TYPE.ESAGV_KVARA;
@@ -206,15 +218,18 @@ namespace SCMCncLib
DefCn = tempS.ToString() + "\\defcn";
//StrCat(DefCn, "\\defcn");
-
ReadNumber = 265;
WriteNumber = 265;
VAreaByteSize = 32;
- ETKAreaByteSize = 8;
+ ETKAreaByteSize = 8;
EOKAreaByteSize = 32; // era 14aggiunto sino a 31 x avere 91...
AlarmByteSize = 32;
- // nuove aree: definisco al SIZE in base ai files di configurazione letti...
+ // nuove aree: da init mi passa le dimensioni delle memorie
+ IOT_ByteAreaByteSize = Convert.ToUInt16(IAS_Byte);
+ IOT_WordAreaByteSize = Convert.ToUInt16(IAS_Word);
+ IOT_DWordAreaByteSize = Convert.ToUInt16(IAS_DWord);
+ IOT_StringAreaByteSize = Convert.ToUInt16(IAS_String);
CommandsAddressName = fIni.ReadString("NC", "CommandsAddress", "SIMREAD[0]");
@@ -224,6 +239,12 @@ namespace SCMCncLib
StatusAddressName = fIni.ReadString("NC", "StatusAddress", "SIMWRITE[0]");
VAreaAddressName = fIni.ReadString("NC", "VAreaAddress", "V");
+ // indirizzo area IOT...
+ IOT_ByteAreaAddressName = fIni.ReadString("NC", "IOT_AreaAddressByte", "IOT.BYTE");
+ IOT_WordAreaAddressName = fIni.ReadString("NC", "IOT_AreaAddressWord", "IOT.WORD");
+ IOT_DWordAreaAddressName = fIni.ReadString("NC", "IOT_AreaAddressDWord", "IOT.DWORD");
+ IOT_StringAreaAddressName = fIni.ReadString("NC", "IOT_AreaAddressString", "IOT");
+
/**************************************************
* Creazione buffers letture memoria
**************************************************/
@@ -246,6 +267,14 @@ namespace SCMCncLib
PLC_MemoryAreaEOK = new uint[EOKAreaByteSize];
PLC_MemoryAreaETK = new UInt32[ETKAreaByteSize];
+ // creo array x aree memoria IOT...
+ PLC_MemoryAreaIOT_Byte_tmp = new UInt32[(int)Math.Ceiling((decimal)IOT_ByteAreaByteSize / 4)];
+ PLC_MemoryAreaIOT_Word_tmp = new UInt32[(int)Math.Ceiling((decimal)IOT_WordAreaByteSize / 2)];
+ PLC_MemoryAreaIOT_Byte = new Byte[IOT_ByteAreaByteSize];
+ PLC_MemoryAreaIOT_Word = new UInt16[IOT_WordAreaByteSize];
+ PLC_MemoryAreaIOT_DWord = new UInt32[IOT_DWordAreaByteSize];
+ PLC_MemoryAreaIOT_String = new string[IOT_StringAreaByteSize];
+
if (!Connect())
Disconnect();
}
@@ -279,13 +308,64 @@ namespace SCMCncLib
Finished = true;
}
+
+ ///
+ /// Leggo il buffer di memorie BYTE
+ ///
+ public void ReadBufferByte()
+ {
+ // 2017.02: modifiche x nuova versione PLC: leggo intero buffer BYTE
+ iError = read_regbuffer(ref IOT_ByteAreaAddress, 0, IOT_ByteAreaByteSize, PLC_MemoryAreaIOT_Byte_tmp);
+ // ...e copio in array a byte...
+ try
+ {
+ Buffer.BlockCopy(PLC_MemoryAreaIOT_Byte_tmp, 0, PLC_MemoryAreaIOT_Byte, 0, IOT_ByteAreaByteSize);
+ }
+ catch
+ { }
+ }
+ ///
+ /// Leggo il buffer di memorie WORD
+ ///
+ public void ReadBufferWord()
+ {
+ // 2017.02: modifiche x nuova versione PLC: leggo intero buffer WORD
+ iError = read_regbuffer(ref IOT_WordAreaAddress, 0, IOT_WordAreaByteSize, PLC_MemoryAreaIOT_Word_tmp);
+ try
+ {
+ Buffer.BlockCopy(PLC_MemoryAreaIOT_Word_tmp, 0, PLC_MemoryAreaIOT_Word, 0, IOT_WordAreaByteSize);
+ }
+ catch
+ { }
+ }
+ ///
+ /// Leggo il buffer di memorie DWORD
+ ///
+ public void ReadBufferDWord()
+ {
+ // leggo intero buffer DWORD
+ iError = read_regbuffer(ref IOT_DWordAreaAddress, 0, IOT_DWordAreaByteSize, PLC_MemoryAreaIOT_DWord);
+ }
+ ///
+ /// Leggo il buffer di memorie STRING
+ ///
+ public void ReadBufferString()
+ {
+#if false
+ // leggo intero buffer STRING
+ iError = read_regbuffer(ref IOT_StringAreaAddress, 0, IOT_StringAreaByteSize, PLC_MemoryAreaIOT_String);
+#endif
+ }
+
+
+
///
/// Reads the buffer.
///
public void ReadBuffer()
{
// leggo da posizione memorie V/allarmi come TS_REG
- iError = read_regbuffer(ref PlcErrAreaAddress, 300, AlarmByteSize, PLC_MemAreaAlarm_tmp);
+ iError = read_regbuffer(ref PlcErrAreaAddress, 300, AlarmByteSize, PLC_MemAreaAlarm_tmp);
// lettura buffer dal CN
iError = read_regbuffer(ref StatusAddress, 0, ReadNumber, PLC_MemoryRead);
@@ -296,23 +376,6 @@ namespace SCMCncLib
// leggo da posizione memorie EOK TS_REG
iError = read_regbuffer(ref EOKAreaAddress, 60, EOKAreaByteSize, PLC_MemoryAreaEOK);
- // 2017.02: modifiche x nuova versione PLC
- // leggo intero buffer BYTE
- iError = read_regbuffer(ref IOTByteAreaAddress, 0, IOTByteAreaByteSize, PLC_MemoryAreaIOTByte);
-
- // leggo intero buffer WORD
- iError = read_regbuffer(ref IOTWordAreaAddress, 0, IOTWordAreaByteSize, PLC_MemoryAreaIOTWord);
-
- // leggo intero buffer DWORD
- iError = read_regbuffer(ref IOTDWordAreaAddress, 0, IOTDWordAreaByteSize, PLC_MemoryAreaIOTDWord);
-
- // leggo intero buffer STRING
- iError = read_regbuffer(ref IOTStringAreaAddress, 0, IOTStringAreaByteSize, PLC_MemoryAreaIOTString);
-
-
-
-
-
// copio in array a byte...
try
{
@@ -328,7 +391,7 @@ namespace SCMCncLib
catch
{ }
}
-
+
///
/// Connects to device.
///
@@ -350,6 +413,16 @@ namespace SCMCncLib
if (iError == 0)
iError = get_reg_by_name(VAreaAddressName, ref VAreaAddress);
+
+ if (iError == 0)
+ iError = get_reg_by_name(IOT_ByteAreaAddressName, ref IOT_ByteAreaAddress);
+ if (iError == 0)
+ iError = get_reg_by_name(IOT_WordAreaAddressName, ref IOT_WordAreaAddress);
+ if (iError == 0)
+ iError = get_reg_by_name(IOT_DWordAreaAddressName, ref IOT_DWordAreaAddress);
+ if (iError == 0)
+ iError = get_reg_by_name(IOT_StringAreaAddressName, ref IOT_StringAreaAddress);
+
Connected = (iError == 0);
return Connected;
}