diff --git a/Client/Client.csproj b/Client/Client.csproj index a15ba069..f818321b 100644 --- a/Client/Client.csproj +++ b/Client/Client.csproj @@ -35,7 +35,7 @@ true full false - bin\Debug\ + ..\Thermo.Active\bin\Client_Debug\x64\ DEBUG;TRACE prompt 4 @@ -44,7 +44,7 @@ AnyCPU pdbonly true - bin\Release\ + ..\Thermo.Active\bin\Client\x64\ TRACE prompt 4 diff --git a/Thermo.Active.Config/Config/risk2007.xml b/Thermo.Active.Config/Config/risk2007.xml index 61a34c58..eb701d6f 100644 --- a/Thermo.Active.Config/Config/risk2007.xml +++ b/Thermo.Active.Config/Config/risk2007.xml @@ -1,933 +1,268 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 2 diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs index d4efe01d..c3f9dd08 100644 --- a/Thermo.Active.Config/ServerConfigController.cs +++ b/Thermo.Active.Config/ServerConfigController.cs @@ -281,8 +281,6 @@ namespace Thermo.Active.Config public static void ReadServerConfig() { - //CalculateHash(SERVER_CONFIG_PATH); - // Get server file handler XDocument xmlConfigFile = GetXmlHandlerWithValidator(SERVER_CONFIG_SCHEMA_PATH, SERVER_CONFIG_PATH); diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index ec9b6762..e44f248b 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -428,10 +428,13 @@ public static class ThreadsFunctions // Send through signalR MessageServices.Current.Publish(SEND_EXPIRED_MAINTENANCES_DATA, null, expiredMaintenances); + // 2020.06.18 commentata da indicazione di Lucio Maranta (NON dovrebbe servire ora) +#if false //Manage Candies libraryError = ncAdapter.ManageCandies(); if (libraryError.errorCode != 0) - ManageLibraryError(libraryError); + ManageLibraryError(libraryError); +#endif } else RestoreConnection(); diff --git a/Thermo.Active.Database/Controllers/ProdInfoController.cs b/Thermo.Active.Database/Controllers/ProdInfoController.cs index 6bdb9c0d..8aececeb 100644 --- a/Thermo.Active.Database/Controllers/ProdInfoController.cs +++ b/Thermo.Active.Database/Controllers/ProdInfoController.cs @@ -22,7 +22,11 @@ namespace Thermo.Active.Database.Controllers // Clear database context dbCtx.Dispose(); } - + /// + /// Get record by NumDone + /// + /// + /// public ProdInfoModel FindByNumDone(int num) { return dbCtx @@ -30,7 +34,12 @@ namespace Thermo.Active.Database.Controllers .Where(x => x.NumDone == num) .SingleOrDefault(); } - + /// + /// Get historical paginated data from DB (DESC ordered + /// + /// + /// + /// public List GetPaginated(int numStart, int numRecord) { // cehck numEnd @@ -41,10 +50,26 @@ namespace Thermo.Active.Database.Controllers return dbCtx .ProdInfo .Where(x => x.NumDone <= numStart && x.NumDone > numEnd) - .OrderByDescending(x=> x.NumDone) + .OrderByDescending(x => x.DtEvent) .ToList(); } - + /// + /// Create new prodInfo record on DB + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// public ProdInfoModel Create(short NumTarget, short NumDone, int TimeWarm, int TimeVent, int TimeVacuum, int TimeCycleGross, int TimeCycleNet, double MaterialTempEndWarm, double MaterialTempEndVent, double MoldTemp, double VacuumReadVal, double MouldEnergyOUT, double MouldEnergyIN) { // Create database machine model @@ -101,22 +126,28 @@ namespace Thermo.Active.Database.Controllers // save! dbCtx.SaveChanges(); - + answ = true; } return answ; } + /// + /// Process table and delete all record (truncate) + /// + /// + public bool PurgeAll() + { + bool answ = false; - //public void UpdateMachineName(int id, string name) - //{ - // // Find machine by id - // MachineModel machine = FindById(id); - // if (machine != null) - // { - // // Update machine name - // machine.Model = name; - // dbCtx.SaveChanges(); - // } - //} + try + { + dbCtx + .Database + .ExecuteSqlCommand("TRUNCATE TABLE prodInfo"); + } + catch + { } + return answ; + } } } \ No newline at end of file diff --git a/Thermo.Active.Model/Constants.cs b/Thermo.Active.Model/Constants.cs index cf7ea9a0..a59316f2 100644 --- a/Thermo.Active.Model/Constants.cs +++ b/Thermo.Active.Model/Constants.cs @@ -198,7 +198,8 @@ namespace Thermo.Active.Model } // Config File Names - public static readonly string BASE_PATH = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + public static readonly string BASE_PATH = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + //public static readonly string BASE_PATH = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).Replace("\\lib", ""); #if DEBUG public static readonly string CLIENT_PATH_64 = BASE_PATH + @"\Client_Debug\x64\" + CLIENT_EXE_NAME; diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 72d510e8..93730913 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -332,8 +332,9 @@ namespace Thermo.Active.NC if (ThermoProdUpdatedStr) { // se si in questo caso leggo il record produzione... - - /// e quindi lo gestisco (salvataggio su DB) + cmsError = ReadProdInfoData(out ThermoModels.ProdInfoModel prodInfoData); + if (cmsError.IsError()) + return cmsError; // do il bit di ack cmsError = numericalControl.PLC_WAckProdUpdate(); @@ -341,7 +342,6 @@ namespace Thermo.Active.NC else { // se è zero e il mio ack fosse 1 --> resetto il mio! - } return cmsError; @@ -1250,11 +1250,13 @@ namespace Thermo.Active.NC { prodInfoData = new ThermoModels.ProdInfoModel(); CmsError cmsError = numericalControl.PLC_RProdInfo(ref prodInfoData); + if (cmsError.IsError()) + return cmsError; // do comparison with old record and if changed --> persist on DB! - if(lastProdInfoData != null) + if (lastProdInfoData != null) { - if(!prodInfoData.Equals(lastProdInfoData)) + if (!prodInfoData.Equals(lastProdInfoData)) { // save on DB! using (ProdInfoController prodInfoController = new ProdInfoController()) @@ -1286,7 +1288,7 @@ namespace Thermo.Active.NC prodInfoDataList = results.Select(x => new ThermoModels.ProdInfoModel() { NumTarget = x.NumTarget, - NumDone= x.NumDone, + NumDone = x.NumDone, TimeWarm = x.TimeWarm, TimeVent = x.TimeVent, TimeVacuum = x.TimeVacuum, @@ -1303,10 +1305,38 @@ namespace Thermo.Active.NC return cmsError; } + /// + /// Update requested prod quantity + /// + /// + /// + /// + public CmsError UpdateProdInfoData(short numTarget, bool newWorkOrder) + { + CmsError cmsError = NO_ERROR; + + using (ProdInfoController prodInfoController = new ProdInfoController()) + { + // registro dati aggiornati sul PLC + cmsError = numericalControl.PLC_WProdInfo(numTarget, newWorkOrder); + if (cmsError.IsError()) + return cmsError; + + // svuoto il db se richiesto reset... + if (newWorkOrder) + { + prodInfoController.PurgeAll(); + } + } + + return cmsError; + } public CmsError ReadProdCycleData(out ThermoModels.ProdCycleModel prodCycleData) { prodCycleData = new ThermoModels.ProdCycleModel(); CmsError cmsError = numericalControl.PLC_RProdCycle(ref prodCycleData); + if (cmsError.IsError()) + return cmsError; return cmsError; } @@ -1369,12 +1399,24 @@ namespace Thermo.Active.NC Min = paramPLC.ValMin / item.ScaleFactor, Max = paramPLC.ValMax / item.ScaleFactor }; + + // FIXME TODO impostato a true in debug x testing UI +#if DEBUG + currStatus = new RPStatus() + { + Visible = true, + Enabled = true, + HasError = false + }; + +#else currStatus = new RPStatus() { Visible = paramPLC.Visible, Enabled = paramPLC.Enabled, HasError = paramPLC.HasError }; +#endif // calcolo intero oggetto currParam = new DTORecipeParam() { diff --git a/Thermo.Active/App.config b/Thermo.Active/App.config index 38af01d7..64ce6002 100644 --- a/Thermo.Active/App.config +++ b/Thermo.Active/App.config @@ -4,153 +4,154 @@ https://go.microsoft.com/fwlink/?LinkId=301879 --> - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Thermo.Active/Controllers/WebApi/ProdController.cs b/Thermo.Active/Controllers/WebApi/ProdController.cs index dc22cae4..e9175d5d 100644 --- a/Thermo.Active/Controllers/WebApi/ProdController.cs +++ b/Thermo.Active/Controllers/WebApi/ProdController.cs @@ -128,13 +128,13 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } - //// scrivo sul PLC il comando strobe richiesta AUTO! - //CmsError cmsError = ncAdapter.StrobeMode(Model.DTOModels.ThermoProd.Mode.SETUP); - //if (cmsError.IsError()) - //{ - // ThermoActiveLogger.LogError($"RequestSetup error | {cmsError.exception}"); - // return BadRequest(cmsError.localizationKey); - //} + // scrivo sul PLC il comando strobe richiesta AUTO! + CmsError cmsError = ncAdapter.UpdateProdInfoData((short)requestQty, newWorkOrder); + if (cmsError.IsError()) + { + ThermoActiveLogger.LogError($"StartProd error | {cmsError.exception}"); + return BadRequest(cmsError.localizationKey); + } // ritorno solo fatto! return Ok(); diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index 571c3a75..fcb83848 100644 --- a/Thermo.Active/Properties/AssemblyInfo.cs +++ b/Thermo.Active/Properties/AssemblyInfo.cs @@ -31,4 +31,4 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.8.9")] +[assembly: AssemblyVersion("0.9.4")] diff --git a/Thermo.Active/Thermo.Active.csproj b/Thermo.Active/Thermo.Active.csproj index cf54d815..09c57b7d 100644 --- a/Thermo.Active/Thermo.Active.csproj +++ b/Thermo.Active/Thermo.Active.csproj @@ -16474,4 +16474,10 @@ --> + + + + + + \ No newline at end of file diff --git a/Thermo.Active/packages.config b/Thermo.Active/packages.config index aed0d197..356c243e 100644 --- a/Thermo.Active/packages.config +++ b/Thermo.Active/packages.config @@ -33,6 +33,7 @@ +