From ef139a236504510917d7c86a7f15907a3dca780d Mon Sep 17 00:00:00 2001 From: Thermo_SIM Date: Sun, 21 Mar 2021 19:28:07 +0100 Subject: [PATCH] Fix THermoprophet --- Thermo.Active.Core/ThreadsFunctions.cs | 6 ++ Thermo.Active.Model/Constants.cs | 1 + .../DTOModels/ThWarmers/DTOThermoCam.cs | 9 ++- Thermo.Active.NC/NcAdapter.cs | 8 +++ Thermo.Active.Utils/languages/IT.xml | 2 +- Thermo.Active.Utils/languages/en.xml | 2 +- Thermo.Active/Listeners/ListenersHandler.cs | 4 ++ .../Listeners/SignalR/SignalRListener.cs | 7 +++ .../base-components/thermocamera.ts | 56 ++++++++++++++++++- .../base-components/thermocamera.vue | 7 ++- .../components/base-components/warmers.ts | 1 - Thermo.Active/wwwroot/src/services/hub.ts | 8 ++- .../wwwroot/src/services/warmersService.ts | 4 ++ 13 files changed, 105 insertions(+), 10 deletions(-) diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 21054cb2..e17c4931 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -390,13 +390,19 @@ public static class ThreadsFunctions } // salvo dati temp sul PLC ncAdapter.WriteRecipeWarmChTCamTempAct(actualTemp); + NcAdapter.lastImageTaken = DateTime.Now; // give PLC strobe for uploaded Actual TEMP from image ncAdapter.SendTCamImageReadyStrb(); + + + MessageServices.Current.Publish(SEND_NEWTCAMIMAGE, null, NcAdapter.lastImageTaken); + } } // salvo status thermocam... NcAdapter.cameraIsConnected = TCCom.CameraIsConnected; + } else RestoreConnection(); diff --git a/Thermo.Active.Model/Constants.cs b/Thermo.Active.Model/Constants.cs index faa86d2b..b4f113c8 100644 --- a/Thermo.Active.Model/Constants.cs +++ b/Thermo.Active.Model/Constants.cs @@ -104,6 +104,7 @@ namespace Thermo.Active.Model public const string SEND_AXIS_INFO = "SEND_AXIS_INFO"; public const string SEND_CHANNELS_IO_DATA = "SEND_CHANNELS_IO_DATA"; + public const string SEND_NEWTCAMIMAGE = "SEND_NEWTCAMIMAGE"; public const string SEND_CMSCONNECT_GW_REBOOT_STATUS = "SEND_CMSCONNECT_GW_REBOOT_STATUS"; public const string SEND_ERROR_TO_UI = "SEND_ERROR_TO_UI"; public const string SEND_EXPIRED_MAINTENANCES_DATA = "SEND_EXPIRED_MAINTENANCES_DATA"; diff --git a/Thermo.Active.Model/DTOModels/ThWarmers/DTOThermoCam.cs b/Thermo.Active.Model/DTOModels/ThWarmers/DTOThermoCam.cs index 95270743..c28c2a07 100644 --- a/Thermo.Active.Model/DTOModels/ThWarmers/DTOThermoCam.cs +++ b/Thermo.Active.Model/DTOModels/ThWarmers/DTOThermoCam.cs @@ -40,6 +40,11 @@ namespace Thermo.Active.Model.DTOModels.ThWarmers /// public bool ThermoOptionActive { get; set; } = false; + /// + /// Data ultima acquisizione + /// + public DateTime LastTakenImage { get; set; } = new DateTime(0); + #endregion Public Properties #region Public Methods @@ -64,7 +69,9 @@ namespace Thermo.Active.Model.DTOModels.ThWarmers return false; if (RangeTemperature != item.RangeTemperature) return false; - + if (LastTakenImage != item.LastTakenImage) + return false; + return true; } diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index e150eb99..62bc2a11 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -140,6 +140,11 @@ namespace Thermo.Active.NC /// public static bool cameraIsConnected = false; + /// + /// Indica se la FLIR camera รจ connessa + /// + public static DateTime lastImageTaken = new DateTime(0); + #endregion Public Fields #region Public Constructors @@ -3172,6 +3177,9 @@ namespace Thermo.Active.NC }; // controllo se connessa currTCamData.ThermoCamConnected = cameraIsConnected; + + // DataOra ultima immagine scattata + currTCamData.LastTakenImage = lastImageTaken; } return libraryError; } diff --git a/Thermo.Active.Utils/languages/IT.xml b/Thermo.Active.Utils/languages/IT.xml index 9b0aa567..da101661 100644 --- a/Thermo.Active.Utils/languages/IT.xml +++ b/Thermo.Active.Utils/languages/IT.xml @@ -431,5 +431,5 @@ In errore: Allarme test freno: Nessuno - Tutti + Tutti \ No newline at end of file diff --git a/Thermo.Active.Utils/languages/en.xml b/Thermo.Active.Utils/languages/en.xml index 19a0a095..48d74428 100644 --- a/Thermo.Active.Utils/languages/en.xml +++ b/Thermo.Active.Utils/languages/en.xml @@ -431,5 +431,5 @@ In Error: Brake Test Alarm: None - All + All \ No newline at end of file diff --git a/Thermo.Active/Listeners/ListenersHandler.cs b/Thermo.Active/Listeners/ListenersHandler.cs index f9b7a02e..1bb3cc2f 100644 --- a/Thermo.Active/Listeners/ListenersHandler.cs +++ b/Thermo.Active/Listeners/ListenersHandler.cs @@ -68,6 +68,10 @@ namespace Thermo.Active.Listeners { SignalRListener.SendThermoChannelsIoData(a); })); + infos.Add(MessageServices.Current.Subscribe(SEND_NEWTCAMIMAGE, (a, b) => + { + SignalRListener.SendTCamNewImage(a); + })); infos.Add(MessageServices.Current.Subscribe(SEND_ACTIVE_PROGRAM_DATA, (a, b) => { SignalRListener.SendActiveProgramData(a); diff --git a/Thermo.Active/Listeners/SignalR/SignalRListener.cs b/Thermo.Active/Listeners/SignalR/SignalRListener.cs index 4fd0c6ad..41ec6578 100644 --- a/Thermo.Active/Listeners/SignalR/SignalRListener.cs +++ b/Thermo.Active/Listeners/SignalR/SignalRListener.cs @@ -611,6 +611,13 @@ namespace Thermo.Active.Listeners.SignalR } } + public static void SendTCamNewImage(object newImageDate) + { + DateTime imageDate = (DateTime)newImageDate; + var context = GlobalHost.ConnectionManager.GetHubContext(); + context.Clients.Group("ncData").newThermoCamImage(newImageDate); + } + public static void SetGatewayRebootStatus(object status) { string msg = status.ToString(); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.ts index ba96d595..00910449 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.ts @@ -8,6 +8,8 @@ import { warmersService } from "@/services/warmersService"; import { awaiter } from '@/_base'; import termoModal from "./thermoProphet-modal.vue"; import { ModalHelper } from '@/components/modals'; +import moment from "moment"; +import { messageService } from "src/_base"; @Component({ name: "thermocamera", components: { @@ -26,12 +28,18 @@ export default class Thermocamera extends Vue { btnModeEnabled = true; thermoImageUri: string = "/thermoprophet/colored/_last.jpg"; - thermoImageOpacity: number = 0; + thermoImageOpacity: number = 1; resistanceMode = 0; + timeoutLastTakenImage = 0; + timeCamDiff = " "; + TCamData: { imageSize: { x: number, y: number }, rangeTemperature: { max: number, min: number }, + thermoCamConnected: boolean, + thermoOptionActive: boolean, + lastTakenImage: Date, } = null; @Watch("warmers", { deep: true }) @@ -53,6 +61,13 @@ export default class Thermocamera extends Vue { async mounted() { this.ChangedTemps(); this.TCamData = await warmersService.GetTCamData(); + + messageService.subscribeToChannel("new-thermocam-image", (args)=>{ + if(this.TCamData){ + console.log(args) + this.TCamData.lastTakenImage = args[0]; + } + }); } get selectedChannels(): Warmers.IChannel[] { @@ -75,6 +90,45 @@ export default class Thermocamera extends Vue { // return (store.state.warmers.tCamStatus.thermoCamMode); // } + get thermocameraImageUrl(){ + if(!this.TCamData || moment(this.TCamData.lastTakenImage).year() <= 2000) + return "/thermoprophet/colored/_last.jpg?lastmod=NOTAVAILABLE"; + return "/thermoprophet/colored/_last.jpg?lastmod=" + this.TCamData.lastTakenImage; + } + + get thermocameraImageOk(): boolean { + clearInterval(this.timeoutLastTakenImage); + this.timeCamDiff = " " + + if(!this.TCamData) + return false; + + if(moment(this.TCamData.lastTakenImage).year() > 2000) + { + this.lastTakenImageFuncion(); + this.timeoutLastTakenImage = setInterval(this.lastTakenImageFuncion,10000); + return true; + + } + return false; + } + + lastTakenImageFuncion(){ + var today = moment(new Date()); + var end = moment(this.TCamData.lastTakenImage); + var diff = (moment.duration(today.diff(end)) as any)._data; + var seconds = diff.seconds; + var minutes = diff.minutes; + var hours = diff.hours; + + if(hours >0) + this.timeCamDiff = hours + "h " + minutes + "m "; + else if(minutes >0) + this.timeCamDiff = minutes + "m " + seconds + "s "; + else + this.timeCamDiff = seconds + "s"; + } + get thermocameraModeBTN(): boolean { return (store.state.warmers.tCamStatus.thermoCamOnOff); } diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.vue b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.vue index 736c8881..f2f970d5 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.vue +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.vue @@ -111,8 +111,8 @@ @methodChanged="m => selectionMethod = m" :recipe="recipe" :resistanceMode="resistanceMode" - thermoImage="/thermoprophet/colored/_last.jpg" - :thermoImageVisible="thermocameraModeBTN" + :thermoImage="thermocameraImageUrl" + :thermoImageVisible="true" :thermoImageOpacity="thermoImageOpacity" :isThermoProphet="true" > @@ -128,8 +128,9 @@ + {{timeCamDiff}} i.row == row)) return this.resistances.filter(i => i.row == row); } diff --git a/Thermo.Active/wwwroot/src/services/hub.ts b/Thermo.Active/wwwroot/src/services/hub.ts index a77898a9..7ffaa307 100644 --- a/Thermo.Active/wwwroot/src/services/hub.ts +++ b/Thermo.Active/wwwroot/src/services/hub.ts @@ -124,8 +124,7 @@ export class Hub { this._hub.client.gaugeData = Hub.gaugeData; this._hub.client.axisInfo = Hub.axisInfoData; this._hub.client.channelsIoVal = Hub.channelsIOUpdate; - - + this._hub.client.newThermoCamImage = Hub.newThermoCamImage; this._hub.client.logout = this.logout; @@ -219,6 +218,11 @@ export class Hub { recipeActions.setOverview(store, data); } + + public static newThermoCamImage(data) { + messageService.publishToChannel("new-thermocam-image", data); + } + public static prodPanelData(data) { prodActions.setProdPanel(store, data); } diff --git a/Thermo.Active/wwwroot/src/services/warmersService.ts b/Thermo.Active/wwwroot/src/services/warmersService.ts index 6648a066..b7f45409 100644 --- a/Thermo.Active/wwwroot/src/services/warmersService.ts +++ b/Thermo.Active/wwwroot/src/services/warmersService.ts @@ -71,10 +71,14 @@ export class WarmersService extends baseRestService { let result = await this.Get<{ imageSize: { x: number, y: number }, rangeTemperature: { max: number, min: number }, + thermoCamConnected: boolean, + thermoOptionActive: boolean, + lastTakenImage: Date, }>((await this.BASE_URL()) + "TCamData", true); return result; } + async GetMeasurePoints(setname: string): Promise { return await this.Get((await this.BASE_URL()) + `getMeasurePoints?setName=${setname}`, true); }