(function(e){var g=new function(){this.Status=function(){this.category="TwinCAT";this.name="Status";this.subnavigationicon="sec-nav-status.png";var c=void 0;this.Init=function(){c=this;if(void 0==c||null==c)return!1;c.setCycleTime(2E3);c.setCommunicationObj(e.DevMan.getCommunicationModule(e.DevMan.CommunicationType.mdp));c.addParameter("TwinCAT_TcMisc_Property_TwinCATStatus",!0);c.addParameter("TwinCAT_TcMisc_Property_RunAsDevice",!0);c.addParameter("LatencyTimeWatch",!0);c.addParameter("TwinCAT_TcMisc_Property_RegLevel",
!0);c.addParameter("TwinCAT_TcMisc_Property_ShowTargetVisu",!0);c.addParameter("TwinCAT_TcMisc_Property_MajorVersion",!1);c.addParameter("TwinCAT_TcMisc_Property_MinorVersion",!1);c.addParameter("TwinCAT_TcMisc_Property_Build",!1);c.addParameter("TwinCAT_TcMisc_Property_Revision",!1);c.setOnInitStaticPage(g);c.setOnDisplayValues(h);c.setOnWriteFailed(k);c.setOnWriteResult(l);return!0};var g=function(a){var b="";if(a[0].getHasValues()||a[1].getHasValues()||a[2].getHasValues()||a[3].getHasValues()||
a[4].getHasValues()){winxp?b+="<h3>Status</h3>":(b+='<table style="margin-bottom: 5px"><tr><td class="td_trans"><h3>Status</h3></td>',b+='<td class="td_Action_trans">'+(new ControlLib.SmallButton).Create("btnWriteTcSettings","save")+(new ControlLib.SmallButton).Create("btnWriteTcSettings_Cancel","delete")+"</td>",b+="</tr></table>");b+="<table>";a[0].getHasValues()&&(b+='<tr><td class="td_FirstColumn">TwinCAT Status</td><td><div id="'+a[0].parameterName+'"></div></td></tr>');if(a[1].getHasValues())var d=
["No","Yes"],b=b+('<tr><td class="td_FirstColumn">Run As Device</td><td>'+(new ControlLib.Combobox).Create(a[1].parameterName,d)+"</td></tr>");a[2].getHasValues()&&(b+='<tr><td class="td_FirstColumn">Latency timewatch</td><td><div id="temp1">no mdp property</div></td></tr>');a[3].getHasValues()&&(b+='<tr><td class="td_FirstColumn">Reg Level</td><td><div id="'+a[3].parameterName+'"></div></td></tr>');a[4].getHasValues()&&(d=["No","Yes"],b+='<tr><td class="td_FirstColumn">Show Target-Visu</td><td>'+
(new ControlLib.Combobox).Create(a[4].parameterName,d)+"</td></tr>");b+="</table>";b+="<br>"}if(a[5].getHasValues()||a[6].getHasValues()||a[7].getHasValues())b+="<h3>Version</h3>",b+="<table>",a[5].getHasValues()&&(b+='<tr><td class="td_FirstColumn">Major</td><td><div id="'+a[5].parameterName+'"></div></td></tr>'),a[6].getHasValues()&&(b+='<tr><td class="td_FirstColumn">Minor</td><td><div id="'+a[6].parameterName+'"></div></td></tr>'),a[7].getHasValues()&&(b+='<tr><td class="td_FirstColumn">Build</td><td><div id="'+
a[7].parameterName+'"></div></td></tr>'),a[8].getHasValues()&&(b+='<tr><td class="td_FirstColumn">Revision</td><td><div id="'+a[8].parameterName+'"></div></td></tr>'),b+="</table>",b+="<br>";b+='<div id="status"></div>';c.writeActivePage(b);winxp||(c.addLockListener(a[1].parameterName),c.addLockListener(a[4].parameterName),c.setElementOnClick("btnWriteTcSettings",function(a){return function(){var a=[],b=[],d=[],e=c.getRequestParamIDs();if(c.isLocked(e[1].parameterName)){var f=c.getElementValue(e[1].parameterName);
a.push(e[1].parameterName);b.push(0);d.push(f)}c.isLocked(e[4].parameterName)&&(f=c.getElementValue(e[4].parameterName),a.push(e[4].parameterName),b.push(0),d.push(f));0<a.length&&(c.Write(a,b,d),Helper.ShowLoading())}}(0)),c.setElementOnClick("btnWriteTcSettings_Cancel",function(a){return function(){var a=c.getRequestParamIDs();c.removeLock(a[1].parameterName);c.removeLock(a[4].parameterName)}}(0)));return!0},h=function(a){a[0].getHasValues()&&c.writeElement(a[0].parameterName,Helper.getTwinCATState(a[0].values[0].data));
a[1].getHasValues()&&c.setElementValue(a[1].parameterName,a[1].values[0].data);a[2].getHasValues()&&c.writeElement(a[2].parameterName,a[2].values[0].data);a[3].getHasValues()&&c.writeElement(a[3].parameterName,Helper.getTwinCATRegLevel(a[3].values[0].data));a[4].getHasValues()&&c.setElementValue(a[4].parameterName,a[4].values[0].data);a[5].getHasValues()&&c.writeElement(a[5].parameterName,a[5].values[0].data);a[6].getHasValues()&&c.writeElement(a[6].parameterName,a[6].values[0].data);a[7].getHasValues()&&
c.writeElement(a[7].parameterName,a[7].values[0].data);a[8].getHasValues()&&c.writeElement(a[8].parameterName,a[8].values[0].data)},k=function(a){Helper.HideLoading();e.DevMan.getErrorQueue().AddError(a.requestStatus,a.requestStatusText);c.clearLocks()},l=function(a,b){Helper.HideLoading();for(var d=0;d<a.length;d++)0<b[d]&&e.DevMan.getErrorQueue().AddError(b[d]);for(d=0;d<a.length;d++)c.removeLock(a[d].name);for(d=0;d<a.length;d++)if(0==b[d]&&("TwinCAT_TcMisc_Property_RunAsDevice"==a[d].name||"TwinCAT_TcMisc_Property_ShowTargetVisu"==
a[d].name)){if(confirm("You must restart your computer to apply these changes.\nDo you really want to reboot the computer?")){var d=c.getCommunicationObj().getServiceTransferParameterSize("MISC_Function_Reboot"),f=[];f.push(d);f.push(0);Helper.RebootActive();c.executeCommand("MISC_Function_Reboot",0,f)}break}}};this.Status.prototype=new e.Page_Template.Template};e.DevMan.RegisterModule(new g.Status,e.DevMan.ModuleType.Website)})(window);
