diff --git a/IOB-WIN/DATA/CONF/OSAI.ini b/IOB-WIN/DATA/CONF/OSAI.ini
index bac3b441..a54a9769 100644
--- a/IOB-WIN/DATA/CONF/OSAI.ini
+++ b/IOB-WIN/DATA/CONF/OSAI.ini
@@ -10,6 +10,7 @@ MODEL=OSAI_OPEN
; TEST OSAI su VirtSAM
IP=192.168.157.2
;PORT=8193
+;GETPRGNAME=false
[SERVER]
MPIP=SRV-MAPO
diff --git a/IOB-WIN/IobOSAI.cs b/IOB-WIN/IobOSAI.cs
index fd3c8053..50279a5c 100644
--- a/IOB-WIN/IobOSAI.cs
+++ b/IOB-WIN/IobOSAI.cs
@@ -44,25 +44,6 @@ namespace IOB_WIN
* */
-
-#if false
- ///
- /// Area memoria G (copia)
- ///
- protected byte[] MemBlockG = new byte[2];
- ///
- /// Area memoria R (copia)
- ///
- protected byte[] MemBlockR = new byte[2];
- ///
- /// Area memoria X (copia)
- ///
- protected byte[] MemBlockX = new byte[2];
- ///
- /// Area memoria Y (copia)
- ///
- protected byte[] MemBlockY = new byte[2];
-#endif
///
/// LookUpTable di decodifica da CNC a segnali tipo bitmap MAPO
///
@@ -243,29 +224,6 @@ namespace IOB_WIN
///
protected ComCNOsai OSAI_ref;
-#if false
- ///
- /// Dati dell'area D
- ///
- protected memAreaFanuc areaD;
- ///
- /// Dati dell'area PARameters
- ///
- protected memAreaFanuc areaPAR;
- ///
- /// Dati dell'area R
- ///
- protected memAreaFanuc areaR;
- ///
- /// Dati dell'area X
- ///
- protected memAreaFanuc areaX;
- ///
- /// Dati dell'area Y
- ///
- protected memAreaFanuc areaY;
-#endif
-
///
/// estende l'init della classe base...
///
@@ -283,59 +241,13 @@ namespace IOB_WIN
// inizializzo correttamente aree memoria secondo CONF - iniFileName
IniFile fIni = new IniFile(IOBConf.iniFileName);
-#if false
+
// inizializzo aree di memoria correnti...
- MemBlockG = new byte[fIni.ReadInteger("MEMORY", "AREAG_SIZE", 8)];
- MemBlockR = new byte[fIni.ReadInteger("MEMORY", "AREAR_SIZE", 8)];
- MemBlockX = new byte[fIni.ReadInteger("MEMORY", "AREAX_SIZE", 8)];
- MemBlockY = new byte[fIni.ReadInteger("MEMORY", "AREAY_SIZE", 8)];
- // loggo aree di memoria avviate...
- lgInfo(string.Format("Avviare area di memoria MemBlockG: {0} byte", MemBlockG.Length));
- lgInfo(string.Format("Avviare area di memoria MemBlockR: {0} byte", MemBlockR.Length));
- lgInfo(string.Format("Avviare area di memoria MemBlockX: {0} byte", MemBlockX.Length));
- lgInfo(string.Format("Avviare area di memoria MemBlockY: {0} byte", MemBlockY.Length));
-#endif
-
+
// fix enable prgName
enablePrgName = fIni.ReadBoolean("CNC", "GETPRGNAME", true);
-#if false
- // salvo le aree X-Y-D (per dump/sample/ottimizzazione lettura)
- areaD = new memAreaFanuc
- {
- areaName = "AreaD",
- startIdx = fIni.ReadInteger("MEMORY", "AREAD_START", 0),
- arraySize = fIni.ReadInteger("MEMORY", "AREAD_SIZE", 0)
- };
- areaPAR = new memAreaFanuc
- {
- areaName = "AreaPARR",
- startIdx = fIni.ReadInteger("MEMORY", "PAR_START", 0),
- arraySize = fIni.ReadInteger("MEMORY", "PAR_SIZE", 0)
- };
- areaR = new memAreaFanuc
- {
- areaName = "AreaR",
- startIdx = fIni.ReadInteger("MEMORY", "AREAR_START", 0),
- arraySize = fIni.ReadInteger("MEMORY", "AREAR_SIZE", 0)
- };
- areaX = new memAreaFanuc
- {
- areaName = "AreaX",
- startIdx = fIni.ReadInteger("MEMORY", "AREAX_START", 0),
- arraySize = fIni.ReadInteger("MEMORY", "AREAX_SIZE", 0)
- };
- areaY = new memAreaFanuc
- {
- areaName = "AreaY",
- startIdx = fIni.ReadInteger("MEMORY", "AREAY_START", 0),
- arraySize = fIni.ReadInteger("MEMORY", "AREAY_SIZE", 0)
- };
- lgInfo(string.Format("Salvata area di memoria: {0}, da {1} per {2} byte", areaD.areaName, areaD.startIdx, areaD.arraySize));
- lgInfo(string.Format("Salvata area di memoria: {0}, da {1} per {2} byte", areaR.areaName, areaR.startIdx, areaR.arraySize));
- lgInfo(string.Format("Salvata area di memoria: {0}, da {1} per {2} byte", areaX.areaName, areaX.startIdx, areaX.arraySize));
- lgInfo(string.Format("Salvata area di memoria: {0}, da {1} per {2} byte", areaY.areaName, areaY.startIdx, areaY.arraySize));
-#endif
+
// effettuo lettura della conf sigLUT... cercando 1:1 i bit...
string currBit = "";
@@ -355,17 +267,8 @@ namespace IOB_WIN
hasBigEndian = false;
lgInfo("Start init Adapter OSAI all'IP {0}:{1} per IOB {2}", IOBConf.cncIpAddr, IOBConf.cncPort, IOBConf.codIOB);
- // Creo oggetto connessione NC
+ // Creo oggetto x gestione connessione/comunicazione NC: secondo il tipo creo CNDEX o OPEN
parentForm.commPlcActive = true;
-
-#if false
- // in base al tipo controllo se CNDEX o OPEN...
- //Runtime.CreateNC(CNC.NcType.OSAI_OPEN, IOBConf.cncIpAddr,IOBConf.cncPort);
- Runtime.CreateNC(CNC.NcType.OSAI_CNDEX, IOBConf.cncIpAddr, IOBConf.cncPort);
-#endif
-
-
- // secondo il tipo creo CNDEX o OPEN
if (IOBConf.tipoIob == tipoAdapter.OSAI_OPEN)
{
OSAI_ref = new Open_Series(IOBConf.cncIpAddr, false);
@@ -374,17 +277,11 @@ namespace IOB_WIN
{
OSAI_ref = new ComCNOsai(IOBConf.cncIpAddr, false);
}
-
parentForm.commPlcActive = false;
-#if false
- // aggiungo referenza obj OSAI
- OSAI_ref = (OSAI)Runtime.NC;
-#endif
-
if (utils.CRB("verbose"))
{
- lgInfo("OSAI_ref da CncLib");
+ lgInfo(string.Format("INIT OSAI_ref da CncLib come {0}",IOBConf.tipoIob));
}
// disconnetto e connetto...
@@ -397,28 +294,27 @@ namespace IOB_WIN
lgInfo("OSAI: tryConnect");
tryConnect();
-#if false
- // provo a leggere la GetNcInfo
- CncLib.OPENcontrol.GETINFO1DATA outData = new CncLib.OPENcontrol.GETINFO1DATA();
- bool fatto = OSAI_ref.O_GetNcInfo1(ref outData);
-#endif
// recupero machine status e mode da cui decodificare info sul PLC...
- var machineStatus = OSAI_ref.GetMachineStatus();
- var modeSelected = OSAI_ref.GetModeSelected();
+ byte machineStatus = OSAI_ref.GetMachineStatus();
+ byte modeSelected = OSAI_ref.GetModeSelected();
+ lgInfo(string.Format("Lettura preliminare: machineStatus={0} | modeSelected={1}", machineStatus, modeSelected));
// possiamo leggere tutto da qui che contiene status, mode e last_nc_error
- Cndex.GETINFO1DATA outData = new Cndex.GETINFO1DATA();
- var ncInfo = OSAI_ref.NcInfo1(ref outData);
+ Cndex.GETINFO1DATA oData = new Cndex.GETINFO1DATA();
+ var ncInfo = OSAI_ref.NcInfo1(ref oData);
// esempio dati
- var lastNcError = outData.last_nc_error;
- var mStatus = outData.status;
- var mMode = outData.mode_select;
- var mProgramName = outData.main_progr_name;
- var speedOvr = outData.speed_ov;
- var speedPrg = outData.progr_speed;
- var speedReal = outData.real_speed;
- var modeSel = outData.mode_select;
+ var lastNcError = oData.last_nc_error;
+ var mStatus = oData.status;
+ var mMode = oData.mode_select;
+ var mProgramName = oData.main_progr_name;
+ var speedOvr = oData.speed_ov;
+ var speedPrg = oData.progr_speed;
+ var speedReal = oData.real_speed;
+ var modeSel = oData.real_feed;
+
+
+ lgInfo(string.Format("Lettura START completa NCINFO1DATA{0} lastNcError={1}{0}status={2}{0}substatus={9}{0}mode_select={3}{0}main_progr_name={4}{0}speed_ov={5}{0}progr_speed={6}{0}real_speed={7}{0}real_feed={8}{0}", Environment.NewLine, oData.last_nc_error, oData.status, oData.mode_select, oData.main_progr_name, oData.speed_ov, oData.progr_speed, oData.real_speed, oData.real_feed, oData.substatus));
// inizio il calcolo dello status semaforico
@@ -543,9 +439,6 @@ namespace IOB_WIN
string szStatusConnection = "";
try
{
-#if false
- OSAI_ref.Disconnect(ref szStatusConnection);
-#endif
OSAI_ref.CloseSession();
connectionOk = false;
// resetto timing!
@@ -591,10 +484,7 @@ namespace IOB_WIN
try
{
// ora provo connessione...
- parentForm.commPlcActive = true;
-#if false
- OSAI_ref.Connect(ref szStatusConnection);
-#endif
+ parentForm.commPlcActive = true;
OSAI_ref.OpenSession();
parentForm.commPlcActive = false;
@@ -646,6 +536,7 @@ namespace IOB_WIN
processMemoryDiscon();
}
}
+
///
/// lettura principale (bit semafori)
///
@@ -660,9 +551,18 @@ namespace IOB_WIN
}
parentForm.sIN = Semaforo.SV;
+
+ // possiamo leggere tutto da qui che contiene status, mode e last_nc_error
+ Cndex.GETINFO1DATA oData = new Cndex.GETINFO1DATA();
+ var ncInfo = OSAI_ref.NcInfo1(ref oData);
+
+ lgInfo(string.Format("Lettura completa NCINFO1DATA{0} lastNcError={1}{0}status={2}{0}substatus={9}{0}mode_select={3}{0}main_progr_name={4}{0}speed_ov={5}{0}progr_speed={6}{0}real_speed={7}{0}real_feed={8}{0}", Environment.NewLine, oData.last_nc_error, oData.status, oData.mode_select, oData.main_progr_name, oData.speed_ov, oData.progr_speed, oData.real_speed, oData.real_feed, oData.substatus));
+
+
+
+#if false
// inizio letture, SEMPRE DA ZERO (possibile ottimizzazione...)
int memIndex = 0;
-#if false
// controllo area R: se ha dati (> 0 byte) --> leggo!
if (MemBlockR.Length > 0)
{