diff --git a/CMS_CORE_Library/Models/ThermoModels.cs b/CMS_CORE_Library/Models/ThermoModels.cs
index 18e0516..2d89427 100644
--- a/CMS_CORE_Library/Models/ThermoModels.cs
+++ b/CMS_CORE_Library/Models/ThermoModels.cs
@@ -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
+
+ ///
+ /// Single AXIS Info Data
+ ///
+ 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
+
+ }
+
+ ///
+ /// Single AXIS RealTime (positions / movement) Data
+ ///
+ public class AxisRT
+ {
+
+ #region Constructors
+
+ ///
+ /// Deserializzazione da byte ad oggetto AxisRT
+ ///
+ ///
+ 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
+
+ ///
+ /// Converte un singolo item in un array di byte per scrittura su PLC S7
+ ///
+ ///
+ 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
+
+ }
+
///
/// Represents thermo LIVE prod data (gauge, time adv...)
///
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
+
}
- ///
- /// Recipe Parameters
- ///
- 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();
- }
- }
- ///
- /// Single AXIS RealTime (positions / movement) Data
- ///
- 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();
- }
-
- ///
- /// Deserializzazione da byte ad oggetto AxisRT
- ///
- ///
- 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());
- }
- ///
- /// Converte un singolo item in un array di byte per scrittura su PLC S7
- ///
- ///
- 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;
- }
- }
- ///
- /// Single AXIS Info Data
- ///
- 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 PrecedingId { get; set; } = new List();
- 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 PrecedingId { get; set; } = new List();
+ 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
+
+ ///
+ /// Converte un singolo item in un array di byte per scrittura su PLC S7
+ ///
+ ///
+ 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();
}
- ///
- /// Converte un singolo item in un array di byte per scrittura su PLC S7
- ///
- ///
- 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
+ ///
+ /// Recipe Parameters
+ ///
+ 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
+
+ ///
+ /// Channel status
+ ///
+ public byte ChStatus { get; set; } = 0;
+
+ ///
+ /// Channel AMPERE actual value
+ ///
+ public double CurrAct { get; set; } = 0;
+
+ ///
+ /// Channel Unique ID (from risk2007)
+ ///
+ public int IdChannel { get; set; } = 0;
+
+ ///
+ /// Reflector ID
+ ///
+ public byte IdRefl { get; set; } = 0;
+
+ ///
+ /// Channel MaxPower
+ ///
+ public int MaxPower { get; set; } = 0;
+
+ ///
+ /// Channel actual value %
+ ///
+ public byte PercAct { get; set; } = 0;
+
+ ///
+ /// Setpoint from HMI (%)
+ ///
+ public byte SetpointHMI { get; set; } = 0;
+
+ ///
+ /// Setpoint from PLC (%)
+ ///
+ public byte SetpointPLC { get; set; } = 0;
+
+ ///
+ /// Define if camera is active for channel
+ ///
+ public bool TCamActive { get; set; } = false;
+
+ ///
+ /// Actual value from last ThermoCam image acquisition (1/10 ° Celsius)
+ ///
+ public short TCamTempActual { get; set; } = 0;
+
+ ///
+ /// Setpoint from HMI (1/10 ° Celsius)
+ ///
+ public short TCamTempSet { get; set; } = 0;
+
+ #endregion Properties
+
+ #region Methods
+
+ ///
+ /// Equality test for class object
+ ///
+ ///
+ ///
+ 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;
+ }
+
+ ///
+ /// Hash gen
+ ///
+ ///
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+
+ #endregion Methods
+
}
- #endregion
+ #endregion Classes
+
}
}
diff --git a/CMS_CORE_Library/NcThermo.cs b/CMS_CORE_Library/NcThermo.cs
index 9588a6e..bb125ad 100644
--- a/CMS_CORE_Library/NcThermo.cs
+++ b/CMS_CORE_Library/NcThermo.cs
@@ -674,9 +674,10 @@ namespace CMS_CORE_Library
///
/// Get current Warmers Channels list
///
+ /// updates only READ parameters (false = update all data)
///
///
- public abstract CmsError PLC_RWarmerChannelList(ref Dictionary currWarmerChannelList);
+ public abstract CmsError PLC_RWarmerChannelList(bool useCache, ref Dictionary currWarmerChannelList);
///
/// Set current Warmers Channels setpoints
///
@@ -684,11 +685,17 @@ namespace CMS_CORE_Library
///
public abstract CmsError PLC_WWarmerChSetpHmi(Dictionary newData);
///
- /// Set current Warmers Channels setpoints
+ /// Set current Warmers Channels ThermocamSetpoints (°C)
///
///
///
- public abstract CmsError PLC_WWarmerChSetpTCam(Dictionary newData);
+ public abstract CmsError PLC_WWarmerChTCamSetp(Dictionary newData);
+ ///
+ /// Set current Warmers Channels Thermocam read (actual) value (°C)
+ ///
+ ///
+ ///
+ public abstract CmsError PLC_WWarmerChTCamActual(Dictionary newData);
///
/// Set current Warmers Channels reflector's data
///
diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs
index 38dc27d..41073c7 100644
--- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs
+++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs
@@ -2345,22 +2345,35 @@ namespace CMS_CORE_Library.S7Net
///
/// Get current Warmers Channels list
///
+ /// updates only READ parameters (false = update all data)
///
///
- public override CmsError PLC_RWarmerChannelList(ref Dictionary currWarmerChannelList)
+ public override CmsError PLC_RWarmerChannelList(bool useCache, ref Dictionary 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
}
///
- /// Refresh Canali Riscaldi: SetPoint Termocamera
+ /// Refresh dati ThermoCamera dal PLC: temperatura impostata come riferimento
///
- private void refreshRiscSetpointTermoCam()
+ private void refreshRiscTermoCamTempSet()
{
- // FIXME TODO ???? da dove prendere info?
+ // leggo DB624 x Setpoint Temp richiesti
+ List currMem = new List();
+
+ // 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;
+ }
+ }
+ ///
+ /// Refresh dati ThermoCamera dal PLC: ultima temp letta
+ ///
+ private void refreshRiscTermoCamTempAct()
+ {
+ // leggo DB625 x Temp attuale
+ List currMem = new List();
+
+ // 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;
+ }
+ }
+ ///
+ /// Refresh dati ThermoCamera dal PLC x area command/status
+ ///
+ private void refreshRiscTermoCamCommStatus()
+ {
+#if false
+ // leggo DB614 x area Ich
+ List currMem = new List();
+
+ // 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
+ }
+ ///
+ /// Refresh dati ThermoCamera dal PLC x area command/status
+ ///
+ private void refreshRiscTermoCamAbilit()
+ {
+ // leggo DB664 x abilitazione ch alla termocamera
+ List currMem = new List();
+
+ // 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;
+ }
}
///
/// Refresh Canali Riscaldi: SetPoint HMI
///
private void refreshRiscSetpointHMI()
{
- // leggo DB514 x area Ich
+ // leggo DB614 x area Ich
List currMem = new List();
// leggo da PLC a array di byte di appoggio...
@@ -2995,11 +3175,11 @@ namespace CMS_CORE_Library.S7Net
}
}
///
- /// Refresh Canali Riscaldi: SetPoint PLC
+ /// Refresh Canali Riscaldi: SetPoint PLC (% lavoro applicata ATTUALE dal PLC)
///
private void refreshRiscSetpointPLC()
{
- // leggo DB514 x area Ich
+ // leggo area DB627 (era DB514) x area CHp
List currMem = new List();
// leggo da PLC a array di byte di appoggio...
@@ -3070,7 +3250,7 @@ namespace CMS_CORE_Library.S7Net
}
}
///
- /// Refresh Canali Riscaldi: Percentuale Attuale
+ /// Refresh Canali Riscaldi: Percentuale lavoro Attuale
///
private void refreshRiscPerc()
{
@@ -3171,11 +3351,46 @@ namespace CMS_CORE_Library.S7Net
return NO_ERROR;
}
///
- /// Write Warmers channels termocam data
+ /// Set current Warmers Channels ThermocamSetpoints (°C)
///
///
///
- public override CmsError PLC_WWarmerChSetpTCam(Dictionary newData)
+ public override CmsError PLC_WWarmerChTCamSetp(Dictionary newData)
+ {
+ // FIXME TODO serve nuova area termocamera
+#if false
+ // memory area
+ byte[] newMem = new byte[newData.Count];
+ List currMem = new List();
+
+ // 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;
+ }
+ ///
+ /// Set current Warmers Channels Thermocam read (actual) value (°C)
+ ///
+ ///
+ ///
+ public override CmsError PLC_WWarmerChTCamActual(Dictionary 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);