Cleanup & fix library for S7 (methods for modules)
This commit is contained in:
@@ -551,7 +551,7 @@ namespace CMS_CORE_Library.Models
|
||||
}
|
||||
|
||||
|
||||
public class RecipeModule
|
||||
public class ModuleBlock
|
||||
{
|
||||
public ushort Id { get; set; } = 0;
|
||||
public uint EstimatedDuration { get; set; } = 0;
|
||||
@@ -564,27 +564,20 @@ namespace CMS_CORE_Library.Models
|
||||
public bool HasError { get; set; } = false;
|
||||
}
|
||||
|
||||
public class RecipeWarmerUp
|
||||
public class WarmerChannel
|
||||
{
|
||||
public ushort Id { get; set; } = 0;
|
||||
public byte IdRefrector { get; set; } = 0;
|
||||
public double MinCurrent { get; set; } = 0;
|
||||
public ushort IdChannel { get; set; } = 0;
|
||||
public byte SetpointThermoCam { get; set; } = 0;
|
||||
public byte SetpointPLC { get; set; } = 0;
|
||||
public byte ChStatus { get; set; } = 0;
|
||||
public byte PercWork { get; set; } = 0;
|
||||
public byte PercAct { get; set; } = 0;
|
||||
}
|
||||
|
||||
public class RecipeWarmerDown
|
||||
{
|
||||
public ushort Id { get; set; } = 0;
|
||||
public byte SetpointHMI { get; set; } = 0;
|
||||
}
|
||||
|
||||
|
||||
public class RecipeProdInfo
|
||||
public class ProdInfo
|
||||
{
|
||||
public ushort NumTarget { get; set; } = 0;
|
||||
public ushort NumDOne { get; set; } = 0;
|
||||
public ushort NumDone { get; set; } = 0;
|
||||
public uint TimeWarm { get; set; } = 0;
|
||||
public uint TimeVent { get; set; } = 0;
|
||||
public uint TimeVacuum { get; set; } = 0;
|
||||
@@ -598,7 +591,7 @@ namespace CMS_CORE_Library.Models
|
||||
public double MouldEnergyIN { get; set; } = 0;
|
||||
}
|
||||
|
||||
public class RecipeProdCycle
|
||||
public class ProdCycle
|
||||
{
|
||||
public ushort Status { get; set; } = 0;
|
||||
public ushort MessageId { get; set; } = 0;
|
||||
|
||||
@@ -29,34 +29,6 @@ namespace CMS_CORE_Library.S7Net
|
||||
private const string NcNotFound = "Missing response";
|
||||
private const string NcNotFound2 = "networking error";
|
||||
private const string NcNotFound3 = "Nc not Connected";
|
||||
#if false
|
||||
private const int IDMinPLCMessage = 700000;
|
||||
private const int IDMaxPLCMessage = 799999;
|
||||
private const int IDMinChannel = 10000;
|
||||
private const int IDMaxChannel = 19999;
|
||||
#endif
|
||||
|
||||
#if false
|
||||
// Siemens Path Constants
|
||||
private const string MAX_CHANNEL_NO_PATH = "/Nck/Configuration/maxnumChannels";
|
||||
|
||||
private const string CONF_CHANNEL_NO_PATH = "/Nck/Configuration/numChannels";
|
||||
private const string NC_TYPE_PATH = "/Nck/Configuration/nckType";
|
||||
private const string NC_VERSION_PATH = "/Nck/Configuration/nckVersion";
|
||||
private const string LANGUAGE_PATH = "/Nck/Configuration/anLanguageOnHmi";
|
||||
private const string SERIAL_NO_PATH = "/Nck/State/hwProductSerialNrL";
|
||||
private const string NC_TIME_PATH = "/Nck/State/sysTimeBCD";
|
||||
private const string NC_GENERIC_MODE_PATH = "/Bag/State/opMode";
|
||||
private const string NC_GENERIC_STATE_PATH = "/Channel/State/chanStatus";
|
||||
private const string JOG_INCR_PATH = "/Channel/GeometricAxis/actIncrVal";
|
||||
private const string ADVANCED_JOG_PATH = "/Channel/State/machFunc";
|
||||
private const string RELATIVE_POS_PATH = "/Channel/GeometricAxis/actToolBasPosEN";
|
||||
private const string UNIT_OF_MEASURE = "/Nck/Configuration/basicLengthUnit";
|
||||
|
||||
private const string ACT_PROG_LINES_PATH = "/Channel/ProgramInfo/actPartProgram";
|
||||
private const string ACT_PROG_NAME_PATH = "/Channel/ProgramPointer/progName";
|
||||
#endif
|
||||
|
||||
|
||||
// Global Variables
|
||||
private static DateTime Last_Static_Read;
|
||||
@@ -66,41 +38,15 @@ namespace CMS_CORE_Library.S7Net
|
||||
private static string Cnc_SftVersion;
|
||||
private static string Cnc_SeriesNum;
|
||||
private static string Cms_MachNumber;
|
||||
private static string PlcRirm_SeriesNum;
|
||||
private static string PlcFirmware_SerialNum;
|
||||
private static uint ConfChannelNo;
|
||||
private static string UnitOfMeasure;
|
||||
|
||||
// Alarms data
|
||||
private static Dictionary<int, string> PlcMessages;
|
||||
|
||||
|
||||
#if false
|
||||
|
||||
private const string PLC_MESSAGES_FILE_PATH = "C:\\Program Files (x86)\\Siemens\\MotionControl\\oem\\sinumerik\\hmi\\lng\\";
|
||||
private static readonly string AXES_FILE_PATH = AppDomain.CurrentDomain.BaseDirectory + "\\Config\\axesConfig.xml";
|
||||
|
||||
// axis data
|
||||
private static List<AxisModel> AxesData = new List<AxisModel>();
|
||||
|
||||
public static uint MAX_AXES_FOR_PROCESS = 20;
|
||||
|
||||
// File paths
|
||||
public const string BASE_FILE_PATH = "//NC/";
|
||||
public const string NC_FILE_PATH = "MPF.DIR";
|
||||
|
||||
private static DataSvc AxesSvc;
|
||||
private static DataSvc SelectedProcessSvc;
|
||||
#endif
|
||||
|
||||
private static ushort SelectedProcess = 1;
|
||||
|
||||
#if false
|
||||
private static Dictionary<string, double> MachineAxesPosition = new Dictionary<string, double>();
|
||||
private static Dictionary<string, double> ToGoAxesPosition = new Dictionary<string, double>();
|
||||
private static Dictionary<string, double> InterpAxesPosition = new Dictionary<string, double>();
|
||||
private static Dictionary<string, double> ProgrammedAxisPosition = new Dictionary<string, double>();
|
||||
#endif
|
||||
|
||||
private bool EnableAlarms;
|
||||
private bool EnableHeaters;
|
||||
private bool EnableModules;
|
||||
@@ -111,7 +57,11 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
|
||||
// Dizionario parametri specifici per THERMO
|
||||
private static Dictionary<int, RecipeParam> thermoParamList;
|
||||
private static Dictionary<int, RecipeParam> ThermoParamList;
|
||||
private static Dictionary<int, ModuleBlock> ThermoModuleList;
|
||||
private static Dictionary<int, WarmerChannel> ThermoWarmChannels;
|
||||
private static ProdInfo ThermoProdInfo;
|
||||
private static ProdCycle ThermoProdCycle;
|
||||
|
||||
// connessione S7
|
||||
private CpuType tipoCpu = CpuType.S71500;
|
||||
@@ -125,7 +75,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#region Contructor & global methods
|
||||
#region Constructor & global methods
|
||||
|
||||
///<summary>
|
||||
///Instantiate The NC-S7Net Class
|
||||
@@ -135,21 +85,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
///<param name="ConnectionTimeOut">Send/Recieve timeout connection [mS]</param>
|
||||
public Nc_S7Net(string IpAddress, ushort RemotePort, ushort ConnectionTimeOut)
|
||||
{
|
||||
//Setup options
|
||||
this.EnableAlarms = true;
|
||||
this.EnableHeaters = true;
|
||||
this.EnableModules = true;
|
||||
this.EnableParameters = true;
|
||||
this.EnableProd = true;
|
||||
|
||||
this.EnableAxes = false;
|
||||
|
||||
// Setup parametri
|
||||
Ip = IpAddress;
|
||||
Port = RemotePort;
|
||||
// mesasggi generici PLC
|
||||
PlcMessages = new Dictionary<int, string>();
|
||||
thermoParamList = new Dictionary<int, RecipeParam>();
|
||||
initObjects(IpAddress, RemotePort, false, true, true, true, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -166,7 +102,22 @@ namespace CMS_CORE_Library.S7Net
|
||||
/// <param name="EnableProd">Enable Prod Svc</param>
|
||||
public Nc_S7Net(string IpAddress, ushort RemotePort, ushort ConnectionTimeOut, bool EnableAxes, bool EnableAlarms, bool EnableHeaters, bool EnableModules, bool EnableParameters, bool EnableProd)
|
||||
{
|
||||
//Setup options
|
||||
initObjects(IpAddress, RemotePort, EnableAxes, EnableAlarms, EnableHeaters, EnableModules, EnableParameters, EnableProd);
|
||||
}
|
||||
/// <summary>
|
||||
/// /Inizializzazione effettiva parametri classe
|
||||
/// </summary>
|
||||
/// <param name="IpAddress"></param>
|
||||
/// <param name="RemotePort"></param>
|
||||
/// <param name="EnableAxes"></param>
|
||||
/// <param name="EnableAlarms"></param>
|
||||
/// <param name="EnableHeaters"></param>
|
||||
/// <param name="EnableModules"></param>
|
||||
/// <param name="EnableParameters"></param>
|
||||
/// <param name="EnableProd"></param>
|
||||
private void initObjects(string IpAddress, ushort RemotePort, bool EnableAxes, bool EnableAlarms, bool EnableHeaters, bool EnableModules, bool EnableParameters, bool EnableProd)
|
||||
{
|
||||
// Setup options
|
||||
this.EnableAlarms = EnableAlarms;
|
||||
this.EnableAxes = EnableAxes;
|
||||
this.EnableHeaters = EnableHeaters;
|
||||
@@ -179,7 +130,12 @@ namespace CMS_CORE_Library.S7Net
|
||||
Port = RemotePort;
|
||||
// mesasggi generici PLC
|
||||
PlcMessages = new Dictionary<int, string>();
|
||||
thermoParamList = new Dictionary<int, RecipeParam>();
|
||||
// Init dati specifici Themo
|
||||
ThermoParamList = new Dictionary<int, RecipeParam>();
|
||||
ThermoModuleList = new Dictionary<int, ModuleBlock>();
|
||||
ThermoWarmChannels = new Dictionary<int, WarmerChannel>();
|
||||
ThermoProdCycle = new ProdCycle();
|
||||
ThermoProdInfo = new ProdInfo();
|
||||
}
|
||||
|
||||
public override CmsError NC_Connect()
|
||||
@@ -198,15 +154,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
if (currPLC.IsConnected)
|
||||
Connected = true;
|
||||
|
||||
#if false
|
||||
// InitializeSiemens objects
|
||||
if (this.EnableAxes)
|
||||
{
|
||||
if (AxesSvc == null)
|
||||
AxesSvc = new DataSvc();
|
||||
}
|
||||
#endif
|
||||
|
||||
// FARE TODO FIXME
|
||||
// Setup the alarms (with DB bitmap) --> PlcMessages
|
||||
|
||||
if (this.EnableAlarms)
|
||||
@@ -229,84 +177,6 @@ namespace CMS_CORE_Library.S7Net
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#if false
|
||||
private void ManageSelectedProcess(Guid guid, Item[] item, DataSvcStatus[] status)
|
||||
{
|
||||
SelectedProcess = 0;
|
||||
// Set selectedProcess
|
||||
for (int i = 0; i < item.Count(); i++)
|
||||
{
|
||||
if (status[i].Ok)
|
||||
{
|
||||
if (Convert.ToBoolean(item[i].Value))
|
||||
SelectedProcess = (ushort)(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.EnableAxes)
|
||||
{
|
||||
// Clean listener
|
||||
AxesSvc.UnSubscribe(ManageAxes);
|
||||
|
||||
if (SelectedProcess > 0)
|
||||
{
|
||||
List<AxisModel> axesConf = new List<AxisModel>();
|
||||
|
||||
AXES_RAxesNames(SelectedProcess, ref AxesData);
|
||||
|
||||
List<Item> axesData = new List<Item>();
|
||||
foreach (var conf in AxesData)
|
||||
{
|
||||
// Setup the items to be subscribed
|
||||
// Machine
|
||||
axesData.Add(new Item() { Path = string.Format("/Nck/{0}[u{1},{2}]", "MachineAxis/actToolBasePos", SelectedProcess, conf.Id), SymbolicName = conf.Id.ToString() });
|
||||
// Programmed
|
||||
axesData.Add(new Item() { Path = string.Format("/Channel/{0}[u{1},{2}]", "GeometricAxis/cmdProgPos", SelectedProcess, conf.Id), SymbolicName = conf.Id.ToString() });
|
||||
// Interp
|
||||
axesData.Add(new Item() { Path = string.Format("/Channel/{0}[u{1},{2}]", "GeometricAxis/actToolEdgeCenterPos", SelectedProcess, conf.Id), SymbolicName = conf.Id.ToString() });
|
||||
// Dist to go
|
||||
axesData.Add(new Item() { Path = string.Format("/Channel/{0}[u{1},{2}]", "MachineAxis/toolBaseDistToGo", SelectedProcess, conf.Id), SymbolicName = conf.Id.ToString() });
|
||||
}
|
||||
|
||||
if (axesData.Count() > 0)
|
||||
// Subscribe to axis changes
|
||||
AxesSvc.Subscribe(ManageAxes, axesData.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ManageAxes(Guid guid, Item[] item, DataSvcStatus[] status)
|
||||
{
|
||||
lock (MachineAxesPosition)
|
||||
{
|
||||
lock (ProgrammedAxisPosition)
|
||||
{
|
||||
lock (InterpAxesPosition)
|
||||
{
|
||||
lock (ToGoAxesPosition)
|
||||
{
|
||||
MachineAxesPosition.Clear();
|
||||
ProgrammedAxisPosition.Clear();
|
||||
InterpAxesPosition.Clear();
|
||||
ToGoAxesPosition.Clear();
|
||||
|
||||
for (int i = 0; i < AxesData.Count(); i++)
|
||||
{
|
||||
if (status[i * 4].Ok)
|
||||
MachineAxesPosition.Add(item[i * 4].SymbolicName, Convert.ToDouble(item[i * 4].Value));
|
||||
if (status[i * 4 + 1].Ok)
|
||||
ProgrammedAxisPosition.Add(item[i * 4 + 1].SymbolicName, Convert.ToDouble(item[i * 4 + 1].Value));
|
||||
if (status[i * 4 + 2].Ok)
|
||||
InterpAxesPosition.Add(item[i * 4 + 2].SymbolicName, Convert.ToDouble(item[i * 4 + 2].Value));
|
||||
if (status[i * 4 + 3].Ok)
|
||||
ToGoAxesPosition.Add(item[i * 4 + 3].SymbolicName, Convert.ToDouble(item[i * 4 + 3].Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disconnect Method
|
||||
public override CmsError NC_Disconnect()
|
||||
@@ -2159,7 +2029,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
}
|
||||
|
||||
// copio lista act in output...
|
||||
currParamList = thermoParamList;
|
||||
currParamList = ThermoParamList;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -2169,7 +2039,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
// copio lista act in output...
|
||||
refreshMemRecipeParameter();
|
||||
refreshMemRecipeParameterRT();
|
||||
currParamList = thermoParamList;
|
||||
currParamList = ThermoParamList;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -2217,16 +2087,16 @@ namespace CMS_CORE_Library.S7Net
|
||||
if (currParam.Id > 0)
|
||||
{
|
||||
// update oggetto thermoParamList...
|
||||
if (thermoParamList.ContainsKey(currParam.Id))
|
||||
if (ThermoParamList.ContainsKey(currParam.Id))
|
||||
{
|
||||
thermoParamList[currParam.Id].Enabled = currParam.Enabled;
|
||||
thermoParamList[currParam.Id].HasError = currParam.HasError;
|
||||
thermoParamList[currParam.Id].Visible = currParam.Visible;
|
||||
thermoParamList[currParam.Id].ValueAct = currParam.ValueAct;
|
||||
ThermoParamList[currParam.Id].Enabled = currParam.Enabled;
|
||||
ThermoParamList[currParam.Id].HasError = currParam.HasError;
|
||||
ThermoParamList[currParam.Id].Visible = currParam.Visible;
|
||||
ThermoParamList[currParam.Id].ValueAct = currParam.ValueAct;
|
||||
}
|
||||
else
|
||||
{
|
||||
thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct });
|
||||
ThermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2253,17 +2123,17 @@ namespace CMS_CORE_Library.S7Net
|
||||
if (currParam.Id > 0)
|
||||
{
|
||||
// update oggetto thermoParamList...
|
||||
if (thermoParamList.ContainsKey(currParam.Id))
|
||||
if (ThermoParamList.ContainsKey(currParam.Id))
|
||||
{
|
||||
thermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI;
|
||||
thermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC;
|
||||
thermoParamList[currParam.Id].ValMax = currParam.ValMax;
|
||||
thermoParamList[currParam.Id].ValMin = currParam.ValMin;
|
||||
thermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure;
|
||||
ThermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI;
|
||||
ThermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC;
|
||||
ThermoParamList[currParam.Id].ValMax = currParam.ValMax;
|
||||
ThermoParamList[currParam.Id].ValMin = currParam.ValMin;
|
||||
ThermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure;
|
||||
}
|
||||
else
|
||||
{
|
||||
thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure });
|
||||
ThermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4124,7 +3994,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
Cms_MachNumber = "0000"; // matricola macchina, DB604.DBB6720..6723
|
||||
Cnc_SftVersion = "SMC000"; // versione SW del firmware PLC/CNC | DB604.DBB6724..6745
|
||||
Cnc_SeriesNum = "SMC111"; // seriale PLC/CNC | DB604.DBB6746..6763
|
||||
PlcRirm_SeriesNum = "V.0.0.0"; // seriale PLC/CNC | DB604.DBB6764..6767
|
||||
PlcFirmware_SerialNum = "V.0.0.0"; // seriale PLC/CNC | DB604.DBB6764..6767
|
||||
UnitOfMeasure = MILLIMETERS;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user