Files
CMS-MTConn/MTC_Adapter/SCMA/AdapterDemo.cs
T
2018-08-24 12:00:47 +02:00

169 lines
6.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.updateItemNodeValue("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)
{
vettPath[PtData.PathSel].mPathFeed.Value = PtData.PathFeedrate;
vettPath[PtData.PathSel].mPathFeedOver.Value = PtData.PathFeedrateOver;
vettPath[PtData.PathSel].mPathRapidOver.Value = PtData.PathRapidOver;
vettPath[PtData.PathSel].mPathPosActX.Value = PtData.PathPosAct.x;
vettPath[PtData.PathSel].mPathPosActY.Value = PtData.PathPosAct.y;
vettPath[PtData.PathSel].mPathPosActZ.Value = PtData.PathPosAct.z;
vettPath[PtData.PathSel].mPathPosActI.Value = PtData.PathPosAct.i;
vettPath[PtData.PathSel].mPathPosActJ.Value = PtData.PathPosAct.j;
vettPath[PtData.PathSel].mPathPosActK.Value = PtData.PathPosAct.k;
// aggiunta x revisione 2016.05.05
vettPath[PtData.PathSel].mPathType.Value = PtData.PathType;
vettPath[PtData.PathSel].mPathPartId.Value = PtData.PartId;
vettPath[PtData.PathSel].mPathPartCount.Value = PtData.pzTot;
vettPath[PtData.PathSel].mPathRunMode.Value = PtData.RunMode;
vettPath[PtData.PathSel].mPathExeMode.Value = PtData.ExeMode;
vettPath[PtData.PathSel].mPathCurrProg.Value = PtData.ProgramName;
vettPath[PtData.PathSel].mPathCurrProgRowNum.Value = PtData.ProgrRow;
vettPath[PtData.PathSel].mPathActiveAxes.Value = PtData.ActiveAxes;
}
}
public override void getUnOp()
{
base.getUnOp();
UnOpData uoData = parentForm.CurrUnOp;
if (uoData.UnOpSel >= 0)
{
vettUnOp[uoData.UnOpSel].mUnOpToolId.Value = uoData.UnOpToolId;
vettUnOp[uoData.UnOpSel].mUnOpNumCU.Value = uoData.UnOpNumCU;
vettUnOp[uoData.UnOpSel].mUnOpStatus.Value = uoData.UnOpStatus;
vettUnOp[uoData.UnOpSel].mUnOpVitaRes.Value = uoData.UnOpVitaRes;
vettUnOp[uoData.UnOpSel].mUnOpSpeed.Value = uoData.UnOpSpeed;
vettUnOp[uoData.UnOpSel].mUnOpLoad.Value = uoData.UnOpLoad;
vettUnOp[uoData.UnOpSel].mUnOpAccTime.Value = 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...
vettAxis[AxData.AxisSel].mAxMainProc.Value = AxData.AxisMainProc;
vettAxis[AxData.AxisSel].mAxIsMaster.Value = AxData.AxisIsMaster;
vettAxis[AxData.AxisSel].mAxMastId.Value = AxData.AxisMastId;
//vettAxis[AxData.AxisSel].mAxType.Value = AxData.AxisType;
vettAxis[AxData.AxisSel].mAxDir.Value = AxData.AxisDir;
vettAxis[AxData.AxisSel].mAxLoad.Value = AxData.AxisLoad;
vettAxis[AxData.AxisSel].mAxPosAct.Value = AxData.AxisPosAct;
vettAxis[AxData.AxisSel].mAxPosTgt.Value = AxData.AxisPosTgt;
vettAxis[AxData.AxisSel].mAxFeedAct.Value = AxData.AxisFeedAct;
vettAxis[AxData.AxisSel].mAxFeedOver.Value = AxData.AxisFeedOver;
vettAxis[AxData.AxisSel].mAxAccelAct.Value = AxData.AxisAccel;
vettAxis[AxData.AxisSel].mAxAccTime.Value = AxData.AxisAccTime;
vettAxis[AxData.AxisSel].mAxBattery.Value = AxData.AxisBattery;
}
}
}
}