This commit is contained in:
ext_luca.pansa@cms.it
2021-03-02 08:10:57 +01:00
4 changed files with 5196 additions and 4721 deletions
+295 -185
View File
@@ -6,22 +6,20 @@ namespace CMS_CORE_Library.Models
{
public class ThermoModels
{
#region Fields
#region Protected Fields
protected const double EPSILON = 0.1;
#endregion Fields
#endregion Protected Fields
#region Classes
#region Public Classes
/// <summary>
/// Single AXIS Info Data
/// </summary>
public class AxisInfo
{
#region Properties
#region Public Properties
public int ControlWord { get; set; } = 0;
public int ErrorCode { get; set; } = 0;
@@ -30,9 +28,9 @@ namespace CMS_CORE_Library.Models
public int StatusWord { get; set; } = 0;
public double TargetPos { get; set; } = 0;
#endregion Properties
#endregion Public Properties
#region Methods
#region Public Methods
public override bool Equals(object obj)
{
@@ -54,13 +52,13 @@ namespace CMS_CORE_Library.Models
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Methods
#endregion Public Methods
}
/// <summary>
@@ -68,8 +66,7 @@ namespace CMS_CORE_Library.Models
/// </summary>
public class AxisRT
{
#region Constructors
#region Public Constructors
/// <summary>
/// Deserializzazione da byte ad oggetto AxisRT
@@ -84,18 +81,18 @@ namespace CMS_CORE_Library.Models
Load = S7.Net.Types.Double.FromByteArray(rawData.Skip(8).Take(4).ToArray());
}
#endregion Constructors
#endregion Public Constructors
#region Properties
#region Public 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
#endregion Public Properties
#region Methods
#region Public Methods
/// <summary>
/// Converte un singolo item in un array di byte per scrittura su PLC S7
@@ -126,13 +123,165 @@ namespace CMS_CORE_Library.Models
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Methods
#endregion Public Methods
}
/// <summary>
/// Represent IO Channel FORCED by UI
/// </summary>
public class ChanIOFor
{
#region Public Properties
public Dictionary<int, bool> AO { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> DO { get; set; } = new Dictionary<int, bool>();
#endregion Public Properties
#region Public Methods
public override bool Equals(object obj)
{
if (!(obj is ChanIOVis item))
return false;
if (!DO.Equals(item.DO))
return false;
if (!AO.Equals(item.AO))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
/// <summary>
/// Represent IO Channel Values
/// </summary>
public class ChanIOVal
{
#region Public Properties
public Dictionary<int, int> AI { get; set; } = new Dictionary<int, int>();
public Dictionary<int, int> AO { get; set; } = new Dictionary<int, int>();
public Dictionary<int, bool> DI { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> DO { get; set; } = new Dictionary<int, bool>();
#endregion Public Properties
#region Public Methods
public override bool Equals(object obj)
{
if (!(obj is ChanIOVal item))
return false;
if (!DI.Equals(item.DI))
return false;
if (!DO.Equals(item.DO))
return false;
if (!AI.Equals(item.AI))
return false;
if (!AO.Equals(item.AO))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
/// <summary>
/// Represent IO Channel FORCED values
/// </summary>
public class ChanIOValFor
{
#region Public Properties
public Dictionary<int, int> AO { get; set; } = new Dictionary<int, int>();
public Dictionary<int, bool> DO { get; set; } = new Dictionary<int, bool>();
#endregion Public Properties
#region Public Methods
public override bool Equals(object obj)
{
if (!(obj is ChanIOVal item))
return false;
if (!DO.Equals(item.DO))
return false;
if (!AO.Equals(item.AO))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
/// <summary>
/// Represent IO Channel visibility
/// </summary>
public class ChanIOVis
{
#region Public Properties
public Dictionary<int, bool> AI { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> AO { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> DI { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> DO { get; set; } = new Dictionary<int, bool>();
#endregion Public Properties
#region Public Methods
public override bool Equals(object obj)
{
if (!(obj is ChanIOVis item))
return false;
if (!DI.Equals(item.DI))
return false;
if (!DO.Equals(item.DO))
return false;
if (!AI.Equals(item.AI))
return false;
if (!AO.Equals(item.AO))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
/// <summary>
@@ -140,17 +289,16 @@ namespace CMS_CORE_Library.Models
/// </summary>
public class LiveProdDataModel
{
#region Properties
#region Public 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
#endregion Public Properties
#region Methods
#region Public Methods
public override bool Equals(object obj)
{
@@ -178,15 +326,85 @@ namespace CMS_CORE_Library.Models
return base.GetHashCode();
}
#endregion Methods
#endregion Public Methods
}
public class LogCycleData
{
#region Public Constructors
/// <summary>
/// Deserializzazione da byte ad oggetto LogCycleData
/// </summary>
/// <param name="rawData"></param>
public LogCycleData(byte[] rawData)
{
// converto i dati da byte grezzi ai 3 componenti...
year = S7.Net.Types.Word.FromByteArray(rawData.Skip(0).Take(2).ToArray());
month = S7.Net.Types.Byte.FromByteArray(rawData.Skip(2).Take(1).ToArray());
day = S7.Net.Types.Byte.FromByteArray(rawData.Skip(3).Take(1).ToArray());
hour = S7.Net.Types.Byte.FromByteArray(rawData.Skip(4).Take(1).ToArray());
min = S7.Net.Types.Byte.FromByteArray(rawData.Skip(5).Take(1).ToArray());
msec = S7.Net.Types.Word.FromByteArray(rawData.Skip(6).Take(2).ToArray());
Code = S7.Net.Types.Word.FromByteArray(rawData.Skip(8).Take(2).ToArray());
}
#endregion Public Constructors
#region Public Properties
protected int year { get; set; } = 0;
protected int month { get; set; } = 0;
protected int day { get; set; } = 0;
protected int hour { get; set; } = 0;
protected int min { get; set; } = 0;
protected int msec { get; set; } = 0;
public DateTime DtEvent
{
get
{
DateTime answ = DateTime.Now;
try
{
new DateTime(year, month, day);
answ = answ.AddHours(hour).AddMinutes(min).AddMilliseconds(msec);
}
catch
{ }
return answ;
}
}
public int Code { get; set; } = 0;
#endregion Public Properties
#region Public Methods
public override bool Equals(object obj)
{
// Object is not a GaugeModel instance
if (!(obj is LogCycleData item))
return false;
if (DtEvent != item.DtEvent)
return false;
if (Code != item.Code)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
public class ModuleBlock
{
#region Properties
#region Public Properties
public int ActualDelay { get; set; } = 0;
public int ActualDuration { get; set; } = 0;
@@ -199,9 +417,9 @@ namespace CMS_CORE_Library.Models
public bool Terminated { get; set; } = false;
public bool Visible { get; set; } = false;
#endregion Properties
#endregion Public Properties
#region Methods
#region Public Methods
public override bool Equals(object obj)
{
@@ -232,19 +450,18 @@ namespace CMS_CORE_Library.Models
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Methods
#endregion Public Methods
}
public class ProdCycleModel
{
#region Properties
#region Public Properties
public ushort MessageId { get; set; } = 0;
public ushort Mode { get; set; } = 0;
@@ -252,9 +469,9 @@ namespace CMS_CORE_Library.Models
public ushort Submode { get; set; } = 0;
public uint TimeAdv { get; set; } = 0;
#endregion Properties
#endregion Public Properties
#region Methods
#region Public Methods
public override bool Equals(object obj)
{
@@ -275,41 +492,41 @@ namespace CMS_CORE_Library.Models
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Methods
#endregion Public Methods
}
public class ProdInfoModel
{
#region Properties
#region Public Properties
public DateTime DtEvent { get; set; } = DateTime.Now;
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 float MaterialTempEndVent { get; set; } = 0;
public float MaterialTempEndWarm { get; set; } = 0;
public float MoldTemp { get; set; } = 0;
public float MouldEnergyIN { get; set; } = 0;
public float 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 string ThermoImage { get; set; } = "";
public int TimeCycleGross { get; set; } = 0;
public int TimeCycleNet { 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 float VacuumReadVal { get; set; } = 0;
#endregion Properties
#endregion Public Properties
#region Methods
#region Public Methods
/// <summary>
/// Converte un singolo item in un array di byte per scrittura su PLC S7
@@ -326,12 +543,12 @@ namespace CMS_CORE_Library.Models
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);
Buffer.BlockCopy(S7.Net.Types.Real.ToByteArray(MaterialTempEndWarm), 0, answ, 26, 4);
Buffer.BlockCopy(S7.Net.Types.Real.ToByteArray(MaterialTempEndVent), 0, answ, 30, 4);
Buffer.BlockCopy(S7.Net.Types.Real.ToByteArray(MoldTemp), 0, answ, 34, 4);
Buffer.BlockCopy(S7.Net.Types.Real.ToByteArray(VacuumReadVal), 0, answ, 38, 4);
Buffer.BlockCopy(S7.Net.Types.Real.ToByteArray(MouldEnergyOUT), 0, answ, 42, 4);
Buffer.BlockCopy(S7.Net.Types.Real.ToByteArray(MouldEnergyIN), 0, answ, 46, 4);
return answ;
}
@@ -349,6 +566,8 @@ namespace CMS_CORE_Library.Models
return false;
if (PreWarmCycle != item.PreWarmCycle)
return false;
if (ThermoImage != item.ThermoImage)
return false;
if (TimeWarm != item.TimeWarm)
return false;
if (TimeVent != item.TimeVent)
@@ -378,126 +597,13 @@ namespace CMS_CORE_Library.Models
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Methods
}
/// <summary>
/// Represent IO Channel visibility
/// </summary>
public class ChanIOVis
{
public Dictionary<int, bool> DI { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> DO { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> AI { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> AO { get; set; } = new Dictionary<int, bool>();
public override bool Equals(object obj)
{
if (!(obj is ChanIOVis item))
return false;
if (!DI.Equals(item.DI))
return false;
if (!DO.Equals(item.DO))
return false;
if (!AI.Equals(item.AI))
return false;
if (!AO.Equals(item.AO))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
/// <summary>
/// Represent IO Channel Values
/// </summary>
public class ChanIOVal
{
public Dictionary<int, bool> DI { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> DO { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, int> AI { get; set; } = new Dictionary<int, int>();
public Dictionary<int, int> AO { get; set; } = new Dictionary<int, int>();
public override bool Equals(object obj)
{
if (!(obj is ChanIOVal item))
return false;
if (!DI.Equals(item.DI))
return false;
if (!DO.Equals(item.DO))
return false;
if (!AI.Equals(item.AI))
return false;
if (!AO.Equals(item.AO))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
/// <summary>
/// Represent IO Channel FORCED by UI
/// </summary>
public class ChanIOFor
{
public Dictionary<int, bool> DO { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, bool> AO { get; set; } = new Dictionary<int, bool>();
public override bool Equals(object obj)
{
if (!(obj is ChanIOVis item))
return false;
if (!DO.Equals(item.DO))
return false;
if (!AO.Equals(item.AO))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
/// <summary>
/// Represent IO Channel FORCED values
/// </summary>
public class ChanIOValFor
{
public Dictionary<int, bool> DO { get; set; } = new Dictionary<int, bool>();
public Dictionary<int, int> AO { get; set; } = new Dictionary<int, int>();
public override bool Equals(object obj)
{
if (!(obj is ChanIOVal item))
return false;
if (!DO.Equals(item.DO))
return false;
if (!AO.Equals(item.AO))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
/// <summary>
@@ -505,8 +611,7 @@ namespace CMS_CORE_Library.Models
/// </summary>
public class RecipeParam
{
#region Properties
#region Public Properties
public bool Enabled { get; set; } = false;
public bool HasError { get; set; } = false;
@@ -520,9 +625,9 @@ namespace CMS_CORE_Library.Models
public double ValueAct { get; set; } = 0;
public bool Visible { get; set; } = false;
#endregion Properties
#endregion Public Properties
#region Methods
#region Public Methods
public override bool Equals(object obj)
{
@@ -555,39 +660,46 @@ namespace CMS_CORE_Library.Models
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Methods
#endregion Public Methods
}
/// <summary>
/// ThermoCam management data
/// </summary>
public class ThermoCam
{
/// <summary>
/// Opzione ThermoCamera (set by PLC)
/// </summary>
public bool ThermoOptionActive { get; set; } = false;
#region Public Properties
/// <summary>
/// Modalità ThermoCamera (set by HMI)
/// </summary>
public bool ThermoCamMode { get; set; } = false;
/// <summary>
/// Funzionamento ThermoCamera (set by HMI)
/// </summary>
public bool ThermoCamOnOff { get; set; } = false;
/// <summary>
/// Opzione ThermoCamera (set by PLC)
/// </summary>
public bool ThermoOptionActive { get; set; } = false;
#endregion Public Properties
}
/// <summary>
/// Warmers channel data
/// </summary>
public class WarmerChannel
{
#region Properties
#region Public Properties
/// <summary>
/// Channel status
@@ -644,9 +756,9 @@ namespace CMS_CORE_Library.Models
/// </summary>
public short TCamTempSet { get; set; } = 0;
#endregion Properties
#endregion Public Properties
#region Methods
#region Public Methods
/// <summary>
/// Equality test for class object
@@ -690,11 +802,9 @@ namespace CMS_CORE_Library.Models
return base.GetHashCode();
}
#endregion Methods
#endregion Public Methods
}
#endregion Classes
#endregion Public Classes
}
}
}
+61 -3
View File
@@ -636,6 +636,13 @@ namespace CMS_CORE_Library
/// <returns></returns>
public abstract CmsError PLC_WAckSetpointInvalidated();
/// <summary>
/// Get current LOG Cycle data
/// </summary>
/// <param name="currParamList"></param>
/// <returns></returns>
public abstract CmsError PLC_RLogCycleData(out List<ThermoModels.LogCycleData> currLogCycle);
/// <summary>
/// Get current Axis RT data
/// </summary>
@@ -669,6 +676,17 @@ namespace CMS_CORE_Library
/// <param name="confirmUpdate">true: HMI --> PLC, false: PLC --> HMI</param>
/// <returns></returns>
public abstract CmsError PLC_WRecipeEdit(bool confirmUpdate);
/// <summary>
/// Send axis command
/// </summary>
/// <param name="AxisNum">ID asse</param>
/// <param name="CommandBit">Comando (0..15)</param>
/// <param name="WritePos">Indica se scrivere la TargetPos</param>
/// <param name="TargetPos">Posizione target</param>
/// <returns></returns>
public abstract CmsError PLC_WAxisCommand(int AxisNum, uint CommandBit, bool WritePos, double TargetPos);
/// <summary>
/// Confirm FLIR image acquired and copied to PLC
/// </summary>
@@ -797,14 +815,54 @@ namespace CMS_CORE_Library
/// <returns></returns>
public abstract CmsError PLC_WModeSel(int mode);
/// <summary>
/// Read PLC current IO hannels data
/// Read PLC current IO Channels visibility (conf)
/// </summary>
/// <param name="onlyVal">updates only VALUE readout</param>
/// <param name="currThermoIOVis">Visibility status for all channels</param>
public abstract CmsError PLC_RIOChannelsConf(ref ThermoModels.ChanIOVis currThermoIOVis);
/// <summary>
/// Read PLC current IO Channels VALUES (actual + forced)
/// </summary>
/// <param name="currThermoIOVal">Values for channels</param>
/// <param name="currThermoIOFor">Indicates if values are forced by UI</param>
/// <param name="currThermoIOValFor">Values forced by UI</param>
public abstract CmsError PLC_RIOChannels(bool onlyVal, ref ThermoModels.ChanIOVis currThermoIOVis, ref ThermoModels.ChanIOVal currThermoIOVal, ref ThermoModels.ChanIOFor currThermoIOFor, ref ThermoModels.ChanIOValFor currThermoIOValFor);
public abstract CmsError PLC_RIOChannelsVal(ref ThermoModels.ChanIOVal currThermoIOVal, ref ThermoModels.ChanIOFor currThermoIOFor, ref ThermoModels.ChanIOValFor currThermoIOValFor);
/// <summary>
/// Write MULTIPLE Digital Out values (+ force)
/// </summary>
/// <param name="newValues">Oggetto valori da aggiornare (from HMI)</param>
/// <param name="nMaxParamWrite">num max parametri da scrivere singolarmente</param>
/// <param name="delayParamWrite">delay in scriottura multi parametri singoli</param>
/// <returns></returns>
public abstract CmsError PLC_W_IO_DO_Val(Dictionary<int, bool> newValues);
/// <summary>
/// Write MULTIPLE Analog Out values (+ force)
/// </summary>
/// <param name="newValues">Oggetto valori da aggiornare (from HMI)</param>
/// <param name="nMaxParamWrite">num max parametri da scrivere singolarmente</param>
/// <param name="delayParamWrite">delay in scriottura multi parametri singoli</param>
/// <returns></returns>
public abstract CmsError PLC_W_IO_AO_Val(Dictionary<int, int> newValues);
/// <summary>
/// Reset MULTIPLE Digital Out FORCED Status (bitmap)
/// </summary>
/// <param name="newValues">Oggetto valori da aggiornare (from HMI)</param>
/// <param name="nMaxParamWrite">num max parametri da scrivere singolarmente</param>
/// <param name="delayParamWrite">delay in scriottura multi parametri singoli</param>
/// <returns></returns>
public abstract CmsError PLC_W_IO_DO_Reset(Dictionary<int, bool> newValues);
/// <summary>
/// Reset MULTIPLE Digital Out FORCED Status (bitmap)
/// </summary>
/// <param name="newValues">Oggetto valori da aggiornare (from HMI)</param>
/// <param name="nMaxParamWrite">num max parametri da scrivere singolarmente</param>
/// <param name="delayParamWrite">delay in scriottura multi parametri singoli</param>
/// <returns></returns>
public abstract CmsError PLC_W_IO_AO_Reset(Dictionary<int, bool> newValues);
/// <summary>
/// Reset ALL DO / AO forced bitmap
/// </summary>
/// <returns></returns>
public abstract CmsError PLC_W_IO_ResetAll();
#endregion THERMO high level data
File diff suppressed because it is too large Load Diff
+37
View File
@@ -166,6 +166,30 @@ namespace CMS_CORE_Library.Utils
return String.Empty;
}
internal static Dictionary<int, bool> convToDictIntBol(List<ushort> origVal)
{
Byte[] byteArray = null;
// Convert List<int16> into Byte Array
byteArray = origVal.SelectMany(j => BitConverter.GetBytes(j)).ToArray();
// converto a bit
BitArray bitArr = new BitArray(byteArray);
Dictionary<int, bool> answ = new Dictionary<int, bool>();
for (int i = 0; i < bitArr.Count; i++)
{
answ.Add(i, bitArr[i]);
}
return answ;
}
internal static Dictionary<int, int> convToDictIntInt(List<short> origVal)
{
Dictionary<int, int> answ = new Dictionary<int, int>();
for (int i = 0; i < origVal.Count; i++)
{
answ.Add(i, origVal[i]);
}
return answ;
}
// Convert one integer in array of bools
internal static bool[] IntToBits(int val)
{
@@ -316,6 +340,19 @@ namespace CMS_CORE_Library.Utils
return (b & (1 << bitNumber)) != 0;
}
public static int SetBitOne(this int value, int position)
{
// Set a bit at position to 1.
return value |= (1 << position);
}
public static int SetBitZero(this int value, int position)
{
// Set a bit at position to 0.
return value & ~(1 << position);
}
public static CultureInfo GetCultureFromThreeLetter(string threeLetter)
{
// Get culture info from three letter iso standard