Merge branch 'feature/S7Net' into develop
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace CMS_CORE_Library.Models
|
||||
{
|
||||
@@ -103,7 +104,7 @@ namespace CMS_CORE_Library.Models
|
||||
/// </summary>
|
||||
public class AxisRT
|
||||
{
|
||||
public short Id { get; set; } = 0;
|
||||
public int Id { get; set; } = 0;
|
||||
public double Position { get; set; } = 0;
|
||||
public double Speed { get; set; } = 0;
|
||||
public double Load { get; set; } = 0;
|
||||
@@ -129,16 +130,43 @@ namespace CMS_CORE_Library.Models
|
||||
{
|
||||
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 short Id { get; set; } = 0;
|
||||
public int errorCode { get; set; } = 0;
|
||||
public int movPhase { get; set; } = 0;
|
||||
public int statusCode { get; set; } = 0;
|
||||
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)
|
||||
{
|
||||
@@ -148,11 +176,15 @@ namespace CMS_CORE_Library.Models
|
||||
|
||||
if (Id != item.Id)
|
||||
return false;
|
||||
if (errorCode != item.errorCode)
|
||||
if (ErrorCode != item.ErrorCode)
|
||||
return false;
|
||||
if (movPhase != item.movPhase)
|
||||
if (MovPhase != item.MovPhase)
|
||||
return false;
|
||||
if (statusCode != item.statusCode)
|
||||
if (StatusWord != item.StatusWord)
|
||||
return false;
|
||||
if (ControlWord != item.ControlWord)
|
||||
return false;
|
||||
if (TargetPos != item.TargetPos)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -626,6 +626,18 @@ namespace CMS_CORE_Library
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_WAckPzProdEnd();
|
||||
|
||||
/// <summary>
|
||||
/// Get current Axis RT data
|
||||
/// </summary>
|
||||
/// <param name="currParamList"></param>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_RAxisRTList(ref Dictionary<int, ThermoModels.AxisRT> currAxisRT);
|
||||
/// <summary>
|
||||
/// Get current Axis Info data
|
||||
/// </summary>
|
||||
/// <param name="currParamList"></param>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_RAxisInfoList(ref Dictionary<int, ThermoModels.AxisInfo> currAxisInfo);
|
||||
/// <summary>
|
||||
/// Get current recipe parameter list
|
||||
/// </summary>
|
||||
|
||||
@@ -1072,7 +1072,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
// Read machine variable
|
||||
libraryError = MEM_RWDouble(R, 0, M156_RESPONSE_MEMORY.MemType, M156_RESPONSE_MEMORY.Address, M156_RESPONSE_MEMORY.SubAddress + (int)processId - 1, ref responseVal);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
return libraryError;
|
||||
// Parse line & get parameters
|
||||
value.Add(new M156InputIsNeededModel()
|
||||
{
|
||||
@@ -2073,6 +2073,116 @@ namespace CMS_CORE_Library.S7Net
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current Axis RT data
|
||||
/// </summary>
|
||||
/// <param name="currParamList"></param>
|
||||
/// <returns></returns>
|
||||
public override CmsError PLC_RAxisRTList(ref Dictionary<int, ThermoModels.AxisRT> currAxisRT)
|
||||
{
|
||||
CmsError libraryError = NO_ERROR;
|
||||
List<byte> currMem = new List<byte>();
|
||||
int packSize = 12;
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
libraryError = MEM_RWByteList(R, 0, AXES_RTDATA.MemType, AXES_RTDATA.Address, AXES_RTDATA.SubAddress, 0, AXES_RTDATA.Size, ref currMem);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
// controllo SE ho dati...
|
||||
if (currMem.Count > 0)
|
||||
{
|
||||
// converto a blocchi di byte...
|
||||
byte[] memArray = currMem.ToArray();
|
||||
for (int i = 0; i < AXES_RTDATA.Size / packSize; i++)
|
||||
{
|
||||
ThermoModels.AxisRT currData = new ThermoModels.AxisRT(i + 1, memArray.Skip(i * packSize).Take(packSize).ToArray());
|
||||
// solo se ID > 0...
|
||||
if (currData.Id > 0)
|
||||
{
|
||||
// update oggetto thermoParamList...
|
||||
if (currAxisRT.ContainsKey(currData.Id))
|
||||
{
|
||||
try
|
||||
{
|
||||
currAxisRT[currData.Id].Position = currData.Position;
|
||||
currAxisRT[currData.Id].Speed = currData.Speed;
|
||||
currAxisRT[currData.Id].Load = currData.Load;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
currAxisRT.Add(currData.Id, currData);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return libraryError;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get current Axis Info data
|
||||
/// </summary>
|
||||
/// <param name="currParamList"></param>
|
||||
/// <returns></returns>
|
||||
public override CmsError PLC_RAxisInfoList(ref Dictionary<int, ThermoModels.AxisInfo> currAxisInfo)
|
||||
{
|
||||
CmsError libraryError = NO_ERROR;
|
||||
#if false
|
||||
CmsError libraryError = NO_ERROR;
|
||||
List<byte> currMem = new List<byte>();
|
||||
int packSize = 8;
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
libraryError = MEM_RWByteList(R, 0, PARAMETER_RT_DATA.MemType, PARAMETER_RT_DATA.Address, PARAMETER_RT_DATA.SubAddress, 0, PARAMETER_RT_DATA.Size, ref currMem);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
// controllo SE ho dati...
|
||||
if (currMem.Count > 0)
|
||||
{
|
||||
// converto a blocchi di 8 byte...
|
||||
byte[] memArray = currMem.ToArray();
|
||||
for (int i = 0; i < PARAMETER_RT_DATA.Size / packSize; i++)
|
||||
{
|
||||
PlcParamRT currParam = new PlcParamRT(memArray.Skip(i * packSize).Take(packSize).ToArray());
|
||||
// solo se ID > 0...
|
||||
if (currParam.Id > 0)
|
||||
{
|
||||
// update oggetto thermoParamList...
|
||||
if (ThermoParamList.ContainsKey(currParam.Id))
|
||||
{
|
||||
try
|
||||
{
|
||||
ThermoParamList[currParam.Id].Enabled = currParam.Enabled;
|
||||
ThermoParamList[currParam.Id].HasError = currParam.HasError;
|
||||
ThermoParamList[currParam.Id].Visible = currParam.Visible;
|
||||
ThermoParamList[currParam.Id].ValueAct = currParam.ValueAct;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
ThermoParamList.Add(currParam.Id, new ThermoModels.RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct });
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return libraryError;
|
||||
}
|
||||
/// <summary>
|
||||
/// read current recipe parameter list
|
||||
/// </summary>
|
||||
@@ -4747,7 +4857,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
// assi
|
||||
internal static MEMORY_CELL AXES_RTDATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 615, 0, 768);
|
||||
internal static MEMORY_CELL AXES_INFO = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 616, 0, 640);
|
||||
internal static MEMORY_CELL AXES_INFO = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 616, 0, 896);
|
||||
|
||||
// aree Parametri
|
||||
internal static MEMORY_CELL PARAMETER_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 600, 20, 8000);
|
||||
|
||||
Reference in New Issue
Block a user