Files
infineon_plc/Packages/Beckhoff.TwinCAT.HMI.Controls.14.4.1/runtimes/native1.12-tchmi/dist/TcHmiRecipeSelect/TcHmiRecipeSelect.esm.js
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
27 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";import{SelectRecipePrompt}from"./SelectRecipePrompt.js";import{TextAndButtonsPrompt}from"../Helpers/TcHmiPopups/TextAndButtonsPrompt.js";import{PathDisplay}from"../Helpers/TcHmiDirectoryBrowser/PathDisplay.js";let TcHmiRecipeSelect=(()=>{var _a;let ___onRecipeClick_decorators,___onActivatePressed_decorators,___onTeachPressed_decorators,___onResolverForAllowedRecipeTypesWatchCallback_decorators,___onRecipeListWatch_decorators,_classSuper=TcHmiControl.Control,_instanceExtraInitializers=[];return class TcHmiRecipeSelect extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onRecipeClick_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate",earlyReturnValue:Promise.resolve()})],___onActivatePressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate",earlyReturnValue:Promise.resolve()})],___onTeachPressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate",earlyReturnValue:Promise.resolve()})],___onResolverForAllowedRecipeTypesWatchCallback_decorators=[(_a=TcHmi).CallbackMethod.bind(_a)],___onRecipeListWatch_decorators=[TcHmi.EventHandler()],__esDecorate(this,null,___onRecipeClick_decorators,{kind:"method",name:"__onRecipeClick",static:!1,private:!1,access:{has:obj=>"__onRecipeClick"in obj,get:obj=>obj.__onRecipeClick},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onActivatePressed_decorators,{kind:"method",name:"__onActivatePressed",static:!1,private:!1,access:{has:obj=>"__onActivatePressed"in obj,get:obj=>obj.__onActivatePressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onTeachPressed_decorators,{kind:"method",name:"__onTeachPressed",static:!1,private:!1,access:{has:obj=>"__onTeachPressed"in obj,get:obj=>obj.__onTeachPressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForAllowedRecipeTypesWatchCallback_decorators,{kind:"method",name:"__onResolverForAllowedRecipeTypesWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForAllowedRecipeTypesWatchCallback"in obj,get:obj=>obj.__onResolverForAllowedRecipeTypesWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onRecipeListWatch_decorators,{kind:"method",name:"__onRecipeListWatch",static:!1,private:!1,access:{has:obj=>"__onRecipeListWatch"in obj,get:obj=>obj.__onRecipeListWatch},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)}__elementTemplateRoot=__runInitializers(this,_instanceExtraInitializers);__elementSelectedRecipe;__elementPathBox;__buttonActivate;__buttonTeach;__selectRecipePrompt;__serverDomain;__serverInterval;__allowedRecipeTypes;__promptBeforeActivating;__promptBeforeTeaching;__confirmationPrompt=null;__unwatchRecipeList=null;__unwatchRecipeManagementDomain=null;__watchRecipeConditions={extensionLoaded:!1,userHasRights:!1};__activeRecipesSubscriptionId=null;__watchActiveRecipeConditions={extensionLoaded:!1,userHasRights:!1};__symbolAccessSubscriptionId=null;__symbolAccess={"{0}.Config":TcHmi.Server.ACCESS.NONE,"{0}.ActivateRecipe":TcHmi.Server.ACCESS.NONE,"{0}.ReadFromTarget":TcHmi.Server.ACCESS.NONE,"{0}.UpdateRecipe":TcHmi.Server.ACCESS.NONE,"{0}.GetActiveRecipes":TcHmi.Server.ACCESS.NONE};__selectedRecipe=null;__isEnabledLock={locked:!1,unlockValue:null};__localizedElements=new Map;__localizationReader=void 0;__previnit(){super.__previnit();const elementTemplateRoot=this.__element[0].querySelector(".TcHmi_Controls_Beckhoff_TcHmiRecipeSelect-template"),elementSelectedRecipe=this.__element[0].querySelector(".TcHmi_Controls_Beckhoff_TcHmiRecipeSelect-selected-recipe"),elementPathBox=this.__element[0].querySelector("div.TcHmi_Controls_Beckhoff_TcHmiRecipeSelect-path-box");if(!elementTemplateRoot||!elementSelectedRecipe||!elementPathBox)throw new Error("Invalid Template.html");this.__elementTemplateRoot=elementTemplateRoot,this.__elementSelectedRecipe=elementSelectedRecipe,this.__elementPathBox=elementPathBox;const buttonActivate=TcHmi.Controls.get(this.__id+"_ButtonActivate"),buttonTeach=TcHmi.Controls.get(this.__id+"_ButtonTeach");if(!buttonActivate||!buttonTeach)throw new Error("Controls in Template.html were not instantiated");this.__buttonActivate=buttonActivate,this.__buttonTeach=buttonTeach;const pathDisplay=new PathDisplay(this.__elementPathBox,this);this.__selectRecipePrompt=new SelectRecipePrompt(pathDisplay,this),this.__selectRecipePrompt.setTexts({headerText:this.__expandLocalizationSymbol("Header_Recipes"),noRecipesText:this.__expandLocalizationSymbol("Popup_Text_NoRecipes"),buttonTextOk:this.__expandLocalizationSymbol("Button_Text_Ok"),buttonTextCancel:this.__expandLocalizationSymbol("Button_Text_Cancel")});const localizedElements=this.__element[0].querySelectorAll("[data-tchmi-localized-content-key]");for(const element of localizedElements){const localizeKey=element.dataset.tchmiLocalizedContentKey;localizeKey&&this.__localizedElements.set(element,{key:localizeKey})}this.__destroyOnDestroy.push(this.__localization.watch(data=>{if(data.error===TcHmi.Errors.NONE&&data.reader){this.__localizationReader=data.reader;for(const[element,info]of this.__localizedElements){let localizedText=data.reader.get(info.key);info.parameters&&(localizedText=tchmi_format_string(localizedText,...info.parameters)),element.textContent=tchmi_decode_control_characters(localizedText)}}}))}__init(){super.__init(),this.__destroyOnDestroy.push(TcHmi.EventProvider.registerDomEvent(this.__elementSelectedRecipe,"click",this.__onRecipeClick),TcHmi.EventProvider.registerDomEvent(this.__elementPathBox,"click",this.__onRecipeClick),TcHmi.EventProvider.register(this.__buttonActivate.getId()+".onPressed",this.__onActivatePressed),TcHmi.EventProvider.register(this.__buttonTeach.getId()+".onPressed",this.__onTeachPressed))}__attach(){super.__attach(),this.__selectRecipePrompt.resume(),this.__lockIsEnabled(),this.__updateRecipeWatches(),this.__updateSymbolAccessSubscription()}__detach(){super.__detach(),this.__updateRecipeWatches(!0),this.__updateSymbolAccessSubscription(!0)}destroy(){this.__keepAlive||super.destroy()}__addLocalizedElement(element,key,...parameters){let info={key};if(0!==parameters.length&&(info.parameters=parameters),this.__localizedElements.set(element,info),this.__localizationReader){let localizedText=this.__localizationReader.get(key);info.parameters&&(localizedText=tchmi_format_string(localizedText,...info.parameters)),element.textContent=tchmi_decode_control_characters(localizedText)}}__removeLocalizedElement(element){this.__localizedElements.delete(element)}async __onRecipeClick(_event){if(this.__symbolAccess["{0}.Config"]!==TcHmi.Server.ACCESS.NONE)try{const result=await this.__selectRecipePrompt.prompt();result.isOk&&this.__select(result.value.name)}catch(e){}}__select(fullName){fullName!==this.__selectedRecipe?.toString()&&(this.__selectedRecipe=new TcHmi.ObjectPath(fullName),this.__removeLocalizedElement(this.__elementSelectedRecipe),this.__elementSelectedRecipe.textContent=this.getSelectedRecipeName(),this.__buttonActivate.setIsEnabled(!0),this.__buttonTeach.setIsEnabled(!0),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"SelectedRecipeFullName"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"SelectedRecipeName"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"SelectedRecipePath"}),this.__updateActiveRecipesSubscription(null,null,!0))}__unselect(){null!==this.__selectedRecipe&&(this.__selectedRecipe=null,this.__addLocalizedElement(this.__elementSelectedRecipe,this.__elementSelectedRecipe.dataset.tchmiLocalizedContentKey??""),this.__buttonActivate.setIsEnabled(!1),this.__buttonTeach.setIsEnabled(!1),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"SelectedRecipeFullName"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"SelectedRecipeName"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"SelectedRecipePath"}),this.__updateActiveRecipesSubscription(null,null,!0))}__getConfirmationPrompt(headerKey,contentKey){return this.__confirmationPrompt||(this.__confirmationPrompt=new TextAndButtonsPrompt({yes:{value:!0,attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_Yes")}},no:{value:!1,attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_No")}}},this),this.__confirmationPrompt.setBackgroundAction({close:!0,action:"no"})),this.__confirmationPrompt.setTexts({headerText:this.__expandLocalizationSymbol(headerKey),contentText:this.__expandLocalizationSymbol(contentKey)}),this.__confirmationPrompt}async __onActivatePressed(){if(!this.__selectedRecipe)return;if(this.__promptBeforeActivating){const confirmationPrompt=this.__getConfirmationPrompt("Popup_Header_ConfirmActivate","Popup_Text_ConfirmActivate");if(!await confirmationPrompt.prompt())return}const name=this.__selectedRecipe.toString();TcHmi.Server.RecipeManagement.activateEx(name,null,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error===TcHmi.Errors.NONE?(this.__watchActiveRecipeConditions.userHasRights&&this.__elementSelectedRecipe.classList.add("active"),TcHmi.EventProvider.raise(this.__id+".onRecipeActivated",{name})):TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,`Failed to activate recipe. ${TcHmi.Log.buildMessage(data.details)}`)})}async __onTeachPressed(){if(!this.__selectedRecipe)return;if(this.__promptBeforeTeaching){const confirmationPrompt=this.__getConfirmationPrompt("Popup_Header_ConfirmTeach","Popup_Text_ConfirmTeach");if(!await confirmationPrompt.prompt())return}const name=this.__selectedRecipe.toString();TcHmi.Server.RecipeManagement.teachEx(name,null,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error===TcHmi.Errors.NONE?(this.__watchActiveRecipeConditions.userHasRights&&this.__elementSelectedRecipe.classList.add("active"),TcHmi.EventProvider.raise(this.__id+".onRecipeTaught",{name})):TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,`Failed to teach recipe. ${TcHmi.Log.buildMessage(data.details)}`)})}setServerDomain(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("ServerDomain")),tchmi_equal(convertedValue,this.__serverDomain)||(this.__serverDomain=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"ServerDomain"}),this.__processServerDomain())}getServerDomain(){return this.__serverDomain}__processServerDomain(){this.__updateRecipeWatches(),this.__updateSymbolAccessSubscription()}setServerInterval(valueNew){let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("ServerInterval")),tchmi_equal(convertedValue,this.__serverInterval)||(this.__serverInterval=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"ServerInterval"}),this.__processServerInterval())}getServerInterval(){return this.__serverInterval}__processServerInterval(){this.__processServerDomain()}getSelectedRecipeFullName(){return this.__selectedRecipe?.toString()??null}getSelectedRecipeName(){return this.__selectedRecipe?.slice(-1).toString()??null}getSelectedRecipePath(){return this.__selectedRecipe?.slice(0,-1).toString()??null}setAllowedRecipeTypes(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew)??this.getAttributeDefaultValueInternal("AllowedRecipeTypes"),resolverInfo=this.__objectResolvers.get("allowedRecipeTypes");resolverInfo?.watchDestroyer?.(),resolverInfo?.resolver.destroy();let resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("AllowedRecipeTypes")?.type});this.__objectResolvers.set("allowedRecipeTypes",{resolver,watchCallback:this.__onResolverForAllowedRecipeTypesWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForAllowedRecipeTypesWatchCallback)})}__onResolverForAllowedRecipeTypesWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("allowedRecipeTypes"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.getAllowedRecipeTypes())||(this.__allowedRecipeTypes=data.value??this.getAttributeDefaultValueInternal("AllowedRecipeTypes"),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"AllowedRecipeTypes"}),this.__processAllowedRecipeTypes()):TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Attribute:"AllowedRecipeTypes"},TcHmi.Log.buildMessage(data.details),`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getAllowedRecipeTypes(){return this.__allowedRecipeTypes}__processAllowedRecipeTypes(){this.__unwatchRecipeList&&(this.__unwatchRecipeList(),this.__unwatchRecipeList=null,this.__updateRecipeListWatch(null,null))}setPromptBeforeActivating(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("PromptBeforeActivating")),tchmi_equal(convertedValue,this.__promptBeforeActivating)||(this.__promptBeforeActivating=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"PromptBeforeActivating"}))}getPromptBeforeActivating(){return this.__promptBeforeActivating}setPromptBeforeTeaching(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("PromptBeforeTeaching")),tchmi_equal(convertedValue,this.__promptBeforeTeaching)||(this.__promptBeforeTeaching=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"PromptBeforeTeaching"}))}getPromptBeforeTeaching(){return this.__promptBeforeTeaching}__updateRecipeWatches(unwatchOnly=!1){TCHMI_DESIGNER||(this.__unwatchRecipeList?.(),this.__unwatchRecipeList=null,this.__unwatchRecipeManagementDomain?.(),this.__unwatchRecipeManagementDomain=null,null!==this.__activeRecipesSubscriptionId&&(TcHmi.Server.unsubscribeEx(this.__activeRecipesSubscriptionId,null),this.__activeRecipesSubscriptionId=null),!unwatchOnly&&this.__isAttached&&this.__serverDomain?this.__unwatchRecipeManagementDomain=TcHmi.Server.Domains.watch(this.__serverDomain,data=>{data.error===TcHmi.Errors.NONE?"Loaded"===data.value?.state||"Initialized"===data.value?.state?(this.__unlockIsEnabled(),this.__updateRecipeListWatch(!0,null),this.__updateActiveRecipesSubscription(!0,null)):(this.__lockIsEnabled(),this.__updateRecipeListWatch(!1,null),this.__updateActiveRecipesSubscription(!1,null),TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,`Domain '${this.__serverDomain}' is not loaded. Please make sure the server extension is activated.`)):(this.__lockIsEnabled(),this.__updateRecipeListWatch(!1,null),this.__updateActiveRecipesSubscription(!1,null),TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,`Domain '${this.__serverDomain}' is not known. Please make sure the server extension is loaded and the domain name is correct. ${TcHmi.Log.buildMessage(data.details)}`))}):this.__selectRecipePrompt.setRecipeList(null))}__lockIsEnabled(){const unlockValue=this.__isEnabledLock.unlockValue;this.setIsEnabled(!1),this.__isEnabledLock.locked=!0,this.__isEnabledLock.unlockValue=unlockValue}__unlockIsEnabled(){this.__isEnabledLock.locked=!1,this.setIsEnabled(this.__isEnabledLock.unlockValue)}setIsEnabled(valueNew){this.__isEnabledLock.unlockValue=valueNew,this.__isEnabledLock.locked||super.setIsEnabled(valueNew)}__updateRecipeListWatch(extensionLoaded,userHasRights){if(TCHMI_DESIGNER)return;let conditionsChanged=!1;null!==extensionLoaded&&extensionLoaded!==this.__watchRecipeConditions.extensionLoaded&&(this.__watchRecipeConditions.extensionLoaded=extensionLoaded,conditionsChanged=!0),null!==userHasRights&&userHasRights!==this.__watchRecipeConditions.userHasRights&&(this.__watchRecipeConditions.userHasRights=userHasRights,conditionsChanged=!0),(conditionsChanged||null===this.__unwatchRecipeList)&&(this.__unwatchRecipeList?.(),this.__unwatchRecipeList=null,this.__isAttached&&this.__serverDomain&&this.__watchRecipeConditions.extensionLoaded&&this.__watchRecipeConditions.userHasRights?this.__unwatchRecipeList=TcHmi.Server.RecipeManagement.watchRecipeList({domain:this.__serverDomain,parallel:!0},this.__onRecipeListWatch):this.__selectRecipePrompt.setRecipeList(null))}__onRecipeListWatch(data){let recipes=null;if(data.error?TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,`Failed to list recipes of domain '${this.__serverDomain}'. Please make sure the domain is a recipe management extension. ${TcHmi.Log.buildMessage(data.details)}`):data.value?recipes=data.value:TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,`Failed to list recipes of domain '${this.__serverDomain}'. Please make sure the domain is a recipe management extension.`),recipes&&this.__allowedRecipeTypes?.length){const filter=folder=>{const filtered={};for(const[name,item]of Object.entries(folder))TcHmi.Server.RecipeManagement.isRecipe(item)?this.__allowedRecipeTypes.includes(item.recipeTypeName)&&(filtered[name]=item):filtered[name]=filter(item);return filtered};recipes=filter(recipes)}this.__selectRecipePrompt.setRecipeList(recipes);try{!this.__selectedRecipe||recipes&&this.__selectedRecipe.readFrom(recipes)||this.__unselect()}catch{this.__unselect()}}__updateActiveRecipesSubscription(extensionLoaded,userHasRights,recipeChanged=!1){if(TCHMI_DESIGNER)return;let conditionsChanged=!1;if(null!==extensionLoaded&&extensionLoaded!==this.__watchActiveRecipeConditions.extensionLoaded&&(this.__watchActiveRecipeConditions.extensionLoaded=extensionLoaded,conditionsChanged=!0),null!==userHasRights&&userHasRights!==this.__watchActiveRecipeConditions.userHasRights&&(this.__watchActiveRecipeConditions.userHasRights=userHasRights,conditionsChanged=!0),!conditionsChanged&&!recipeChanged&&null!==this.__activeRecipesSubscriptionId)return;if(null!==this.__activeRecipesSubscriptionId&&(TcHmi.Server.unsubscribeEx(this.__activeRecipesSubscriptionId,null),this.__activeRecipesSubscriptionId=null),!this.__isAttached||!this.__serverDomain)return void this.__elementSelectedRecipe.classList.remove("active");if(!this.__watchActiveRecipeConditions.extensionLoaded||!this.__watchActiveRecipeConditions.userHasRights||!this.__selectedRecipe)return void this.__elementSelectedRecipe.classList.remove("active");const symbol=this.__serverDomain+".GetActiveRecipes",recipe=this.__selectedRecipe.toString();this.__activeRecipesSubscriptionId=TcHmi.Server.subscribeEx([{commandOptions:["SendErrorMessage","SendWriteValue"],symbol,writeValue:[recipe]}],this.__serverInterval??TcHmi.Config.get().tcHmiServer.websocketIntervalTime,{parallel:!0},data=>{if(data.error!==TcHmi.Errors.NONE)return void TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage(data.details));if(!data.response)return void TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_RESPONSE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_RESPONSE_MISSING],reason:"Missing response from server.",domain:this.__type}));if(data.response.error)return void TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage(data.response.error));if(!data.response.commands)return void TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_COMMANDS_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_COMMANDS_MISSING],reason:`Missing commands in response from server with id: '${data.response.id}'.`,domain:this.__type}));const command=data.response.commands.find(command=>command.symbol===symbol&&command.writeValue?.includes(recipe));command?command.error?TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage(command.error)):command.readValue?this.__elementSelectedRecipe.classList.toggle("active",command.readValue.includes(recipe)):TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_READVALUE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_READVALUE_MISSING],reason:`Missing readValue in response from server with id: '${data.response.id}'.`,domain:this.__type})):TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_COMMAND_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_COMMAND_MISSING],reason:`Missing command for symbol '${symbol}' in response from server with id: '${data.response.id}'.`,domain:this.__type}))})}__updateSymbolAccessSubscription(unsubscribeOnly=!1){if(TCHMI_DESIGNER)return;if(null!==this.__symbolAccessSubscriptionId&&(TcHmi.Server.unsubscribeEx(this.__symbolAccessSubscriptionId,null),this.__symbolAccessSubscriptionId=null),unsubscribeOnly||!this.__isAttached||!this.__serverDomain)return;const writeValuePropertyMap={},commands=Object.keys(this.__symbolAccess).map(symbolName=>{const writeValue=tchmi_format_string(symbolName,this.__serverDomain);return writeValuePropertyMap[writeValue]=symbolName,{symbol:"GetSymbolAccess",writeValue,commandOptions:["SendWriteValue","SendErrorMessage"]}});this.__symbolAccessSubscriptionId=TcHmi.Server.subscribeEx(commands,this.__serverInterval??TcHmi.Config.get().tcHmiServer.websocketIntervalTime,{parallel:!0},data=>{if(data.error===TcHmi.Errors.NONE)if(data.response)if(data.response.error)TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage(data.response.error));else if(data.response.commands){for(const command of data.response.commands)command.error?TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage(command.error)):void 0!==command.readValue?command.writeValue?this.__symbolAccess[writeValuePropertyMap[command.writeValue]]=command.readValue:TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_WRITEVALUE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_WRITEVALUE_MISSING],reason:`Missing writeValue in response from server with id: '${data.response.id}'.`,domain:this.__type})):TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_READVALUE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_READVALUE_MISSING],reason:`Missing readValue in response from server with id: '${data.response.id}'.`,domain:this.__type}));this.__symbolAccess["{0}.Config"]===TcHmi.Server.ACCESS.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,`The TcHmiRecipeSelect control needs at least read access to the ${this.__serverDomain}.Config symbol to be able to display recipes.`),this.__symbolAccess["{0}.GetActiveRecipes"]<TcHmi.Server.ACCESS.WRITE&&TcHmi.Log.Controls.warn(this,TcHmiRecipeSelect.#tchmiFQN,`Without write access access to the ${this.__serverDomain}.GetActiveRecipes symbol the control cannot show recipe activation status.`),this.__updateButtonAccess(),this.__updateRecipeListWatch(null,!!(this.__symbolAccess["{0}.Config"]&TcHmi.Server.ACCESS.READ)),this.__updateActiveRecipesSubscription(null,this.__symbolAccess["{0}.GetActiveRecipes"]>=TcHmi.Server.ACCESS.WRITE)}else TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_COMMANDS_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_COMMANDS_MISSING],reason:`Missing commands in response from server with id: '${data.response.id}'.`,domain:this.__type}));else TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_RESPONSE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_RESPONSE_MISSING],reason:"Missing response from server.",domain:this.__type}));else TcHmi.Log.Controls.error(this,TcHmiRecipeSelect.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage(data.details))})}__updateButtonAccess(){const canWriteConfig=this.__symbolAccess["{0}.Config"]>=TcHmi.Server.ACCESS.WRITE,canActivateRecipe=this.__symbolAccess["{0}.ActivateRecipe"]>=TcHmi.Server.ACCESS.WRITE,canReadFromTarget=this.__symbolAccess["{0}.ReadFromTarget"]>=TcHmi.Server.ACCESS.WRITE,canUpdateRecipe=this.__symbolAccess["{0}.UpdateRecipe"]>=TcHmi.Server.ACCESS.WRITE;TcHmi.Access.setControlRightOverride(this.__buttonActivate,"operate",canActivateRecipe?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canActivateRecipe?"Button_Tooltip_Activate":"Button_Tooltip_Activate_MissingSymbolAccess"),"Tooltip",this.__buttonActivate),TcHmi.Access.setControlRightOverride(this.__buttonTeach,"operate",canReadFromTarget&&canWriteConfig&&canUpdateRecipe?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canReadFromTarget&&canWriteConfig&&canUpdateRecipe?"Button_Tooltip_Teach":"Button_Tooltip_Teach_MissingSymbolAccess"),"Tooltip",this.__buttonTeach)}__expandLocalizationSymbol(key){return`%l%Control::${TcHmiRecipeSelect.#tchmiFQN}::${key}%/l%`}}})();TcHmi.Controls.registerEx("TcHmiRecipeSelect","TcHmi.Controls.Beckhoff",TcHmiRecipeSelect,{injectInGlobalObject:!0});export{TcHmiRecipeSelect as Control};