WebAPI x status TCam
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Thermo.Active.Model.DTOModels.ThWarmers
|
||||
{
|
||||
public class DTOThermoCam
|
||||
{
|
||||
/// <summary>
|
||||
/// Opzione ThermoCamera (set by PLC)
|
||||
/// </summary>
|
||||
public bool ThermoOptionActive { get; set; } = false;
|
||||
/// <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>
|
||||
/// Equality test for class object
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is DTOThermoCam item))
|
||||
return false;
|
||||
|
||||
if (ThermoOptionActive != item.ThermoOptionActive)
|
||||
return false;
|
||||
if (ThermoCamMode != item.ThermoCamMode)
|
||||
return false;
|
||||
if (ThermoCamOnOff != item.ThermoCamOnOff)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash gen
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,6 +118,7 @@
|
||||
<Compile Include="DTOModels\ThRecipe\DTORecipeStatus.cs" />
|
||||
<Compile Include="DTOModels\ThRecipe\LiveData.cs" />
|
||||
<Compile Include="DTOModels\ThSchedulModels\DTOSchedTaskModels.cs" />
|
||||
<Compile Include="DTOModels\ThWarmers\DTOThermoCam.cs" />
|
||||
<Compile Include="DTOModels\ThWarmers\DTOWarmers.cs" />
|
||||
<Compile Include="DTOModels\ThRecipe\DTORecipeParam.cs" />
|
||||
<Compile Include="DTOModels\ThRecipe\DTORecipeConfigModel .cs" />
|
||||
|
||||
@@ -2699,6 +2699,24 @@ namespace Thermo.Active.NC
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
public CmsError ReadTCamData(out DTOThermoCam currTCamData)
|
||||
{
|
||||
CmsError libraryError = NO_ERROR;
|
||||
currTCamData = new DTOThermoCam();
|
||||
// solo x S7...
|
||||
if (NcConfig.NcVendor == NC_VENDOR.S7NET)
|
||||
{
|
||||
numericalControl.PLC_RWarmerTCamData(out ThermoModels.ThermoCam currPlcTCamData);
|
||||
currTCamData = new DTOThermoCam()
|
||||
{
|
||||
ThermoOptionActive = currPlcTCamData.ThermoOptionActive,
|
||||
ThermoCamMode = currPlcTCamData.ThermoCamMode,
|
||||
ThermoCamOnOff = currPlcTCamData.ThermoCamOnOff
|
||||
};
|
||||
}
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all warmers data by channel
|
||||
/// </summary>
|
||||
@@ -2736,7 +2754,7 @@ namespace Thermo.Active.NC
|
||||
ActualPerc = currPlcWarmers[x.IdChannel].PercAct,
|
||||
MaxPower = x.MaxPower
|
||||
}).ToList();
|
||||
|
||||
|
||||
// preparo output
|
||||
foreach (var item in warmersConfig)
|
||||
{
|
||||
|
||||
@@ -190,13 +190,38 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
libraryError = ncAdapter.ReadWarmers(false, out Dictionary<int, DTOWarmers> currWarmers);
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}");
|
||||
ThermoActiveLogger.LogError($"GetCurrentWarmersChannels error | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
return Ok(currWarmers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current status related to ThermoCamera
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Route("TCamData"), HttpGet]
|
||||
public IHttpActionResult GetCurrentTCamData()
|
||||
{
|
||||
// Try connection
|
||||
CmsError libraryError = ncAdapter.Connect();
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentTCamData | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
libraryError = ncAdapter.ReadTCamData(out DTOThermoCam currTCamData);
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"GetCurrentTCamData error | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
return Ok(currTCamData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resistance setup info
|
||||
/// </summary>
|
||||
@@ -386,6 +411,34 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
// ritorno solo fatto!
|
||||
return Ok();
|
||||
}
|
||||
/// <summary>
|
||||
/// Set ThermoCam On/Off
|
||||
/// </summary>
|
||||
/// <param name="setTCamOn"></param>
|
||||
/// <returns></returns>
|
||||
[Route("setTCamOn"), HttpPut]
|
||||
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
|
||||
public IHttpActionResult SetTCamOn(bool setTCamOn)
|
||||
{
|
||||
// scrive su CommandWord attivazione funzione ThermoCam
|
||||
// Try connection
|
||||
CmsError libraryError = ncAdapter.Connect();
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"NC Not connected! | setTCamOn | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
// scrivo sul PLC
|
||||
libraryError = ncAdapter.SetTCamActiv(setTCamOn);
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"setTCamOn error | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
// ritorno solo fatto!
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simulate Flir image req from PLC
|
||||
|
||||
Reference in New Issue
Block a user