Files
m.heisig 2d11c43579 Added minimal functionality for Robot teaching
- Added minimal HMI
- Added possibility to open and close all chamber doors
2026-01-17 09:20:39 +01:00

1 line
7.2 KiB
JavaScript

var __runInitializers=this&&this.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=this&&this.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(void 0!==f&&"function"!=typeof f)throw new TypeError("Function expected");return f}for(var _,kind=contextIn.kind,key="getter"===kind?"get":"setter"===kind?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]="access"===p?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])("accessor"===kind?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if("accessor"===kind){if(void 0===result)continue;if(null===result||"object"!=typeof result)throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&("field"===kind?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};import{TcHmiControl}from"Beckhoff.TwinCAT.HMI.Framework/index.esm.js";let TcHmiStateImage=(()=>{var _a;let ___onResolverForStateListWatchCallback_decorators,_classSuper=TcHmiControl.Control,_instanceExtraInitializers=[];return class TcHmiStateImage extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onResolverForStateListWatchCallback_decorators=[(_a=TcHmi).CallbackMethod.bind(_a)],__esDecorate(this,null,___onResolverForStateListWatchCallback_decorators,{kind:"method",name:"__onResolverForStateListWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForStateListWatchCallback"in obj,get:obj=>obj.__onResolverForStateListWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static#tchmiFQN="TcHmi.Controls.Beckhoff."+this.name;constructor(element,pcElement,attrs){super(element,pcElement,attrs)}__elementImage=__runInitializers(this,_instanceExtraInitializers);__state;__stateList;__fallbackImage;__ignoreTypeSafety;__previnit(){if(super.__previnit(),this.__elementImage=this.__element[0].getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiStateImage-image")[0],!this.__elementImage)throw new Error("Invalid Template.html")}__init(){super.__init()}__attach(){super.__attach(),this.__handleState()}__detach(){super.__detach()}destroy(){this.__keepAlive||super.destroy()}__displayCurrentState(iconpath){this.__elementImage.style.visibility=""===iconpath?"hidden":"visible",this.__elementImage.src=tchmi_path(iconpath)}__handleState(){if(this.__stateList)for(let v of this.__stateList){if(tchmi_equal(v.state,this.__state,{convertPrimitives:this.__ignoreTypeSafety}))return this.__displayCurrentState(v.stateIcon),void(TCHMI_DESIGNER&&null===this.__elementImage.parentElement&&(this.__element[0].innerHTML="",this.__element[0].append(this.__elementImage)));if(this.__fallbackImage)this.__displayCurrentState(this.__fallbackImage),TCHMI_DESIGNER&&null===this.__elementImage.parentElement&&(this.__element[0].innerHTML="",this.__element[0].append(this.__elementImage));else if(this.__displayCurrentState(""),TCHMI_DESIGNER){const designerMessage=document.createElement("div");designerMessage.classList.add("tchmi-designer-control-message"),designerMessage.append("No configured fallbackImage.",document.createElement("br"),"Please add a fallback image for the case the current state is not defined in the state list."),this.__element[0].innerHTML="",this.__element[0].append(designerMessage)}}else if(this.__displayCurrentState(""),TCHMI_DESIGNER){const designerMessage=document.createElement("div");designerMessage.classList.add("tchmi-designer-control-message"),designerMessage.append("No configured StateList.",document.createElement("br"),"Please add definitions for states."),this.__element[0].innerHTML="",this.__element[0].append(designerMessage)}}setStateList(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("StateList"));let resolverInfo=this.__objectResolvers.get("stateList");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());let resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("StateList")?.type});this.__objectResolvers.set("stateList",{resolver,watchCallback:this.__onResolverForStateListWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForStateListWatchCallback)})}__onResolverForStateListWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("stateList"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__stateList)||(this.__stateList=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"StateList"}),this.__processStateList()):TcHmi.Log.Controls.error(this,TcHmiStateImage.#tchmiFQN,{Attribute:"StateList"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getStateList(){return this.__stateList}__processStateList(){this.__isAttached&&this.__handleState()}setState(valueNew){null===valueNew&&(valueNew=this.getAttributeDefaultValueInternal("State")),valueNew!==this.__state&&(this.__state=valueNew,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"State"}),this.__processState())}getState(){return this.__state}__processState(){this.__isAttached&&this.__handleState()}setFallbackImage(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("FallbackImage")),convertedValue!==this.__fallbackImage&&(this.__fallbackImage=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"FallbackImage"}),this.__processFallbackImage())}getFallbackImage(){return this.__fallbackImage}__processFallbackImage(){this.__isAttached&&this.__handleState()}setIgnoreTypeSafety(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("IgnoreTypeSafety")),convertedValue!==this.__ignoreTypeSafety&&(this.__ignoreTypeSafety=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IgnoreTypeSafety"}),this.__processIgnoreTypeSafety())}getIgnoreTypeSafety(){return this.__ignoreTypeSafety}__processIgnoreTypeSafety(){this.__isAttached&&this.__handleState()}}})();TcHmi.Controls.registerEx("TcHmiStateImage","TcHmi.Controls.Beckhoff",TcHmiStateImage,{injectInGlobalObject:!0});export{TcHmiStateImage as Control};