169 lines
7.2 KiB
C#
169 lines
7.2 KiB
C#
using MTC;
|
|
using MTConnect;
|
|
using SCMA.AdapterCom;
|
|
using System;
|
|
|
|
namespace SCMA
|
|
{
|
|
public class AdapterDemo : AdapterGeneric
|
|
{
|
|
public Condition mTemp;
|
|
public Condition mFillLevel;
|
|
|
|
/// <summary>
|
|
/// estende l'init della classe base...
|
|
/// </summary>
|
|
/// <param name="caller">FORM chaimante</param>
|
|
/// <param name="adpConf">CONFIGURAZIONE adapter</param>
|
|
/// <param name="gatewayObj">OGGETTO gestione comunicazione OUT (tipologia e metodi)</param>
|
|
public AdapterDemo(MainForm caller, AdapterConf adpConf, Gateway gatewayObj) : base(caller, adpConf, gatewayObj)
|
|
{
|
|
if (utils.CRB("verbose"))
|
|
{
|
|
lg.Info("Start init Adapter DEMO");
|
|
}
|
|
// IMPLICITO: carica da metodo base tutte le specifiche del conf...
|
|
|
|
mTemp = new Condition("temp");
|
|
mFillLevel = new Condition("cool_low", true);
|
|
// aggiungo specifiche del demo: allarmi gestiti a buttons!!!
|
|
currGateway.addItemNode("temp", mTemp);
|
|
currGateway.addItemNode("cool_low", mFillLevel);
|
|
}
|
|
|
|
public override void startAdapter()
|
|
{
|
|
base.startAdapter();
|
|
// aggiungo altre condizioni specifiche...
|
|
mTemp.Normal();
|
|
mFillLevel.Normal();
|
|
}
|
|
|
|
public override void getSlowChangingData()
|
|
{
|
|
// recupero SEMPRE dati ulteriori: status ON/OFF, clock, ...
|
|
currGateway.updateItemNodeValue("STATUS", parentForm.datiProd.Status);
|
|
currGateway.updateItemNodeValue("ACC_TIME", parentForm.datiProd.AccTime);
|
|
currGateway.updateItemNodeValue("OperatorId", parentForm.datiProd.Operator);
|
|
currGateway.updateItemNodeValue("POWER", parentForm.datiProd.Power);
|
|
currGateway.updateItemNodeValue("CLOCK", DateTime.Now.Date.ToFileTimeUtc());
|
|
}
|
|
|
|
public override void getStrobeAndAckStatus()
|
|
{
|
|
base.getStrobeAndAckStatus();
|
|
|
|
// controllo bool allarmi...
|
|
if (parentForm.datiProd.EmrStop)
|
|
{
|
|
currGateway.updateItemNodeValue("E_STOP", emStatus.TRIGGERED.ToString());
|
|
}
|
|
else
|
|
{
|
|
currGateway.updateItemNodeValue("E_STOP", emStatus.ARMED.ToString());
|
|
}
|
|
|
|
// imposto func mode...
|
|
currGateway.updateItemNodeValue("FUNCT_MODE", parentForm.datiProd.FuncMode);
|
|
|
|
// se ho un messaggio...
|
|
if (parentForm.datiProd.MessageText.Length > 0)
|
|
{
|
|
currGateway.updateItemNodeCodeValue("MESSAGE", parentForm.datiProd.MessageCode, parentForm.datiProd.MessageText);
|
|
}
|
|
}
|
|
|
|
public override void getConfigParam()
|
|
{
|
|
base.getConfigParam();
|
|
}
|
|
|
|
|
|
public override void processStrobe()
|
|
{
|
|
// qui forzo la gestione di update dei path & co...
|
|
getPath();
|
|
getUnOp();
|
|
getAxis();
|
|
}
|
|
/// <summary>
|
|
/// non fa nulla perché recupera allarmi in vettore al singolo cambio...
|
|
/// </summary>
|
|
/// <param name="Alarm2Refresh"></param>
|
|
/// <param name="giveAck"></param>
|
|
public override void refreshAlarmState(StFlag32 Alarm2Refresh, bool giveAck)
|
|
{
|
|
base.refreshAlarmState(Alarm2Refresh, giveAck);
|
|
}
|
|
|
|
public override void getPath()
|
|
{
|
|
base.getPath();
|
|
|
|
PathData PtData = parentForm.CurrPath;
|
|
if (PtData.PathSel >= 0)
|
|
{
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].feedKey, PtData.PathFeedrate);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].feedOverKey, PtData.PathFeedrateOver);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].rapidOverKey, PtData.PathRapidOver);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].posAct_X_Key, PtData.PathPosAct.x);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].posAct_Y_Key, PtData.PathPosAct.y);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].posAct_Z_Key, PtData.PathPosAct.z);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].posAct_I_Key, PtData.PathPosAct.i);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].posAct_J_Key, PtData.PathPosAct.j);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].posAct_K_Key, PtData.PathPosAct.k);
|
|
// aggiunta x revisione 2016.05.05
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].pathTypeKey, PtData.PathType);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].partIdKey, PtData.PartId);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].partCountKey, PtData.pzTot);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].runModeKey, PtData.RunMode);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].exeModeKey, PtData.ExeMode);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].currProgKey, PtData.ProgramName);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].currProgRowNumKey, PtData.ProgrRow);
|
|
currGateway.updateItemNodeValue(vettPath[PtData.PathSel].activeAxesKey, PtData.ActiveAxes);
|
|
}
|
|
}
|
|
|
|
public override void getUnOp()
|
|
{
|
|
base.getUnOp();
|
|
|
|
UnOpData uoData = parentForm.CurrUnOp;
|
|
if (uoData.UnOpSel >= 0)
|
|
{
|
|
currGateway.updateItemNodeValue(vettUnOp[uoData.UnOpSel].toolIdKey, uoData.UnOpToolId);
|
|
currGateway.updateItemNodeValue(vettUnOp[uoData.UnOpSel].numCUKey, uoData.UnOpNumCU);
|
|
currGateway.updateItemNodeValue(vettUnOp[uoData.UnOpSel].statusKey, uoData.UnOpStatus);
|
|
currGateway.updateItemNodeValue(vettUnOp[uoData.UnOpSel].vitaResKey, uoData.UnOpVitaRes);
|
|
currGateway.updateItemNodeValue(vettUnOp[uoData.UnOpSel].speedKey, uoData.UnOpSpeed);
|
|
currGateway.updateItemNodeValue(vettUnOp[uoData.UnOpSel].loadKey, uoData.UnOpLoad);
|
|
currGateway.updateItemNodeValue(vettUnOp[uoData.UnOpSel].accTimeKey, uoData.UnOpAccTime);
|
|
}
|
|
}
|
|
|
|
public override void getAxis()
|
|
{
|
|
base.getAxis();
|
|
AxisData AxData = parentForm.CurrAxis;
|
|
if (AxData.AxisSel >= 0)
|
|
{
|
|
// USO asse selezionato + dati visualizzati e di conseguenza aggiorno...
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisMainProc);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisIsMaster);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisMastId);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisType);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisDir);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisLoad);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisPosAct);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisPosTgt);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisFeedAct);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisFeedOver);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisAccel);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisAccTime);
|
|
currGateway.updateItemNodeValue(vettAxis[AxData.AxisSel].mainProcKey, AxData.AxisBattery);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|