381 lines
14 KiB
C#
381 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CMS_CORE_Library.Models
|
|
{
|
|
public class ThermoModels
|
|
{
|
|
#region Thermo models
|
|
|
|
/// <summary>
|
|
/// Represents thermo LIVE prod data (gauge, time adv...)
|
|
/// </summary>
|
|
public class LiveProdDataModel
|
|
{
|
|
public double TimeAdv { get; set; } = 0;
|
|
public double Power { get; set; } = 0;
|
|
public double Vacuum { get; set; } = 0;
|
|
public double Air { get; set; } = 0;
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
// Object is not a GaugeModel instance
|
|
if (!(obj is LiveProdDataModel item))
|
|
return false;
|
|
|
|
if (TimeAdv != item.TimeAdv)
|
|
return false;
|
|
|
|
if (Power != item.Power)
|
|
return false;
|
|
|
|
if (Vacuum != item.Vacuum)
|
|
return false;
|
|
|
|
if (Air != item.Air)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Recipe Parameters
|
|
/// </summary>
|
|
public class RecipeParam
|
|
{
|
|
public short Id { get; set; } = 0;
|
|
public double SetpointHMI { get; set; } = 0;
|
|
public double SetpointPLC { get; set; } = 0;
|
|
public double ValMax { get; set; } = 0;
|
|
public double ValMin { get; set; } = 0;
|
|
public ushort UnitMeasure { get; set; } = 0;
|
|
public bool Visible { get; set; } = false;
|
|
public bool Enabled { get; set; } = false;
|
|
public bool HasError { get; set; } = false;
|
|
public double ValueAct { get; set; } = 0;
|
|
public int ScaleFactor { get; set; } = 1;
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
// Object is not a GaugeModel instance
|
|
if (!(obj is RecipeParam item))
|
|
return false;
|
|
|
|
if (Id != item.Id)
|
|
return false;
|
|
if (SetpointHMI != item.SetpointHMI)
|
|
return false;
|
|
if (SetpointPLC != item.SetpointPLC)
|
|
return false;
|
|
if (ValMax != item.ValMax)
|
|
return false;
|
|
if (ValMin != item.ValMin)
|
|
return false;
|
|
if (UnitMeasure != item.UnitMeasure)
|
|
return false;
|
|
if (Visible != item.Visible)
|
|
return false;
|
|
if (Enabled != item.Enabled)
|
|
return false;
|
|
if (HasError != item.HasError)
|
|
return false;
|
|
if (ValueAct != item.ValueAct)
|
|
return false;
|
|
if (ScaleFactor != item.ScaleFactor)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Single AXIS RealTime (positions / movement) Data
|
|
/// </summary>
|
|
public class AxisRT
|
|
{
|
|
public short Id { get; set; } = 0;
|
|
public double Position { get; set; } = 0;
|
|
public double Speed { get; set; } = 0;
|
|
public double Load { get; set; } = 0;
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
// Object is not a GaugeModel instance
|
|
if (!(obj is AxisRT item))
|
|
return false;
|
|
|
|
if (Id != item.Id)
|
|
return false;
|
|
if (Position != item.Position)
|
|
return false;
|
|
if (Speed != item.Speed)
|
|
return false;
|
|
if (Load != item.Load)
|
|
return false;
|
|
return true;
|
|
}
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Single AXIS Info Data
|
|
/// </summary>
|
|
public class AxisInfo
|
|
{
|
|
public short Id { get; set; } = 0;
|
|
public int errorCode { get; set; } = 0;
|
|
public int movPhase { get; set; } = 0;
|
|
public int statusCode { get; set; } = 0;
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
// Object is not a GaugeModel instance
|
|
if (!(obj is AxisInfo item))
|
|
return false;
|
|
|
|
if (Id != item.Id)
|
|
return false;
|
|
if (errorCode != item.errorCode)
|
|
return false;
|
|
if (movPhase != item.movPhase)
|
|
return false;
|
|
if (statusCode != item.statusCode)
|
|
return false;
|
|
return true;
|
|
}
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
|
|
public class ModuleBlock
|
|
{
|
|
public short Id { get; set; } = 0;
|
|
public int ActualDelay { get; set; } = 0;
|
|
public int ActualDuration { get; set; } = 0;
|
|
public int EstimatedDelay { get; set; } = 0;
|
|
public int EstimatedDuration { get; set; } = 0;
|
|
public List<short> PrecedingId { get; set; } = new List<short>();
|
|
public bool Visible { get; set; } = false;
|
|
public bool Running { get; set; } = false;
|
|
public bool HasError { get; set; } = false;
|
|
public bool Terminated { get; set; } = false;
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
// Object is not a GaugeModel instance
|
|
if (!(obj is ModuleBlock item))
|
|
return false;
|
|
|
|
if (Id != item.Id)
|
|
return false;
|
|
if (ActualDelay != item.ActualDelay)
|
|
return false;
|
|
if (ActualDuration != item.ActualDuration)
|
|
return false;
|
|
if (EstimatedDelay != item.EstimatedDelay)
|
|
return false;
|
|
if (EstimatedDuration != item.EstimatedDuration)
|
|
return false;
|
|
if (PrecedingId != item.PrecedingId)
|
|
return false;
|
|
if (Visible != item.Visible)
|
|
return false;
|
|
if (Running != item.Running)
|
|
return false;
|
|
if (HasError != item.HasError)
|
|
return false;
|
|
if (Terminated != item.Terminated)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
|
|
public class WarmerChannel
|
|
{
|
|
public int IdChannel { get; set; } = 0;
|
|
public byte IdRefl { get; set; } = 0;
|
|
public byte SetpointHMI { get; set; } = 0;
|
|
public byte SetpointThermoCam { get; set; } = 0;
|
|
public byte SetpointPLC { get; set; } = 0;
|
|
public byte ChStatus { get; set; } = 0;
|
|
public double CurrAct { get; set; } = 0;
|
|
public byte PercAct { get; set; } = 0;
|
|
public int MaxPower { get; set; } = 0;
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
// Object is not a GaugeModel instance
|
|
if (!(obj is WarmerChannel item))
|
|
return false;
|
|
|
|
if (IdChannel != item.IdChannel)
|
|
return false;
|
|
if (SetpointHMI != item.SetpointHMI)
|
|
return false;
|
|
if (SetpointThermoCam != item.SetpointThermoCam)
|
|
return false;
|
|
if (SetpointPLC != item.SetpointPLC)
|
|
return false;
|
|
if (ChStatus != item.ChStatus)
|
|
return false;
|
|
if (CurrAct != item.CurrAct)
|
|
return false;
|
|
if (PercAct != item.PercAct)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
|
|
|
|
public class ProdInfoModel
|
|
{
|
|
public DateTime DtEvent { get; set; }
|
|
public short NumTarget { get; set; } = 0;
|
|
public short NumDone { get; set; } = 0;
|
|
public short PreWarmCycle { get; set; } = 0;
|
|
public int TimeWarm { get; set; } = 0;
|
|
public int TimeVent { get; set; } = 0;
|
|
public int TimeVacuum { get; set; } = 0;
|
|
public int TimeCycleGross { get; set; } = 0;
|
|
public int TimeCycleNet { get; set; } = 0;
|
|
public double MaterialTempEndWarm { get; set; } = 0;
|
|
public double MaterialTempEndVent { get; set; } = 0;
|
|
public double MoldTemp { get; set; } = 0;
|
|
public double VacuumReadVal { get; set; } = 0;
|
|
public double MouldEnergyOUT { get; set; } = 0;
|
|
public double MouldEnergyIN { get; set; } = 0;
|
|
public bool IsScrap { get; set; } = false;
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
// Object is not a GaugeModel instance
|
|
if (!(obj is ProdInfoModel item))
|
|
return false;
|
|
|
|
if (DtEvent != item.DtEvent)
|
|
return false;
|
|
if (NumTarget != item.NumTarget)
|
|
return false;
|
|
if (NumDone != item.NumDone)
|
|
return false;
|
|
if (PreWarmCycle != item.PreWarmCycle)
|
|
return false;
|
|
if (TimeWarm != item.TimeWarm)
|
|
return false;
|
|
if (TimeVent != item.TimeVent)
|
|
return false;
|
|
if (TimeVacuum != item.TimeVacuum)
|
|
return false;
|
|
if (TimeCycleGross != item.TimeCycleGross)
|
|
return false;
|
|
if (TimeCycleNet != item.TimeCycleNet)
|
|
return false;
|
|
if (MaterialTempEndWarm != item.MaterialTempEndWarm)
|
|
return false;
|
|
if (MaterialTempEndVent != item.MaterialTempEndVent)
|
|
return false;
|
|
if (MoldTemp != item.MoldTemp)
|
|
return false;
|
|
if (VacuumReadVal != item.VacuumReadVal)
|
|
return false;
|
|
if (MouldEnergyOUT != item.MouldEnergyOUT)
|
|
return false;
|
|
if (MouldEnergyIN != item.MouldEnergyIN)
|
|
return false;
|
|
if (IsScrap != item.IsScrap)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converte un singolo item in un array di byte per scrittura su PLC S7
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public byte[] convertToByte()
|
|
{
|
|
byte[] answ = new byte[50];
|
|
Buffer.BlockCopy(S7.Net.Types.Int.ToByteArray(NumTarget), 0, answ, 0, 2);
|
|
Buffer.BlockCopy(S7.Net.Types.Int.ToByteArray(NumDone), 0, answ, 2, 2);
|
|
Buffer.BlockCopy(S7.Net.Types.Int.ToByteArray(PreWarmCycle), 0, answ, 4, 2);
|
|
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(TimeWarm), 0, answ, 6, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(TimeVent), 0, answ, 10, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(TimeVacuum), 0, answ, 14, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(TimeCycleGross), 0, answ, 18, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(TimeCycleNet), 0, answ, 22, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(MaterialTempEndWarm), 0, answ, 26, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(MaterialTempEndVent), 0, answ, 30, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(MoldTemp), 0, answ, 34, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(VacuumReadVal), 0, answ, 38, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(MouldEnergyOUT), 0, answ, 42, 4);
|
|
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(MouldEnergyIN), 0, answ, 46, 4);
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
public class ProdCycleModel
|
|
{
|
|
public ushort Status { get; set; } = 0;
|
|
public ushort MessageId { get; set; } = 0;
|
|
public ushort Mode { get; set; } = 0;
|
|
public ushort Submode { get; set; } = 0;
|
|
public uint TimeAdv { get; set; } = 0;
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
// Object is not a GaugeModel instance
|
|
if (!(obj is ProdCycleModel item))
|
|
return false;
|
|
|
|
if (Status != item.Status)
|
|
return false;
|
|
if (MessageId != item.MessageId)
|
|
return false;
|
|
if (Mode != item.Mode)
|
|
return false;
|
|
if (Submode != item.Submode)
|
|
return false;
|
|
if (TimeAdv != item.TimeAdv)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|