Merge branch 'feature/S7Net' into develop
This commit is contained in:
@@ -6,19 +6,151 @@ namespace CMS_CORE_Library.Models
|
||||
{
|
||||
public class ThermoModels
|
||||
{
|
||||
#region Thermo models
|
||||
|
||||
#region Fields
|
||||
|
||||
protected const double EPSILON = 0.1;
|
||||
|
||||
#endregion Fields
|
||||
|
||||
#region Classes
|
||||
|
||||
/// <summary>
|
||||
/// Single AXIS Info Data
|
||||
/// </summary>
|
||||
public class AxisInfo
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
public int ControlWord { get; set; } = 0;
|
||||
public int ErrorCode { get; set; } = 0;
|
||||
public int Id { get; set; } = 0;
|
||||
public int MovPhase { get; set; } = 0;
|
||||
public int StatusWord { get; set; } = 0;
|
||||
public double TargetPos { get; set; } = 0;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
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 (StatusWord != item.StatusWord)
|
||||
return false;
|
||||
if (ControlWord != item.ControlWord)
|
||||
return false;
|
||||
if (TargetPos != item.TargetPos)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Single AXIS RealTime (positions / movement) Data
|
||||
/// </summary>
|
||||
public class AxisRT
|
||||
{
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Deserializzazione da byte ad oggetto AxisRT
|
||||
/// </summary>
|
||||
/// <param name="rawData"></param>
|
||||
public AxisRT(int currId, byte[] rawData)
|
||||
{
|
||||
// converto i dati da byte grezzi ai 3 componenti...
|
||||
Id = currId;
|
||||
Position = S7.Net.Types.Double.FromByteArray(rawData.Skip(0).Take(4).ToArray());
|
||||
Speed = S7.Net.Types.Double.FromByteArray(rawData.Skip(4).Take(4).ToArray());
|
||||
Load = S7.Net.Types.Double.FromByteArray(rawData.Skip(8).Take(4).ToArray());
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
public int Id { get; set; } = 0;
|
||||
public double Load { get; set; } = 0;
|
||||
public double Position { get; set; } = 0;
|
||||
public double Speed { get; set; } = 0;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <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[12];
|
||||
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(Position), 0, answ, 0, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(Speed), 0, answ, 4, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(Load), 0, answ, 8, 4);
|
||||
return answ;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
}
|
||||
|
||||
/// <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;
|
||||
|
||||
#region Properties
|
||||
|
||||
public double Air { get; set; } = 0;
|
||||
public double Power { get; set; } = 0;
|
||||
public double TimeAdv { get; set; } = 0;
|
||||
public double Vacuum { get; set; } = 0;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
@@ -45,169 +177,31 @@ namespace CMS_CORE_Library.Models
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <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 int 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>
|
||||
/// Deserializzazione da byte ad oggetto AxisRT
|
||||
/// </summary>
|
||||
/// <param name="rawData"></param>
|
||||
public AxisRT(int currId, byte[] rawData)
|
||||
{
|
||||
// converto i dati da byte grezzi ai 3 componenti...
|
||||
Id = currId;
|
||||
Position = S7.Net.Types.Double.FromByteArray(rawData.Skip(0).Take(4).ToArray());
|
||||
Speed = S7.Net.Types.Double.FromByteArray(rawData.Skip(4).Take(4).ToArray());
|
||||
Load = S7.Net.Types.Double.FromByteArray(rawData.Skip(8).Take(4).ToArray());
|
||||
}
|
||||
/// <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[12];
|
||||
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(Position), 0, answ, 0, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(Speed), 0, answ, 4, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.Double.ToByteArray(Load), 0, answ, 8, 4);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Single AXIS Info Data
|
||||
/// </summary>
|
||||
public class AxisInfo
|
||||
{
|
||||
public int Id { get; set; } = 0;
|
||||
public int ErrorCode { get; set; } = 0;
|
||||
public int MovPhase { get; set; } = 0;
|
||||
public int StatusWord { get; set; } = 0;
|
||||
public int ControlWord { get; set; } = 0;
|
||||
public double TargetPos { 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 (StatusWord != item.StatusWord)
|
||||
return false;
|
||||
if (ControlWord != item.ControlWord)
|
||||
return false;
|
||||
if (TargetPos != item.TargetPos)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public class ModuleBlock
|
||||
{
|
||||
public short Id { get; set; } = 0;
|
||||
|
||||
#region Properties
|
||||
|
||||
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 short Id { get; set; } = 0;
|
||||
public List<short> PrecedingId { get; set; } = new List<short>();
|
||||
public bool Running { get; set; } = false;
|
||||
public bool Terminated { get; set; } = false;
|
||||
public bool Visible { get; set; } = false;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
@@ -242,39 +236,41 @@ namespace CMS_CORE_Library.Models
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
}
|
||||
|
||||
public class WarmerChannel
|
||||
public class ProdCycleModel
|
||||
{
|
||||
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;
|
||||
|
||||
#region Properties
|
||||
|
||||
public ushort MessageId { get; set; } = 0;
|
||||
public ushort Mode { get; set; } = 0;
|
||||
public ushort Status { get; set; } = 0;
|
||||
public ushort Submode { get; set; } = 0;
|
||||
public uint TimeAdv { get; set; } = 0;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// Object is not a GaugeModel instance
|
||||
if (!(obj is WarmerChannel item))
|
||||
if (!(obj is ProdCycleModel item))
|
||||
return false;
|
||||
|
||||
if (IdChannel != item.IdChannel)
|
||||
if (Status != item.Status)
|
||||
return false;
|
||||
if (SetpointHMI != item.SetpointHMI)
|
||||
if (MessageId != item.MessageId)
|
||||
return false;
|
||||
if (SetpointThermoCam != item.SetpointThermoCam)
|
||||
if (Mode != item.Mode)
|
||||
return false;
|
||||
if (SetpointPLC != item.SetpointPLC)
|
||||
if (Submode != item.Submode)
|
||||
return false;
|
||||
if (ChStatus != item.ChStatus)
|
||||
return false;
|
||||
if (CurrAct != item.CurrAct)
|
||||
return false;
|
||||
if (PercAct != item.PercAct)
|
||||
if (TimeAdv != item.TimeAdv)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -283,28 +279,61 @@ namespace CMS_CORE_Library.Models
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
}
|
||||
|
||||
public class ProdInfoModel
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
public DateTime DtEvent { get; set; } = DateTime.Now;
|
||||
public short NumTarget { get; set; } = 0;
|
||||
public bool IsScrap { get; set; } = false;
|
||||
public double MaterialTempEndVent { get; set; } = 0;
|
||||
public double MaterialTempEndWarm { get; set; } = 0;
|
||||
public double MoldTemp { get; set; } = 0;
|
||||
public double MouldEnergyIN { get; set; } = 0;
|
||||
public double MouldEnergyOUT { get; set; } = 0;
|
||||
public short NumDone { get; set; } = 0;
|
||||
public short NumPreHot { get; set; } = 0;
|
||||
public short NumTarget { 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 int TimeVacuum { get; set; } = 0;
|
||||
public int TimeVent { get; set; } = 0;
|
||||
public int TimeWarm { 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 short NumPreHot { get; set; } = 0;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <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 override bool Equals(object obj)
|
||||
{
|
||||
@@ -354,54 +383,61 @@ namespace CMS_CORE_Library.Models
|
||||
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;
|
||||
}
|
||||
#endregion Methods
|
||||
|
||||
}
|
||||
|
||||
public class ProdCycleModel
|
||||
/// <summary>
|
||||
/// Recipe Parameters
|
||||
/// </summary>
|
||||
public class RecipeParam
|
||||
{
|
||||
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;
|
||||
|
||||
#region Properties
|
||||
|
||||
public bool Enabled { get; set; } = false;
|
||||
public bool HasError { get; set; } = false;
|
||||
public short Id { get; set; } = 0;
|
||||
public int ScaleFactor { get; set; } = 1;
|
||||
public double SetpointHMI { get; set; } = 0;
|
||||
public double SetpointPLC { get; set; } = 0;
|
||||
public ushort UnitMeasure { get; set; } = 0;
|
||||
public double ValMax { get; set; } = 0;
|
||||
public double ValMin { get; set; } = 0;
|
||||
public double ValueAct { get; set; } = 0;
|
||||
public bool Visible { get; set; } = false;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// Object is not a GaugeModel instance
|
||||
if (!(obj is ProdCycleModel item))
|
||||
if (!(obj is RecipeParam item))
|
||||
return false;
|
||||
|
||||
if (Status != item.Status)
|
||||
if (Id != item.Id)
|
||||
return false;
|
||||
if (MessageId != item.MessageId)
|
||||
if (SetpointHMI != item.SetpointHMI)
|
||||
return false;
|
||||
if (Mode != item.Mode)
|
||||
if (SetpointPLC != item.SetpointPLC)
|
||||
return false;
|
||||
if (Submode != item.Submode)
|
||||
if (ValMax != item.ValMax)
|
||||
return false;
|
||||
if (TimeAdv != item.TimeAdv)
|
||||
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;
|
||||
@@ -410,8 +446,121 @@ namespace CMS_CORE_Library.Models
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
}
|
||||
public class WarmerChannel
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Channel status
|
||||
/// </summary>
|
||||
public byte ChStatus { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Channel AMPERE actual value
|
||||
/// </summary>
|
||||
public double CurrAct { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Channel Unique ID (from risk2007)
|
||||
/// </summary>
|
||||
public int IdChannel { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Reflector ID
|
||||
/// </summary>
|
||||
public byte IdRefl { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Channel MaxPower
|
||||
/// </summary>
|
||||
public int MaxPower { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Channel actual value %
|
||||
/// </summary>
|
||||
public byte PercAct { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Setpoint from HMI (%)
|
||||
/// </summary>
|
||||
public byte SetpointHMI { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Setpoint from PLC (%)
|
||||
/// </summary>
|
||||
public byte SetpointPLC { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Define if camera is active for channel
|
||||
/// </summary>
|
||||
public bool TCamActive { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Actual value from last ThermoCam image acquisition (1/10 ° Celsius)
|
||||
/// </summary>
|
||||
public short TCamTempActual { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Setpoint from HMI (1/10 ° Celsius)
|
||||
/// </summary>
|
||||
public short TCamTempSet { get; set; } = 0;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Equality test for class object
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// Object is not a GaugeModel instance
|
||||
if (!(obj is WarmerChannel item))
|
||||
return false;
|
||||
|
||||
if (ChStatus != item.ChStatus)
|
||||
return false;
|
||||
if (CurrAct != item.CurrAct)
|
||||
return false;
|
||||
if (IdChannel != item.IdChannel)
|
||||
return false;
|
||||
if (PercAct != item.PercAct)
|
||||
return false;
|
||||
if (SetpointHMI != item.SetpointHMI)
|
||||
return false;
|
||||
if (SetpointPLC != item.SetpointPLC)
|
||||
return false;
|
||||
if (TCamActive != item.TCamActive)
|
||||
return false;
|
||||
if (TCamTempActual != item.TCamTempActual)
|
||||
return false;
|
||||
if (TCamTempSet != item.TCamTempSet)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash gen
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Classes
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,9 +674,10 @@ namespace CMS_CORE_Library
|
||||
/// <summary>
|
||||
/// Get current Warmers Channels list
|
||||
/// </summary>
|
||||
/// <param name="useCache">updates only READ parameters (false = update all data)</param>
|
||||
/// <param name="currWarmerChannelList"></param>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_RWarmerChannelList(ref Dictionary<int, ThermoModels.WarmerChannel> currWarmerChannelList);
|
||||
public abstract CmsError PLC_RWarmerChannelList(bool useCache, ref Dictionary<int, ThermoModels.WarmerChannel> currWarmerChannelList);
|
||||
/// <summary>
|
||||
/// Set current Warmers Channels setpoints
|
||||
/// </summary>
|
||||
@@ -684,11 +685,17 @@ namespace CMS_CORE_Library
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_WWarmerChSetpHmi(Dictionary<int, int> newData);
|
||||
/// <summary>
|
||||
/// Set current Warmers Channels setpoints
|
||||
/// Set current Warmers Channels ThermocamSetpoints (°C)
|
||||
/// </summary>
|
||||
/// <param name="newData"></param>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_WWarmerChSetpTCam(Dictionary<int, int> newData);
|
||||
public abstract CmsError PLC_WWarmerChTCamSetp(Dictionary<int, double> newData);
|
||||
/// <summary>
|
||||
/// Set current Warmers Channels Thermocam read (actual) value (°C)
|
||||
/// </summary>
|
||||
/// <param name="newData"></param>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_WWarmerChTCamActual(Dictionary<int, double> newData);
|
||||
/// <summary>
|
||||
/// Set current Warmers Channels reflector's data
|
||||
/// </summary>
|
||||
|
||||
@@ -2345,22 +2345,35 @@ namespace CMS_CORE_Library.S7Net
|
||||
/// <summary>
|
||||
/// Get current Warmers Channels list
|
||||
/// </summary>
|
||||
/// <param name="useCache">updates only READ parameters (false = update all data)</param>
|
||||
/// <param name="currWarmerChannelList"></param>
|
||||
/// <returns></returns>
|
||||
public override CmsError PLC_RWarmerChannelList(ref Dictionary<int, ThermoModels.WarmerChannel> currWarmerChannelList)
|
||||
public override CmsError PLC_RWarmerChannelList(bool useCache, ref Dictionary<int, ThermoModels.WarmerChannel> currWarmerChannelList)
|
||||
{
|
||||
// refresh stato canale
|
||||
// refresh stato canale ESP[i]
|
||||
refreshRiscStatus();
|
||||
// refresh % attuale
|
||||
// refresh % lavoro attuale OVp[i]
|
||||
refreshRiscPerc();
|
||||
// refresh setpoint PLC
|
||||
// refresh corrente attuale Ich[i]
|
||||
refreshRiscActCurr();
|
||||
// refresh setpoint HMI
|
||||
refreshRiscSetpointHMI();
|
||||
// refresh setpoint PLC
|
||||
// refresh setpoint PLC % (era 514 --> 627)
|
||||
refreshRiscSetpointPLC();
|
||||
// refresh setpoint termocamera ???
|
||||
refreshRiscSetpointTermoCam();
|
||||
|
||||
// refresh dati status/comando termocamera
|
||||
refreshRiscTermoCamCommStatus();
|
||||
|
||||
// refresh setpoint HMI canale % | Write
|
||||
refreshRiscSetpointHMI();
|
||||
|
||||
if (!useCache)
|
||||
{
|
||||
// refresh abilitazione canale x thermoCam | Write
|
||||
refreshRiscTermoCamAbilit();
|
||||
// refresh ultima temp canale letta da thermoCam | Write
|
||||
refreshRiscTermoCamTempAct();
|
||||
// refresh temp canale impostata x thermoCam | Write
|
||||
refreshRiscTermoCamTempSet();
|
||||
}
|
||||
|
||||
// copio lista act in output
|
||||
currWarmerChannelList = ThermoWarmChannels;
|
||||
@@ -2945,18 +2958,185 @@ namespace CMS_CORE_Library.S7Net
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh Canali Riscaldi: SetPoint Termocamera
|
||||
/// Refresh dati ThermoCamera dal PLC: temperatura impostata come riferimento
|
||||
/// </summary>
|
||||
private void refreshRiscSetpointTermoCam()
|
||||
private void refreshRiscTermoCamTempSet()
|
||||
{
|
||||
// FIXME TODO ???? da dove prendere info?
|
||||
// leggo DB624 x Setpoint Temp richiesti
|
||||
List<short> currMem = new List<short>();
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
CmsError libraryError = MEM_RWShortList(R, 0, TCAM_TEMP_REQ_DATA.MemType, TCAM_TEMP_REQ_DATA.Address, TCAM_TEMP_REQ_DATA.SubAddress, TCAM_TEMP_REQ_DATA.Size, ref currMem);
|
||||
|
||||
// copio! controllo SE ho dati...
|
||||
if (currMem.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < TCAM_TEMP_REQ_DATA.Size / 2; i++)
|
||||
{
|
||||
// cerco id + 1 (su memoria è base 0)
|
||||
if (ThermoWarmChannels.ContainsKey(i + 1))
|
||||
{
|
||||
try
|
||||
{
|
||||
ThermoWarmChannels[i + 1].TCamTempSet = currMem[i];
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
ThermoWarmChannels.Add(i + 1, new ThermoModels.WarmerChannel()
|
||||
{
|
||||
IdChannel = i + 1,
|
||||
TCamTempSet = currMem[i]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
libraryError = S7_PLC_EMPTY_READ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Refresh dati ThermoCamera dal PLC: ultima temp letta
|
||||
/// </summary>
|
||||
private void refreshRiscTermoCamTempAct()
|
||||
{
|
||||
// leggo DB625 x Temp attuale
|
||||
List<short> currMem = new List<short>();
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
CmsError libraryError = MEM_RWShortList(R, 0, TCAM_TEMP_ACT_DATA.MemType, TCAM_TEMP_ACT_DATA.Address, TCAM_TEMP_ACT_DATA.SubAddress, TCAM_TEMP_ACT_DATA.Size, ref currMem);
|
||||
|
||||
// copio! controllo SE ho dati...
|
||||
if (currMem.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < TCAM_TEMP_ACT_DATA.Size / 2; i++)
|
||||
{
|
||||
// cerco id + 1 (su memoria è base 0)
|
||||
if (ThermoWarmChannels.ContainsKey(i + 1))
|
||||
{
|
||||
try
|
||||
{
|
||||
ThermoWarmChannels[i + 1].TCamTempActual = currMem[i];
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
ThermoWarmChannels.Add(i + 1, new ThermoModels.WarmerChannel()
|
||||
{
|
||||
IdChannel = i + 1,
|
||||
TCamTempActual = currMem[i]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
libraryError = S7_PLC_EMPTY_READ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Refresh dati ThermoCamera dal PLC x area command/status
|
||||
/// </summary>
|
||||
private void refreshRiscTermoCamCommStatus()
|
||||
{
|
||||
#if false
|
||||
// leggo DB614 x area Ich
|
||||
List<byte> currMem = new List<byte>();
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
CmsError libraryError = MEM_RWByteList(R, 0, RISC_CHP_DATA.MemType, RISC_CHP_DATA.Address, RISC_CHP_DATA.SubAddress, 0, RISC_CHP_DATA.Size, ref currMem);
|
||||
|
||||
// copio! controllo SE ho dati...
|
||||
if (currMem.Count > 0)
|
||||
{
|
||||
// converto a blocchi di 8 byte...
|
||||
byte[] memArray = currMem.ToArray();
|
||||
for (int i = 0; i < RISC_CHP_DATA.Size; i++)
|
||||
{
|
||||
// cerco id + 1 (su memoria è base 0)
|
||||
if (ThermoWarmChannels.ContainsKey(i + 1))
|
||||
{
|
||||
try
|
||||
{
|
||||
ThermoWarmChannels[i + 1].SetpointHMI = memArray[i];
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
ThermoWarmChannels.Add(i + 1, new ThermoModels.WarmerChannel()
|
||||
{
|
||||
IdChannel = i + 1,
|
||||
SetpointHMI = memArray[i]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
libraryError = S7_PLC_EMPTY_READ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// Refresh dati ThermoCamera dal PLC x area command/status
|
||||
/// </summary>
|
||||
private void refreshRiscTermoCamAbilit()
|
||||
{
|
||||
// leggo DB664 x abilitazione ch alla termocamera
|
||||
List<byte> currMem = new List<byte>();
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
CmsError libraryError = MEM_RWByteList(R, 0, TCAM_CH_ENAB_DATA.MemType, TCAM_CH_ENAB_DATA.Address, TCAM_CH_ENAB_DATA.SubAddress, 0, TCAM_CH_ENAB_DATA.Size, ref currMem);
|
||||
|
||||
// copio! controllo SE ho dati...
|
||||
if (currMem.Count > 0)
|
||||
{
|
||||
bool[] bits = new bool[TCAM_CH_ENAB_DATA.Size * 8];
|
||||
|
||||
// Convert int into to true/false array
|
||||
var bArray = new BitArray(currMem.ToArray());
|
||||
bArray.CopyTo(bits, 0);
|
||||
|
||||
for (int i = 0; i < TCAM_CH_ENAB_DATA.Size * 8; i++)
|
||||
{
|
||||
// cerco id + 1 (su memoria è base 0)
|
||||
if (ThermoWarmChannels.ContainsKey(i + 1))
|
||||
{
|
||||
try
|
||||
{
|
||||
ThermoWarmChannels[i + 1].TCamActive = bits[i];
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
ThermoWarmChannels.Add(i + 1, new ThermoModels.WarmerChannel()
|
||||
{
|
||||
IdChannel = i + 1,
|
||||
TCamActive = bits[i]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
libraryError = S7_PLC_EMPTY_READ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Refresh Canali Riscaldi: SetPoint HMI
|
||||
/// </summary>
|
||||
private void refreshRiscSetpointHMI()
|
||||
{
|
||||
// leggo DB514 x area Ich
|
||||
// leggo DB614 x area Ich
|
||||
List<byte> currMem = new List<byte>();
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
@@ -2995,11 +3175,11 @@ namespace CMS_CORE_Library.S7Net
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Refresh Canali Riscaldi: SetPoint PLC
|
||||
/// Refresh Canali Riscaldi: SetPoint PLC (% lavoro applicata ATTUALE dal PLC)
|
||||
/// </summary>
|
||||
private void refreshRiscSetpointPLC()
|
||||
{
|
||||
// leggo DB514 x area Ich
|
||||
// leggo area DB627 (era DB514) x area CHp
|
||||
List<byte> currMem = new List<byte>();
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
@@ -3070,7 +3250,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Refresh Canali Riscaldi: Percentuale Attuale
|
||||
/// Refresh Canali Riscaldi: Percentuale lavoro Attuale
|
||||
/// </summary>
|
||||
private void refreshRiscPerc()
|
||||
{
|
||||
@@ -3171,11 +3351,46 @@ namespace CMS_CORE_Library.S7Net
|
||||
return NO_ERROR;
|
||||
}
|
||||
/// <summary>
|
||||
/// Write Warmers channels termocam data
|
||||
/// Set current Warmers Channels ThermocamSetpoints (°C)
|
||||
/// </summary>
|
||||
/// <param name="updtCh"></param>
|
||||
/// <returns></returns>
|
||||
public override CmsError PLC_WWarmerChSetpTCam(Dictionary<int, int> newData)
|
||||
public override CmsError PLC_WWarmerChTCamSetp(Dictionary<int, double> newData)
|
||||
{
|
||||
// FIXME TODO serve nuova area termocamera
|
||||
#if false
|
||||
// memory area
|
||||
byte[] newMem = new byte[newData.Count];
|
||||
List<byte> currMem = new List<byte>();
|
||||
|
||||
// read actual data on memory...
|
||||
CmsError libraryError = MEM_RWByteList(R, 0, RISC_CHP_DATA.MemType, RISC_CHP_DATA.Address, RISC_CHP_DATA.SubAddress, 0, RISC_CHP_DATA.Size, ref currMem);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
newMem = currMem.ToArray();
|
||||
|
||||
// update only given data...
|
||||
foreach (var item in newData)
|
||||
{
|
||||
newMem[item.Key - 1] = (byte)item.Value;
|
||||
}
|
||||
// return as list...
|
||||
currMem = newMem.ToList();
|
||||
// scrivo sul PLC array di byte...
|
||||
libraryError = MEM_RWByteList(W, 0, RISC_CHP_DATA.MemType, RISC_CHP_DATA.Address, RISC_CHP_DATA.SubAddress, 0, RISC_CHP_DATA.Size, ref currMem);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
#endif
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
/// <summary>
|
||||
/// Set current Warmers Channels Thermocam read (actual) value (°C)
|
||||
/// </summary>
|
||||
/// <param name="updtCh"></param>
|
||||
/// <returns></returns>
|
||||
public override CmsError PLC_WWarmerChTCamActual(Dictionary<int, double> newData)
|
||||
{
|
||||
// FIXME TODO serve nuova area termocamera
|
||||
#if false
|
||||
@@ -4917,7 +5132,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
// riscaldi
|
||||
internal static MEMORY_CELL RISC_VU_MIN = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 513, 0, 2);
|
||||
internal static MEMORY_CELL RISC_OCC_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 64, 64);
|
||||
internal static MEMORY_CELL RISC_PLC_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 128, 1024);
|
||||
internal static MEMORY_CELL RISC_PLC_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 627, 0, 1024); //internal static MEMORY_CELL RISC_PLC_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 128, 1024); //valore PRE thermoCam
|
||||
internal static MEMORY_CELL RISC_CHP_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 614, 0, 1024);
|
||||
internal static MEMORY_CELL RISC_CFI_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 2176, 1024);
|
||||
internal static MEMORY_CELL RISC_ICH_MIN_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 3200, 4096);
|
||||
@@ -4926,6 +5141,14 @@ namespace CMS_CORE_Library.S7Net
|
||||
internal static MEMORY_CELL RISC_OVP_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 10752, 1024);
|
||||
internal static MEMORY_CELL RISC_ICH_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 11776, 4096);
|
||||
|
||||
// ThermoCamera
|
||||
internal static MEMORY_CELL TCAM_STATW_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 626, 0, 2);
|
||||
internal static MEMORY_CELL TCAM_COMMW_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 626, 2, 2);
|
||||
internal static MEMORY_CELL TCAM_CH_ENAB_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 626, 4, 128);
|
||||
internal static MEMORY_CELL TCAM_TEMP_REQ_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 624, 0, 2048);
|
||||
internal static MEMORY_CELL TCAM_TEMP_ACT_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 625, 0, 2048);
|
||||
|
||||
|
||||
// produzione
|
||||
internal static MEMORY_CELL PROCESS_PROD_INFO = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 606, 0, 52);
|
||||
internal static MEMORY_CELL PROCESS_PROD_CYCLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 605, 0, 22);
|
||||
|
||||
Reference in New Issue
Block a user