(function(f){var h=new function(){this.Connectivity=function(){this.category="TwinCAT";this.name="Connectivity";this.subnavigationicon="sec-nav-network.png";var b=void 0;this.Init=function(){b=this;if(void 0==b||null==b)return!1;b.setCycleTime(2E3);b.setCommunicationObj(f.DevMan.getCommunicationModule(f.DevMan.CommunicationType.mdp));b.addParameter("TwinCAT_TcMisc_Property_TwinCATSystemID",!1);b.addParameter("TwinCAT_TcMisc_Property_AmsNetID",!0);b.addParameter("TwinCAT_Property_Route_Name_Len",!0);
b.addParameter("TwinCAT_Property_Route_AMS_Address_Len",!0);b.addParameter("TwinCAT_Property_Route_Transport_Len",!0);b.addParameter("TwinCAT_Property_Route_Address_Len",!0);b.addParameter("TwinCAT_Property_Route_Timeout_Len",!0);b.addParameter("TwinCAT_Property_Route_Flags_Len",!0);b.setOnInitStaticPage(h);b.setOnDisplayValues(m);b.setOnServiceTransferFailed(n);b.setOnServiceTransferResult(p);return!0};var h=function(c){var a="";if(c[0].getHasValues()||c[1].getHasValues())a+="<h3>Connectivity</h3><table>",
c[0].getHasValues()&&(a+='<tr><td class="td_FirstColumn">System ID</td><td><div id="'+c[0].parameterName+'"></div></td></tr>'),c[1].getHasValues()&&(a+='<tr><td class="td_FirstColumn">AMS Net ID</td><td><div id="'+c[1].parameterName+'"></div></td></tr>'),a+="</table>",a+="<br>";a+="<h3>TwinCAT Routes</h3>";a+='<div id="TwinCAT_Routes">No routes available</div>';a+="<br>";a+='<table style="margin-bottom: 5px"><tr>';a+='<td class="td_trans"><h4>Add TwinCAT Route</h4></td>';a+='<td class="td_Action_trans">'+
(new ControlLib.SmallButton).Create("btnAddTwinCATRoute","save","Add TwinCAT Route")+(new ControlLib.SmallButton).Create("btnAddTwinCATRoute_Cancel","delete")+"</td>";a+="</tr></table>";a+="<table>";a+='<tr><td class="td_FirstColumn">Route Name</td><td>'+(new ControlLib.Textbox).Create("txtAddRoute_Name")+"</td></tr>";a+='<tr><td class="td_FirstColumn">AMS Net ID</td><td>'+(new ControlLib.Textbox).Create("txtAddRoute_AmsNetId")+"</td></tr>";c=Helper.getTwinCATRouteTransportTypes();a+='<tr><td class="td_FirstColumn">Transport Type</td><td>'+
(new ControlLib.Combobox).Create("cmbAddRoute_TransportType",c)+"</td></tr></td>";a+='<tr><td class="td_FirstColumn">Address</td><td>'+(new ControlLib.Textbox).Create("txtAddRoute_Address")+(new ControlLib.Radiobutton).Create("rdAddRouteFlag_Dynamic",2,"Host Name",!0)+(new ControlLib.Radiobutton).Create("rdAddRouteFlag_Dynamic",0,"IP Address",!1)+"</td></tr>";a+='<tr><td class="td_FirstColumn">Connection Timeout (ms)</td><td>'+(new ControlLib.Textbox).Create("txtAddRoute_Timeout")+"</td></tr>";a+=
'<tr><td class="td_FirstColumn">Temporary</td><td>'+(new ControlLib.Checkbox).Create("chkAddRouteFlag_Temporary",1,"Delete route after next restart")+"</td></tr>";a+="</table>";a+="<br>";a+='<div id="status"></div>';b.writeActivePage(a);b.setElementOnClick("btnAddTwinCATRoute",function(a){return function(){var a;a=0|b.getCheckedRadioButtonValue("rdAddRouteFlag_Dynamic");b.getElementChecked("chkAddRouteFlag_Temporary")&&(a|=b.getElementValue("chkAddRouteFlag_Temporary"));var c=b.getElementValue("txtAddRoute_Timeout"),
f=b.getElementValue("cmbAddRoute_TransportType"),g=b.getElementValue("txtAddRoute_AmsNetId").split(".");6!=g.length&&(g=[0,0,0,0,0,0]);var l=b.getElementValue("txtAddRoute_Name"),h=b.getElementValue("txtAddRoute_Address"),k=b.getCommunicationObj().getServiceTransferParameterSize("TwinCAT_Function_AddRoute")+l.length+h.length,e=[];e.push(k);e.push(a);e.push(c);e.push(f);e.push(g[0]);e.push(g[1]);e.push(g[2]);e.push(g[3]);e.push(g[4]);e.push(g[5]);e.push(l.length);e.push(h.length);e.push(l);e.push(h);
b.executeCommand("TwinCAT_Function_AddRoute",0,e);Helper.ShowLoading()}}(0));b.setElementOnClick("btnAddTwinCATRoute_Cancel",function(a){return function(){k(a)}}(0));return!0},m=function(c){c[0].getHasValues()&&b.writeElement(c[0].parameterName,c[0].values[0].data);c[1].getHasValues()&&b.writeElement(c[1].parameterName,c[1].values[0].data);if(c[2].getHasValues()){for(var a="",f=c[2].values[0].length,d=0;d<f;d++)a+='<table style="margin-bottom: 5px"><tr>',a+='<td class="td_trans"><h4>#'+(d+1)+" "+
c[2].values[0][d].data+"</h4></td>",a+='<td class="td_Action_trans">'+(new ControlLib.SmallButton).Create("btnDelTwinCATRoute"+d,"delete","")+"</td>",a+="</tr></table>",a+="<table>",c[3].values[0].length>d&&(a+='<tr><td class="td_FirstColumn">AMS Net ID</td><td>'+c[3].values[0][d].data+"</td></tr>"),c[4].values[0].length>d&&(a+='<tr><td class="td_FirstColumn">Transport Type</td><td>'+Helper.getTwinCATRouteTransportTypeById(c[4].values[0][d].data)+"</tr></td>"),c[5].values[0].length>d&&(a+='<tr><td class="td_FirstColumn">Address</td><td>'+
c[5].values[0][d].data+"</td></tr>"),c[6].values[0].length>d&&(a+='<tr><td class="td_FirstColumn">Connection Timeout (ms)</td><td>'+c[6].values[0][d].data+"</td></tr>"),c[7].values[0].length>d&&(a+='<tr><td class="td_FirstColumn">Flags</td><td>'+Helper.getTwinCATRouteFlagsStr(c[7].values[0][d].data)+"</td></tr>"),a+="</table>",a+="<br>";0==f&&(a="No routes available");b.writeElement("TwinCAT_Routes",a);for(d=0;d<f;d++)b.setElementOnClick("btnDelTwinCATRoute"+d,function(a){return function(){if(confirm("Do you really want to delete the route "+
a+"?")){var c=[];c.push(a.length);c.push(a);b.executeCommand("TwinCAT_Function_DelRoute",0,c);Helper.ShowLoading()}}}(c[2].values[0][d].data))}else b.writeElement("TwinCAT_Routes","No routes available")},n=function(b){Helper.HideLoading();f.DevMan.getErrorQueue().AddError(b.requestStatus,b.requestStatusText)},p=function(b){Helper.HideLoading();if(b.hasError)f.DevMan.getErrorQueue().AddError(b.errCode);else switch(b.moduleItem.name){case "TwinCAT_Function_AddRoute":k(0)}},k=function(c){b.setElementValue("txtAddRoute_Name",
"");b.setElementValue("txtAddRoute_AmsNetId","");b.setElementValue("cmbAddRoute_TransportType",0);b.setElementValue("txtAddRoute_Address","");b.setElementChecked("rdAddRouteFlag_Dynamic_Host Name");b.setElementValue("txtAddRoute_Timeout","");b.setElementUnchecked("chkAddRouteFlag_Temporary")}};this.Connectivity.prototype=new f.Page_Template.Template};f.DevMan.RegisterModule(new h.Connectivity,f.DevMan.ModuleType.Website)})(window);
