nc connection management
This commit is contained in:
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
||||
<alarm-list></alarm-list>
|
||||
<div id="back-view">
|
||||
<div id="nc-hmi">
|
||||
|
||||
|
||||
<img id="nc-hmi-img" src="assets/images/Siemens_Placeholder.jpg" v-if="isSiemens">
|
||||
<img id="nc-hmi-img" src="assets/images/Fanuc_Placeholder.jpg" v-if="isFanuc">
|
||||
<img id="nc-hmi-img" src="assets/images/Osai_Placeholder.jpg" v-if="isOsai">
|
||||
@@ -93,6 +93,7 @@ export default {
|
||||
);
|
||||
|
||||
|
||||
|
||||
this.hub = new Hub();
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -3,7 +3,7 @@ import AlarmsModelActionsInterface from "../store/alarms.store"
|
||||
import { signalr } from "src/@types/signalr.alarms";
|
||||
import { store, alarmsModelActions, machineStatusActions, machineInfoActions } from "src/store";
|
||||
import { alarmDetail } from "src/modules/alarms";
|
||||
|
||||
import iziToast, { IziToastSettings } from "izitoast";
|
||||
|
||||
declare let $: any;
|
||||
|
||||
@@ -19,6 +19,8 @@ function recalcArrayId(prefix: string, alarms: Array<signalr.genericAlarm>, proc
|
||||
|
||||
export class Hub {
|
||||
|
||||
static _ncConnectionNotificationVisible: boolean = false;
|
||||
|
||||
private _hub: any;
|
||||
|
||||
constructor() {
|
||||
@@ -28,10 +30,29 @@ export class Hub {
|
||||
// Registro le callback;
|
||||
this._hub.client.alarms = this.manageAlarmsCallbacks;
|
||||
this._hub.client.powerOn = this.managePowerCallbacks;
|
||||
this._hub.client.ncNetworkStatus = Hub.manageNcStatus;
|
||||
|
||||
$.connection.hub.start();
|
||||
}
|
||||
|
||||
private static manageNcStatus(status) {
|
||||
|
||||
if (Hub._ncConnectionNotificationVisible && status.connected) {
|
||||
machineStatusActions.setNcConnectionStatus(store, status.connected);
|
||||
var toast = document.querySelector('#ncConnection') as any;
|
||||
(iziToast as any).hide(toast);
|
||||
Hub._ncConnectionNotificationVisible = false;
|
||||
}
|
||||
|
||||
if (!Hub._ncConnectionNotificationVisible && !status.connected) {
|
||||
machineStatusActions.setNcConnectionStatus(store, status.connected);
|
||||
iziToast.warning({
|
||||
id: "ncConnection", timeout: false, toastOnce: true, theme: "dark", title: "nc offline", close: false
|
||||
} as IziToastSettings);
|
||||
Hub._ncConnectionNotificationVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private manageAlarmsCallbacks(alarms: signalr.alarmMessage) {
|
||||
|
||||
recalcArrayId("cn", alarms.NcAlarms);
|
||||
@@ -57,6 +78,9 @@ export class Hub {
|
||||
|
||||
private managePowerCallbacks(power: signalr.powerMessage) {
|
||||
|
||||
// Receiving messages so NC is connected
|
||||
Hub.manageNcStatus({ connected: true});
|
||||
|
||||
// Pre-power on
|
||||
machineStatusActions.setAirPressureAlarm(store, power.prePowerOn.AirPressure.Active);
|
||||
machineStatusActions.setPowerAlarm(store, power.prePowerOn.PowerOn.Active);
|
||||
@@ -70,7 +94,6 @@ export class Hub {
|
||||
machineStatusActions.setWaterJet1Alarm(store, power.postPowerOn.WaterjetPump.Active);
|
||||
}
|
||||
|
||||
|
||||
public Hello() {
|
||||
this._hub.server.hello();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ declare let cmsClient: any;
|
||||
export interface AreaModel {
|
||||
name: string,
|
||||
enabled: boolean,
|
||||
allowExternalBrowser: boolean
|
||||
allowExternalBrowser: boolean,
|
||||
ncNeeded: boolean
|
||||
}
|
||||
|
||||
export interface MachineStatusModel {
|
||||
@@ -19,6 +20,8 @@ export interface MachineStatusModel {
|
||||
waterJet1Alarm: boolean,
|
||||
waterJet2Alarm: boolean,
|
||||
|
||||
ncReady: boolean,
|
||||
|
||||
areasConfiguration: Array<AreaModel>
|
||||
}
|
||||
|
||||
@@ -34,6 +37,7 @@ export interface MachineStatusActions {
|
||||
setWaterJet2Alarm(context, status: boolean)
|
||||
setAreasConfg(context, areas: Array<AreaModel>)
|
||||
isAreaEnabled(context, areaname: string)
|
||||
setNcConnectionStatus(context, connected: boolean)
|
||||
}
|
||||
|
||||
export const machineStatusStore = {
|
||||
@@ -50,6 +54,8 @@ export const machineStatusStore = {
|
||||
waterJet1Alarm: false,
|
||||
waterJet2Alarm: false,
|
||||
|
||||
ncReady: false,
|
||||
|
||||
areasConfiguration: []
|
||||
|
||||
} as MachineStatusModel,
|
||||
@@ -104,9 +110,12 @@ export const machineStatusStore = {
|
||||
setWaterJet2Alarm(context, status: boolean) {
|
||||
context.commit('UpdateMachineStatus', { waterJet2Alarm: status });
|
||||
},
|
||||
setAreasConfg(context, areas: Array<AreaModel>){
|
||||
setAreasConfg(context, areas: Array<AreaModel>) {
|
||||
context.commit('UpdateMachineStatus', { areasConfiguration: areas });
|
||||
},
|
||||
setNcConnectionStatus(context, connected: boolean){
|
||||
context.commit('UpdateMachineStatus', { ncReady: connected });
|
||||
},
|
||||
isAreaEnabled(context, areaname: string): boolean {
|
||||
let inBrowser = (typeof cmsClient == "undefined");
|
||||
|
||||
@@ -116,10 +125,11 @@ export const machineStatusStore = {
|
||||
if (areaconfig.hasOwnProperty(key)) {
|
||||
const config = areaconfig[key];
|
||||
|
||||
if(config && config.name && config.name == areaname)
|
||||
{
|
||||
if(inBrowser) return config.allowExternalBrowser && config.enabled;
|
||||
return config.enabled;
|
||||
if (config && config.name && config.name == areaname) {
|
||||
if(!context.state.machineStatus.ncReady && config.ncNeeded) return false;
|
||||
|
||||
if (inBrowser) return config.allowExternalBrowser && config.enabled;
|
||||
return config.enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user