Merge branch 'feature/S7Net' into develop

This commit is contained in:
Samuele Locatelli
2020-10-24 16:08:50 +02:00
2 changed files with 108 additions and 29 deletions
+16 -4
View File
@@ -685,17 +685,29 @@ namespace CMS_CORE_Library
/// <returns></returns>
public abstract CmsError PLC_WWarmerChSetpHmi(Dictionary<int, int> newData);
/// <summary>
/// Set current Warmers Channels ThermocamSetpoints (°C)
/// Set current Warmers Channels Temperature Set as reference (°C)
/// </summary>
/// <param name="newData"></param>
/// <returns></returns>
public abstract CmsError PLC_WWarmerChTCamSetp(Dictionary<int, double> newData);
public abstract CmsError PLC_WWarmerChTCamTempSet(Dictionary<int, double> newData);
/// <summary>
/// Set current Warmers Channels Thermocam read (actual) value (°C)
/// Set current Warmers Channels Thermocam LAST READ value (°C)
/// </summary>
/// <param name="newData"></param>
/// <returns></returns>
public abstract CmsError PLC_WWarmerChTCamActual(Dictionary<int, double> newData);
public abstract CmsError PLC_WWarmerChTCamTempAct(Dictionary<int, double> newData);
/// <summary>
/// Set current Warmers Channels as enabled/disabled for working with thermo camera data
/// </summary>
/// <param name="newData"></param>
/// <returns></returns>
public abstract CmsError PLC_WWarmerChTCamEnab(Dictionary<int, bool> newData);
/// <summary>
/// Set ThermoCamera mode
/// </summary>
/// <param name="enableTCam"></param>
/// <returns></returns>
public abstract CmsError PLC_WTCamMode(bool enableTCam);
/// <summary>
/// Set current Warmers Channels reflector's data
/// </summary>
+92 -25
View File
@@ -2368,12 +2368,12 @@ namespace CMS_CORE_Library.S7Net
if (!useCache)
{
// refresh abilitazione canale x thermoCam | Write
refreshRiscTermoCamAbilit();
refreshRiscTermoCamEnab();
// refresh ultima temp canale letta da thermoCam | Write
refreshRiscTermoCamTempAct();
// refresh temp canale impostata x thermoCam | Write
refreshRiscTermoCamTempSet();
}
}
// copio lista act in output
currWarmerChannelList = ThermoWarmChannels;
@@ -3087,7 +3087,7 @@ namespace CMS_CORE_Library.S7Net
/// <summary>
/// Refresh dati ThermoCamera dal PLC x area command/status
/// </summary>
private void refreshRiscTermoCamAbilit()
private void refreshRiscTermoCamEnab()
{
// leggo DB664 x abilitazione ch alla termocamera
List<byte> currMem = new List<byte>();
@@ -3129,7 +3129,7 @@ namespace CMS_CORE_Library.S7Net
else
{
libraryError = S7_PLC_EMPTY_READ;
}
}
}
/// <summary>
/// Refresh Canali Riscaldi: SetPoint HMI
@@ -3351,20 +3351,22 @@ namespace CMS_CORE_Library.S7Net
return NO_ERROR;
}
/// <summary>
/// Set current Warmers Channels ThermocamSetpoints (°C)
/// Set current Warmers Channels Temp REF Setpoints (1/10 °C)
/// </summary>
/// <param name="updtCh"></param>
/// <returns></returns>
public override CmsError PLC_WWarmerChTCamSetp(Dictionary<int, double> newData)
public override CmsError PLC_WWarmerChTCamTempSet(Dictionary<int, double> newData)
{
// FIXME TODO serve nuova area termocamera
#if false
// valori in 1/10 di °C
int dataScale = 10;
// memory area
byte[] newMem = new byte[newData.Count];
List<byte> currMem = new List<byte>();
short[] newMem = new short[newData.Count];
// 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);
// 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;
@@ -3373,15 +3375,16 @@ namespace CMS_CORE_Library.S7Net
// update only given data...
foreach (var item in newData)
{
newMem[item.Key - 1] = (byte)item.Value;
// attenzione: effettua scalatura dati!
newMem[item.Key - 1] = (short)(dataScale * 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);
libraryError = MEM_RWShortList(W, 0, TCAM_TEMP_REQ_DATA.MemType, TCAM_TEMP_REQ_DATA.Address, TCAM_TEMP_REQ_DATA.SubAddress, TCAM_TEMP_REQ_DATA.Size, ref currMem);
if (libraryError.IsError())
return libraryError;
#endif
return libraryError;
return NO_ERROR;
}
@@ -3390,16 +3393,18 @@ namespace CMS_CORE_Library.S7Net
/// </summary>
/// <param name="updtCh"></param>
/// <returns></returns>
public override CmsError PLC_WWarmerChTCamActual(Dictionary<int, double> newData)
public override CmsError PLC_WWarmerChTCamTempAct(Dictionary<int, double> newData)
{
// FIXME TODO serve nuova area termocamera
#if false
// valori in 1/10 di °C
int dataScale = 10;
// memory area
byte[] newMem = new byte[newData.Count];
List<byte> currMem = new List<byte>();
short[] newMem = new short[newData.Count];
// 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_ACT_DATA.MemType, TCAM_TEMP_ACT_DATA.Address, TCAM_TEMP_ACT_DATA.SubAddress, TCAM_TEMP_ACT_DATA.Size, ref currMem);
// 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;
@@ -3408,18 +3413,80 @@ namespace CMS_CORE_Library.S7Net
// update only given data...
foreach (var item in newData)
{
newMem[item.Key - 1] = (byte)item.Value;
// attenzione: effettua scalatura dati!
newMem[item.Key - 1] = (short)(dataScale * 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);
libraryError = MEM_RWShortList(W, 0, TCAM_TEMP_ACT_DATA.MemType, TCAM_TEMP_ACT_DATA.Address, TCAM_TEMP_ACT_DATA.SubAddress, TCAM_TEMP_ACT_DATA.Size, ref currMem);
if (libraryError.IsError())
return libraryError;
return NO_ERROR;
}
/// <summary>
/// Set current Warmers Channels as enabled/disabled for working with thermo camera data
/// </summary>
/// <param name="newData"></param>
/// <returns></returns>
public override CmsError PLC_WWarmerChTCamEnab(Dictionary<int, bool> newData)
{
// leggo DB664 x abilitazione ch alla termocamera
bool[] newMem = new bool[TCAM_CH_ENAB_DATA.Size * 8];
List<byte> currMem = new List<byte>();
// read actual data on memory...
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);
if (libraryError.IsError())
return libraryError;
// Convert int into to true/false array
BitArray bArray = new BitArray(currMem.ToArray());
bArray.CopyTo(newMem, 0);
// update only given data...
foreach (var item in newData)
{
newMem[item.Key - 1] = item.Value;
}
// return as list...
currMem = boolsToByteArray(newMem).ToList();
// scrivo sul PLC array di byte...
libraryError = MEM_RWByteList(W, 0, TCAM_CH_ENAB_DATA.MemType, TCAM_CH_ENAB_DATA.Address, TCAM_CH_ENAB_DATA.SubAddress, 0, TCAM_CH_ENAB_DATA.Size, ref currMem);
if (libraryError.IsError())
return libraryError;
return NO_ERROR;
}
public static byte[] boolsToByteArray(bool[] bits)
{
byte[] ret = new byte[(bits.Length - 1) / 8 + 1];
bits.CopyTo(ret, 0);
return ret;
}
/// <summary>
/// Set ThermoCamera mode
/// </summary>
/// <param name="enableTCam"></param>
/// <returns></returns>
public override CmsError PLC_WTCamMode(bool enableTCam)
{
#if false
#endif
return NO_ERROR;
}
/// <summary>
/// Set current Warmers Channels reflector's data
/// </summary>