aggiunta modifiche x check OSAI OPEN in FPlast

This commit is contained in:
Samuele E. Locatelli
2018-11-22 18:31:40 +01:00
parent 82ecf5bd37
commit 4b13d04c3d
2 changed files with 34 additions and 133 deletions
+1
View File
@@ -10,6 +10,7 @@ MODEL=OSAI_OPEN
; TEST OSAI su VirtSAM
IP=192.168.157.2
;PORT=8193
;GETPRGNAME=false
[SERVER]
MPIP=SRV-MAPO
+33 -133
View File
@@ -44,25 +44,6 @@ namespace IOB_WIN
* */
#if false
/// <summary>
/// Area memoria G (copia)
/// </summary>
protected byte[] MemBlockG = new byte[2];
/// <summary>
/// Area memoria R (copia)
/// </summary>
protected byte[] MemBlockR = new byte[2];
/// <summary>
/// Area memoria X (copia)
/// </summary>
protected byte[] MemBlockX = new byte[2];
/// <summary>
/// Area memoria Y (copia)
/// </summary>
protected byte[] MemBlockY = new byte[2];
#endif
/// <summary>
/// LookUpTable di decodifica da CNC a segnali tipo bitmap MAPO
/// </summary>
@@ -243,29 +224,6 @@ namespace IOB_WIN
/// </summary>
protected ComCNOsai OSAI_ref;
#if false
/// <summary>
/// Dati dell'area D
/// </summary>
protected memAreaFanuc areaD;
/// <summary>
/// Dati dell'area PARameters
/// </summary>
protected memAreaFanuc areaPAR;
/// <summary>
/// Dati dell'area R
/// </summary>
protected memAreaFanuc areaR;
/// <summary>
/// Dati dell'area X
/// </summary>
protected memAreaFanuc areaX;
/// <summary>
/// Dati dell'area Y
/// </summary>
protected memAreaFanuc areaY;
#endif
/// <summary>
/// estende l'init della classe base...
/// </summary>
@@ -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();
}
}
/// <summary>
/// lettura principale (bit semafori)
/// </summary>
@@ -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)
{