PageSourceSearch

https://www.robotmesh.com/studio/content/jsx/robotmesh/tsjs/interface_monitor.js

js robotmesh.com collected 2026-09-24 12:51:47 UTC 27,557 bytes, 1 lines download raw bytes

1import{ProgLanguage}from"./db_enum.js";import{gamepad}from"./gamepad.js";import{ide}from"./ide.js";import{interface_state as ist}from"./interface_state.js";import{msg}from"./msg/messages.js";import{prog_language}from"./prog_language/prog_language.js";import{prog_language_python}from"./prog_language/python.js";import{rmc_browser}from"./rmc/rmc_browser.js";import{ui_status}from"./ui_status.js";import{util as utilweb}from"./util.js";import{util}from"./util_general.js";export var interface_monitor;!function(e){let t,i,o,n,s;e._plugin=null,e._intmonUi=null,e._inInterfaceMonitorShowValue=!1,e.start=async function(t,i,o=!1){if(!e._intmonUi){if(e._intmonUi=new s.InterfaceMonitorUI(t,o),e._intmonUi.start(i),!e._plugin)try{e._plugin=await rmc_browser.start()}catch(e){}jQuery(window).bind("beforeunload",()=>{t&&t.disconnect()})}},e.exit=function(){e._intmonUi.exit(),e._intmonUi=null},e.serializeToJson=function(e){return null!=e?e.getState().serialize():""},e.deserializeFromJson=function(e,t){const i=t.type.progLanguage;var o=prog_language.getCommentText(i,"__CONFIG__",e);if(null==o&&(o=prog_language.getCommentText(i,"__JSON__",e)),null==o||""==o)return!1;const n=t.getState();return n.deserialize(o),function(e,t){const i=t.getDeprecatedWidgetTypes(e.type.id);if(i&&i.length>0){const e=t.getAllWidgets();let o="";for(const t of e)for(const e of i)if(t.type===e){t.setType(null),o=util.format(msg.ERR_DEVICE_TYPE_0_NO_LONGER_SUPPORTED,[e.uiName])+"\n"+util.format(msg.TYPE_OF_PORT_0_HAS_BEEN_SET_TO_EMPTY,[t.hwIdName])+"\n",ui_status.appendOutput(o);break}o&&setTimeout(()=>ui_status.warn(msg.LOAD_ERROR_SOME_TYPES_NO_LONGER_SUPPORTED),2e3)}}(t,n),!0},function(t){const i="fw_ui";function o(){if(ide.project.hwInterface){const e=ide.project.hwInterface.getDownloader();return!!(e.getFirmwareVersion&&e.isFirmwareVersionGreaterThan&&e.updateFirmware)}return!1}async function n(e){const t=utilweb.getAbsUrl(`/studio/content/device_scripts/${e}/${e}_firmware_version.txt`);try{const e=await utilweb.wrapAsAsync(jQuery.get(t));return util.log(i,"getLatestVersion",e),e.trim()}catch(e){return util.log(i,"getLatestVersion failed",e),null}}t.isSupported=o,t.tryStart=async function(t){if(!o())return util.log(i,"tryStart: not supported"),!1;const s=ide.project.hwInterface.getDownloader(),r=ide.project.hwInterface.name,l={};if(l.latest=await n(r),l.toSkip=function(e){const t=`rm_skip_firmware_version_${e}`;return utilweb.cookie(t)}(r),l.device=await s.getFirmwareVersion(t),null===l.device)return util.log(i,"tryStart: did not return the version (e.g. connected to controller)"),!1;if(l.minimum=s.minimumFirmwareVersion,util.log(i,"versions",l),s.isFirmwareVersionGreaterThan(l.latest,l.device)){const o=l.minimum&&s.isFirmwareVersionGreaterThan(l.minimum,l.device);if(!o&&l.toSkip==l.latest)return function(t,i){const o=util.format(msg.FIRMWARE_ON_0_NEEDS_TO_BE_UPDATED,[t])+`<a id='statusBarFirmwareUpdateWarning'>${msg.START_UPDATE}</a>`;ui_status.warn(o),utilweb.$("#statusBarFirmwareUpdateWarning").click(()=>{ui_status.info(""),e.firmware_update.showStartUpdatePrompt(i)})}(r,l),!1;if(await function(e,t,i){return a(util.format(msg.FIRMWARE_ON_0_NEEDS_TO_BE_UPDATED,[e]),e,t,i)}(r,l,!o))return t.close(),util.log(i,"tryStart: exiting, update started"),!0;if(o)return util.log(i,"tryStart: exiting, required update refused"),alert(msg.FIRMWARE_UPDATE_REQUIRED),!0}return util.log(i,"tryStart: exiting, no update"),!1};const s="#firmwareUpdatePromptDialog",r="#firmwareUpdateProgressDialog";function a(t,o,n,a){const l=new util.Deferred,c=utilweb.$(s),d=ide.project.hwInterface.getDownloader(),u=n.minimum&&d.isFirmwareVersionGreaterThan(n.minimum,n.device);return utilweb.$(".dialogText",c).html(t+"<br/>"+msg.CURRENT_VERSION_C+" "+n.device+"<br/>"+msg.NEW_VERSION_C+" "+n.latest+"<br/>"+(u?`<span style="color:red;">${msg.MINIMUM_REQUIRED_VERSION_C}${n.minimum}</span><br/>`:"")),utilweb.$("#bStartUpdate",c).off("click").click(()=>{util.log(i,"start update"),l.resolve(!0),utilweb.hideLightbox(s),async function(t){const o=utilweb.$(r);utilweb.$("#bClose",o).prop("disabled",!0).off("click").click(()=>{utilweb.hideLightbox(r)}),utilweb.showLightbox(r,{modal:!0});let n=msg.FIRMWARE_UPDATE_IN_PROGRESS;function s(e,t=null){n+="</br>",n+=t?`<span class='${t}'>${e}</span>`:e,utilweb.$(".dialogText",o).html(n)}function a(e){n.endsWith("%")&&(n=n.substr(0,n.lastIndexOf(" "))),n+=` ${e}%`,utilweb.$(".dialogText",o).html(n)}
1s(msg.DO_NOT_CLOSE_OR_TURN_OFF,"warn");try{const o=ide.project.hwInterface.getDownloader();if(!o.updateFirmware)throw new Error("Not supported");s(msg.DOWNLOADING_FIRMWARE_DATA);const n=await async function(e,t){const o=utilweb.getAbsUrl(`/studio/content/device_scripts/${e}/${e}_firmware.json`),n=jQuery.ajax({xhr:()=>{const e=new window.XMLHttpRequest;return e.addEventListener("progress",e=>{if(e.lengthComputable){var o=Math.round(e.loaded/e.total*100);util.log(i,"downloadFirmwareData progress: "+o+"%"),t(o)}},!1),e},type:"GET",url:o});return await utilweb.wrapAsAsync(n)}(t,e=>a(e));a(100);let r="",l=0;s(msg.UPDATING_DEVICE);const c=await rmc_browser.getSelectedPort(e._plugin,o.usbDeviceType),d=await o.beforeDownload(e._plugin,c);await o.updateFirmware(d,n,(function(e,t){const i=Date.now();i<l+300||(l=i,t!=r&&(""!=r&&a(100),s(t),r=t),a(e))})),a(100),await d.close(),s(msg.FIRMWARE_UPDATE_DONE,"success")}catch(e){s(msg.ERROR_C+" "+e.message||e)}utilweb.$("#bClose").prop("disabled",!1)}(o)}),utilweb.$("#bSkipVersion",c).off("click").click(()=>{util.log(i,"skip version",n.latest),function(e,t){const i=`rm_skip_firmware_version_${e}`;utilweb.cookie(i,t)}(o,n.latest),utilweb.hideLightbox(s),l.resolve(!1)}),utilweb.$("#bCancel",c).off("click").click(()=>{util.log(i,"cancel"),utilweb.hideLightbox(s),l.resolve(!1)}),utilweb.$("#bSkipVersion",c).text(msg.SKIP_VERSION+" "+n.latest).toggle(a),utilweb.showLightbox(s,{onClose:()=>l.resolve(!1)}),l.promise()}t.showStartUpdatePrompt=async function(t){const i=ide.project.hwInterface.name;try{if(t||(t={}),!t.device){const i=ide.project.hwInterface.getDownloader(),o=await rmc_browser.getSelectedPort(e._plugin,i.usbDeviceType),n=await i.beforeDownload(e._plugin,o);if(t.device=await i.getFirmwareVersion(n),await n.close(),null===t.device)throw msg.ERR_CANNOT_GET_FIRMWARE_VERSION+" "+msg.MAKE_SURE_THAT_V5_BRAIN_IS_DIRECTLY_CONNECTED}t.latest||(t.latest=await n(i))}catch(e){return void alert(msg.ERROR_C+" "+(e.message||e))}a(util.format(msg.ARE_YOU_SURE_YOU_WANT_TO_UPDATE,[i]),i,t,!1)}}(t=e.firmware_update||(e.firmware_update={})),function(e){const t="#interfaceMonitorConfig_joystick",i=t+" .gamepad_item",o=t+" #bOK",n=t+" .type",r=t+" #nameSection #imcj_tbName";e.JoystickDialogBox=class{constructor(){this.selectedWidgetIndex=null,utilweb.$(o).click(()=>{this.tryApply()&&utilweb.hideLightbox(t)})}currentConfigIndex(){var e=gamepad.getConfig();if(!e||!ide.project.hwInterface.gamepadMappings)return 0;let t=0;for(const i of ide.project.hwInterface.gamepadMappings){if(i.id===e.id)return t;t++}return 0}show(e,o){if(e.hwId!==ist.HWID_joystick&&e.hwId!==ist.HWID_controller)throw new Error("Widget is not a joystick/controller");e.hwId==ist.HWID_controller&&(utilweb.$(t+" .dialogTitle").text(msg.CONTROLLER_CONFIGURATION),utilweb.$(t+" .lbJoystickConfig").text(msg.CONTROLLER_CONFIG_C),utilweb.$(t+" .lbJoystickName").text(msg.CONTROLLER_NAME_C),utilweb.$(t+" .lbPartnerJoystickName").text(msg.CONTROLLER_NAME_C)),this._widget=e;const a=utilweb.$(r),l=utilweb.$("#interfaceMonitorConfig_joystick #partnerNameSection #tbPartnerName"),c=utilweb.$(n),d=()=>{const t=c.find("option:selected").index();this.selectedWidgetIndex=t-1,this._widget.selectTypeAt(this.selectedWidgetIndex);const i=t>0;jQuery(".joystick_enabled-mode").toggle(i),utilweb.$("#interfaceMonitorConfig_joystick #nameSection").toggle(t>0),utilweb.$("#interfaceMonitorConfig_joystick #partnerNameSection").toggle(t>1),a.val(e.name),l.val(a.val()+"_p")},u=c.find("option").first().removeAttr("selected");s.updateTypeMenuItems(c,u,e),c.change(()=>d()),d(),l.prop("readonly",!0),a.off("change"),a.on("change",()=>{s.onNameTextChanged(a,e,o.getState()),l.val(a.val()+"_p")}),a.off("keyup paste"),a.on("keyup paste",()=>{l.val(a.val()+"_p")}),a.val(e.name),l.val(a.val()+"_p");const g=c.find("option:selected").index()>0;jQuery("#interfaceMonitorConfig_joystick .gamepadTypeBox").toggle(g),utilweb.fillTemplate("usbGamepadTypes",{types:ide.project.hwInterface.gamepadMappings});const h=this.currentConfigIndex(),_=jQuery(i).get(h);_&&jQuery(_).addClass("selected"),jQuery(i).click(e=>{jQuery(i).removeClass("selected");const t=jQuery(e.target);t.hasClass("gamepad_item")?t.addClass("selected"):t.parents(i).addClass("selected")}),utilweb.showLightbox(t)}
1exit(){jQuery(o).off("click"),jQuery(n).off("change"),jQuery(r).off("change"),jQuery(r).off("keyup paste"),jQuery(i).off("click")}tryApply(){const e=jQuery(i+".selected").attr("id"),t=parseInt(e.substr("gamepad_item_".length));for(const e of ide.project.hwInterface.gamepadMappings)if(e.id===t){gamepad.setConfig(e,ide.project);break}return!0}}}(i=e.ui_joystick||(e.ui_joystick={})),function(t){const i="#interfaceMonitorConfig_drivetrain",o="#interfaceMonitorConfig_drivetrain",n=o+" #cbEnabled",s=o+" #config",r=o+" #leftMotor0",a=o+" #leftMotor1",l=o+" #rightMotor0",c=o+" #rightMotor1",d=" .motorSelect",u=" .cbReversePolarity",g=o+d,h=o+u,_=o+" #gyroSelect",p=o+" #tbWheelTravel",f=o+" #tbTrackWidth",w=o+" #tbGearRatio",m=o+" #bOK",b=o+" #bCancel",y=o+" #nameSection #imcdt_tbName";t.DrivetrainDialogBox=class{constructor(){const e=utilweb.$(n);function t(e,t){const i=jQuery(e).closest(" li").find(t);return util.assert(i.length>0),i}e.click(()=>{var t=e.is(":checked");utilweb.$(s).toggle(t)}),utilweb.$(m).click(()=>{this.tryApply()&&utilweb.hideLightbox(i)}),utilweb.$(b).click(()=>{utilweb.hideLightbox(i)}),utilweb.$(g).change(e=>this.onMotorMenuSelect(jQuery(e.target),t(e.target,u))),utilweb.$(h).click(e=>this.onReversePolarityClick(t(e.target,d),jQuery(e.target))),utilweb.$(_).change(e=>this.onGyroMenuSelect())}onGyroMenuSelect(){const e=utilweb.$(_).val();utilweb.$(f).prop("disabled",!!e)}tryReverseRightMotorPolarity(e,t){const i=e.closest(" li");const o=i.is(utilweb.$(l))?utilweb.$(r):i.is(utilweb.$(c))?utilweb.$(a):null;if(!o)return;const n=utilweb.$(d,o).val();if(n){const e=ide.project.getState(),o=e.getWidgetByHwid(n),s=e.isReversePolarity(o);s||(utilweb.$(u,i).prop("checked",!s),e.setReversePolarity(t,!s))}}onMotorMenuSelect(e,t){const i=ide.project.getState(),o=e.val();if(o){const n=i.getWidgetByHwid(o);t.prop("checked",i.isReversePolarity(n)),t.parent().show(),this.tryReverseRightMotorPolarity(e,n)}else t.parent().hide()}onReversePolarityClick(e,t){const i=ide.project.getState(),o=e.val();if(o){const e=i.getWidgetByHwid(o),n=t.is(":checked");i.setReversePolarity(e,n)}}show(t,d){if(!t.typeCategoryIs(ist.WidgetTypeCategory.Drivetrain))throw new Error("Widget is not a drivetrain");this._cw=t;const h=utilweb.$(n),_=utilweb.$("#interfaceMonitorConfig_drivetrain #all"),m=utilweb.$(s),b=utilweb.$(y);if(b.off("change"),b.on("change",()=>e.ui.onNameTextChanged(b,t,d.getState())),b.val(t.name),this._motors=d.getState().getAllWidgets().filter(e=>e.typeCategoryIs(ist.WidgetTypeCategory.MotorEncoder)),this._motors.length<2)return this.showError(msg.ERR_AT_LEAST_2_MOTORS_MUST_BE_AVAILABLE),_.hide(),void h.prop("checked",!1);this.showError(""),_.show(),h.show(),this.fillMotorMenu(this._motors,utilweb.$(g)),this.fillGyroMenu();const C=t.extraConfig;C?(h.prop("checked",!0),m.show(),utilweb.$(f).val(""+C.trackWidth),utilweb.$(p).val(""+C.wheelTravel),utilweb.$(w).val(""+C.gearRatio),this.setMotor(r,C.leftMotorsHwIds[0]),this.setMotor(a,C.leftMotorsHwIds[1]),this.setMotor(l,C.rightMotorsHwIds[0]),this.setMotor(c,C.rightMotorsHwIds[1]),this.setGyro(C.gyroHwId)):(h.prop("checked",!1),m.hide(),utilweb.$(o+u).parent().hide(),utilweb.$(f).prop("disabled",!1),this.setDefaultParams()),this.toggleVisibleControls(),utilweb.showLightbox(i)}setMotor(e,t){const i=utilweb.$(e+d),o=utilweb.$(e+u);i.val(t),this.onMotorMenuSelect(i,o)}setGyro(e){utilweb.$(_).val(e),this.onGyroMenuSelect()}setDefaultParams(){ide.project.hwInterface&&"vexv5"===ide.project.hwInterface.name?(utilweb.$(f).val("292.1"),utilweb.$(p).val("319.1764")):(utilweb.$(f).val("176"),utilweb.$(p).val("200")),utilweb.$(w).val("1.0")}toggleVisibleControls(){const e=ide.project.hwInterface?ide.project.hwInterface.name:"",t=ide.project.type?ide.project.type.progLanguage:0,i=!("vexiq"===e&&t!==ProgLanguage.Cpp&&t!==ProgLanguage.BlocklyPythonB&&t!==ProgLanguage.PythonB);utilweb.$(a).toggle(i),utilweb.$(c).toggle(i),utilweb.$("#interfaceMonitorConfig_drivetrain #gyroSection").toggle(i),utilweb.$("#interfaceMonitorConfig_drivetrain #gearRatioSection").toggle(i)}exit(){jQuery(n).off("click"),jQuery(m).off("click"),jQuery(b).off("
1click"),utilweb.$(g).off("change"),utilweb.$(h).off("change"),jQuery(y).off("change")}fillMotorMenu(e,t){t.find("option").remove(),t.append(jQuery("<option>").val("").text(msg.NONE));for(const i of e){const e=jQuery("<option>").val(i.hwId).text(i.name);t.append(e)}}fillGyroMenu(){const e=utilweb.$(_);e.find("option").remove();const t=ide.project.getState().getAllWidgets().filter(e=>e.typeCategoryIs(ist.WidgetTypeCategory.Gyro));if(0!==t.length){e.append(jQuery("<option>").val("").text(msg.NONE));for(const i of t){const t=jQuery("<option>").val(i.hwId).text(i.name);e.append(t)}}else e.append(jQuery("<option>").val("").text(msg.NO_GYROS_CONFIGURED))}tryApply(){const e=this.getConfig();if(null==e)this._cw.extraConfig=null;else{if(e.leftMotorsHwIds.length<1)return this.showError(msg.ERR_LEFT_MOTOR_NOT_SELECTED),!1;if(e.rightMotorsHwIds.length<1)return this.showError(msg.ERR_RIGHT_MOTOR_NOT_SELECTED),!1;if(e.leftMotorsHwIds.length!==e.rightMotorsHwIds.length)return this.showError(msg.ERR_DIFFERENT_NUMBER_OF_MOTORS),!1;const t=function(e){const t={};for(let i=0;i<e.leftMotorsHwIds.length;i++){const o=e.leftMotorsHwIds[i],n=util.format(msg.LEFT_0,[i+1]);if(t[o])return[t[o],n];t[o]=n}for(let i=0;i<e.rightMotorsHwIds.length;i++){const o=e.rightMotorsHwIds[i],n=util.format(msg.RIGHT_0,[i+1]);if(t[o])return[t[o],n];t[o]=n}return null}(e);if(t)return this.showError(util.format(msg.ERR_MOTOR_SELECTED_TWICE_0_1,t)),!1;if(isNaN(e.trackWidth)||e.trackWidth<=0)return this.showError(msg.ERR_TRACK_WIDTH_NOT_VALID),!1;if(isNaN(e.wheelTravel)||e.wheelTravel<=0)return this.showError(msg.ERR_WHEEL_DIAMETER_NOT_VALID),!1;if(isNaN(e.gearRatio)||e.gearRatio<=0)return this.showError(msg.ERR_GEAR_RATIO_NOT_VALID),!1;this._cw.extraConfig=e}return!0}getConfig(){if(utilweb.$(n).is(":checked")){const e={leftMotorsHwIds:[],rightMotorsHwIds:[],wheelTravel:parseFloat(utilweb.$(p).val()),trackWidth:parseFloat(utilweb.$(f).val()),gyroHwId:utilweb.$(_).val(),gearRatio:parseFloat(utilweb.$(w).val())};return this.addMotor(r,e.leftMotorsHwIds),this.addMotor(a,e.leftMotorsHwIds),this.addMotor(l,e.rightMotorsHwIds),this.addMotor(c,e.rightMotorsHwIds),e}return null}addMotor(e,t){const i=utilweb.$(e+d).val();i&&t.push(i)}showError(e){utilweb.$("#interfaceMonitorConfig_drivetrain #error").text(e)}}}(o=e.ui_drivetrain||(e.ui_drivetrain={})),function(e){const t="#interfaceMonitorConfig_port",i=t+" ",o=i+"#bOK",n=i+"#imcp_tbName",r=i+".itemDescription",a=i+"#subtypeSection";e.PortDialogBox=class{constructor(e){this._getTitle="string"==typeof e?t=>util.format(e,[t.index+1]):e}show(e,i){utilweb.$(o).on("click",()=>{this.tryApply()&&(utilweb.$(o).off("click"),utilweb.hideLightbox(t))}),this._widget=e;const a=this._getTitle(e);utilweb.$("#interfaceMonitorConfig_port .dialogTitle").text(a);const l=utilweb.$(n);l.off("change");const c={types:null,name:msg.EMPTY,desc:msg.NO_DEVICE_ATTACHED,icon:"empty.jpg"},d=[c].concat(i.getTypeInfoList(e));let u=util.find(d,t=>null===t.types&&!e.type||util.contains(t.types,e.type));if(!u){const t=util.format(msg.ERR_DEVICE_TYPE_0_NO_LONGER_SUPPORTED,[e.type?e.type.uiName:"unknown"]);alert(t),ui_status.warn(t),u=c}this.onTypeChange(u,e),utilweb.updateUiList("#interfaceMonitorConfig_port #widgetTypeList",d,(t,i)=>{i.find(".title").text(t.name);let o=t.icon.substr(0,t.icon.indexOf("."));i.attr("id","item_device_"+o),i.css({"background-image":"url("+utilweb.getResourceUrl("widget-types/"+t.icon)+")"}),i.mouseenter(()=>{utilweb.$(r).text(t.desc)}),i.click(()=>{utilweb.$(r).text(t.desc),this.onTypeChange(t,e),jQuery("#interfaceMonitorConfig_port .iconListItem").removeClass("selected"),i.addClass("selected")})},u,"","div"),l.on("change",()=>s.onNameTextChanged(l,e,i.getState())),utilweb.$("#interfaceMonitorConfig_port #mainPage").show(),utilweb.showLightbox(t)}exit(){jQuery(n).off("change"),jQuery(o).off("click")}getUiConfigSection(e){const t=e.type?e.type.id:"",o=jQuery(`${i}#${ide.project.hwInterface.name}_${t}.configSection`);return o.length>0?o:null}onTypeChange(e,t){function i(e){t.setType(e),utilweb.$(n).val(t.name),utilweb.$("#interfaceMonitorConfig_port #nameSection").toggle(t.type&&t.type.canChangeVarName)}if(utilweb.$(a).hide(),!e.types||e.types.length<=1)i(e.types?e.types[0]:null);else{let o=util.find(e.types,e=>e===t.type);o||(o=e.types[0]),i(o),utilweb.updateUiList(a,e.types,(e,t)=>{t.text(e.uiName),t.val(e.id)},o,"select","option");const n=utilweb.$("#interfaceMonitorConfig_port #sSubtype");n.off("change"),n.on("change",()=>{const t=n.find(":selected").val();i(util.find(e.types,e=>e.id===t))}),utilweb.$(a).show()}if(utilweb.$("#interfaceMonitorConfig_port .configSection").hide(),e.types){const e=this.getUiConfigSection(t);e&&(ide.project.hwInterface.getInterfaceMonitor().portConfigUI_update(t,e),e.show())}}tryApply(){if(this._widget){const e=this.getUiConfigSection(this._widget);this._widget.extraConfig=e?ide.project.hwInterface.getInterfaceMonitor().portConfigUI_toExtraConfig(this._widget,e):null}return!0}}}(n=e.ui_port||(e.ui_port={})),function(t){t.COLOR_ON="#FFD800",t.COLOR_OFF="#FFFFFF",t.COLOR_FWD="#9BE1FF",t.COLOR_REV="#FFDE93",t.COLOR_WARN="#FF7F00";const i="#interface_monitor";t.ID_CONNECT="#bConnect";t.CL_VAL_EMPTY=".emptyValue",t.CL_VAL_TEXT=".textValue",t.CL_VAL_SLIDER=".sliderValue",t.CL_VAL_SLIDER_EXTRA=".sliderExtraValue",t.CL_VAL_DROPDOWN=".dropdownValue",t.CL_VAL_CHECKBOX=".checkboxValue",t.CL_TB_VALUE=".td_value .value",t.CL_TB_VALUE_EXTRA=".td_value .extraValue",t.CL_TB_VALUE_SLIDER=".td_value .slider",t.CL_TB_VALUE_CHECKBOX=".td_value .checkbox";var o=null;function n(e,t,i){e.empty();const o=t.clone().val("none").text(msg.NONE_SQB);
1e.append(o),null==i.type&&o.attr("selected",!0),i.types.forEach(o=>{const n=t.clone().val(o.uiName).text(o.uiName);e.append(n),i.type==o&&n.attr("selected",!0)})}t.showValueArea=function(e,t){utilweb.$(".imWidgetValue",e).css({display:"none"}),utilweb.$(t,e).css({display:"block"})},t.updateTypeMenuItems=n,t.onNameTextChanged=function(e,t,i){const o=i.getWidgetNames(t),n=e.val(),s=prog_language_python.getDefaultNameScope().createName(n,{addToScope:!1,reservedNames:o});t.name=s,t.name!=e.val()&&e.val(t.name)};t.InterfaceMonitorUI=class{constructor(e,t=!1){this.ifc=e,this._isReadonly=t,this._typeItemTempate=null,this._panel=null,this._bConnect=null,this._mimicConnected=!1,this._dialogs={},this._showWidgetTypeChangeButtons=!0}isConnected(){return this._mimicConnected}stop(){this._mimicConnected&&(this._mimicConnected=!1,this.onConnectedChanged(this._mimicConnected))}exit(){this._typeItemTempate=null,this._bConnect.off("click"),this._panel&&this._panel.empty(),this._panel=null,this._bConnect=null,this._dialogs={},this.ifc&&this.ifc.exit(),this.ifc=null,gamepad.exit()}start(n){if(this._panel=utilweb.$(i+" #widgets"),!o){if(0==(o=this._panel.find(".ic_widget")).length)throw new Error("No element found: "+o.selector);o.remove()}this._bConnect=utilweb.$(t.ID_CONNECT),this._isReadonly?this._bConnect.hide():this._bConnect.show(),null!=n.hwInterface&&(jQuery(".interface_monitor_title").text(n.hwInterface.uiName),this.onWidgetListChanged(this.ifc.getState()),this.onConnectedChanged(this.ifc.connected),this.ifc.getState().widgetListChange(()=>{this.onWidgetListChanged(this.ifc.getState())}),this.ifc.connectedChange(()=>{this.onConnectedChanged(this.ifc.connected)}),this.ifc.getState().widgetValueChange((e,t,i)=>{const o=jQuery("#"+t.cssId);o.length>0&&this.updateWidgetItem(o,t)}),this.ifc.getState().widgetTypeChange((e,t,i,o)=>{t.hwId!==ist.HWID_joystick&&t.hwId!=ist.HWID_controller||jQuery(".joystick_enabled-mode").toggle(null!==t.type);const n=jQuery("#"+t.cssId);n.length>0&&this.updateWidgetItem(n,t,!0)}),this.ifc.getState().widgetNameChange((e,t,i)=>{const o=jQuery("#"+i.cssId);o.length>0&&this.updateWidgetItem(o,i)})),this._bConnect.click(()=>this.connect(n));var s=utilweb.$("#bDetectSensors");null!=this.ifc&&this.ifc.canDetectSensors()&&!this._isReadonly?(s.click(()=>{rmc_browser.getSelectedPort(e._plugin,n.hwInterface.getDownloader().usbDeviceType).then(e=>{utilweb.isValidSerialPortName(e)?this.ifc.detectSensors(e):alert(msg.UNABLE_TO_CONNECT_TO_VEX_DEVICE)})}),s.show()):s.hide(),null!=n.hwInterface&&(gamepad.init(n),gamepad.stateChange(e=>{this.ifc.connected||gamepad.setWidgetValues(e,n)}))}async connect(t,i=!1){if(ide.project.hasMimic())if(this._mimicConnected)i||(ide.mimicEngine.physicsStop(),ide.save_op.autosaveStart(),this._mimicConnected=!1,this.onConnectedChanged(this._mimicConnected));else{ide.save_op.autosaveSuspend(msg.TT_AUTOSAVE_SUSPENDED_ON_PHYSICS);const e=t.getState();null!=e&&e.start(),ide.connectTestMimic(),this._mimicConnected=!0,ide.mimicEngine.showStopWarning(),window.focus(),this.onConnectedChanged(this._mimicConnected)}else{const i=jQuery("#test-forceDownload").is(":checked");if(this.ifc.connected)this.ifc.disconnect();else{const o=await rmc_browser.getSelectedPort(e._plugin,t.hwInterface.getDownloader().usbDeviceType),n=await rmc_browser.getSelectedPort(e._plugin,t.hwInterface.getDownloader().usbUserDeviceType);utilweb.isValidSerialPortName(o)&&utilweb.isValidSerialPortName(n)?this.ifc.connect(o,n,i):alert(msg.UNABLE_TO_CONNECT_TO_VEX_DEVICE)}}}disconnect(e){ide.project.hasMimic()&&this._mimicConnected&&(ide.mimicEngine.physicsStop(),ide.save_op.autosaveStart(),this._mimicConnected=!1,this.onConnectedChanged(this._mimicConnected))}onWidgetListChanged(e){this._dialogs=this.ifc.getDialogBoxes(),gamepad.resetWidgetMappings(),this._panel.find(".ic_widget").remove();let i=0;const n=e.getAllWidgets();for(const e of n){const n=e.hwId.replace(/[^A-Za-z0-9_]/g,"_");e.cssId="widget_"+n,e.disabled=!1,i>0?(e.disabled=!0,i--):e.type&&e.type.numPins>1&&(i=e.type.numPins-1);const s=o.clone().attr("id",e.cssId);this._panel.append(s),this.updateWidgetItem(s,e,!0,!0);const r=s.find(".name");r.change(()=>t.onNameTextChanged(r,e,this.ifc.getState())),this._isReadonly&&(r.prop("readonly",!0),s.find(".type").prop("disabled",!0),s.find(".bConfig").prop("disabled",!0)),e.hidden&&e.cssId&&utilweb.$("#"+e.cssId).hide()}}onConnectedChanged(e){e?(this._bConnect.text(msg.DISCONNECT),jQuery("#tool-connect").text(msg.DISCONNECT),this._panel.addClass("connected"),ide.tutorial&&ide.tutorial.resolveUserEvent("mimicConnect")):(this._bConnect.text(msg.CONNECT),jQuery("#tool-connect").text(msg.CONNECT),this._panel.removeClass("connected"),ide.tutorial&&ide.tutorial.resolveUserEvent("mimicDisconnect"))}updateWidgetItem(e,t,i=!1,o=!1){e.find(".num").text(t.hwIdName),e.find(".name").val(t.name).toggle(!t.type||t.type.canChangeVarName);const s=e.find(".choose_label");if(t.disabled?e.find(".table_namevalue").hide():null===t.type||t.hwId===ist.HWID_drivetrain&&!t.extraConfig?(e.find(".table_namevalue").hide(),s.show(),t.hwId===ist.HWID_joystick?s.text(msg.USE_JOYSTICK_HERE_C):t.hwId===ist.HWID_controller?s.text(msg.USE_CONTROLLER_HERE_C):t.hwId===ist.HWID_drivetrain?s.text(msg.CONFIGURE_DRIVETRAIN_HERE_C):s.text(msg.CHOOSE_DEVICE_TYPE_HERE_C)):(e.find(".table_namevalue").show(),e.find(".choose_label").hide()),i){const i=e.find(".type");null==this._typeItemTempate&&(this._typeItemTempate=i.children().first()),i.empty(),i.toggle(!t.disabled&&t.optionsType==ist.OptionsType.ShowTypes),n(i,this._typeItemTempate,t)}const r=e.find(".bConfig");if(r.toggle(this._showWidgetTypeChangeButtons&&!t.disabled&&t.optionsType==ist.OptionsType.ShowDialog),o){utilweb.$(".slider",e).slider({step:5});const i=e.find(".type");i.change(()=>{var o=i.find("option:selected").index();t.selectTypeAt(o-1),this.updateWidgetItem(e,t)}),r.click(()=>{var e=this._dialogs[t.hwId];if(!e)throw Error("No dialog box registered: "+name);e.show(t,this.ifc)})}const a=e.find(".table_namevalue");this.ifc&&this.ifc.updateWidgetUI(t,a,i,o)}hideWidgetTypeChangeButtons(){utilweb.$(i+" .bConfig").hide(),utilweb.$(i+" .choose_label").hide(),this._showWidgetTypeChangeButtons=!1}hideWidgets(e,t){const o=this.ifc.getState().getAllWidgets();void 0===t&&(t=o.length);for(let n=e;n<t;n++){const e=o[n];utilweb.$(i+" #"+e.cssId).hide()}}}}(s=e.ui||(e.ui={})),e.getTypeInfoListHelper=function(e,t,i){let o=e.types.map(e=>{let o=e.id,n=[e],s=e.uiName;if(i)for(const t of i)if(e===t.types[0])o=t.id,n=t.types,s=t.name?t.name:s;else if(util.contains(t.types,e))return null;let r=msg.type_descriptions[t][o];return void 0===r&&(console.error("No description: msg.type_descriptions."+t+"."+o),r=""),{types:n,name:s,desc:r,icon:t+"_"+e.id+".jpg"}});return o=o.filter(e=>null!==e),o};e.InterfaceMonitor=class{constructor(e){this._connected=!1,this._connectedChangeHandlers=[],this._hud=null,this.__state=e}getState(){return this.__state}get connected(){return this._connected}set connected(e){e!=this._connected&&(this._connected=e,this.raiseConnectedChange())}connectedChange(e){this._connectedChangeHandlers.push(e)}
1raiseConnectedChange(){this._connectedChangeHandlers.forEach(e=>{e(this._connected,void 0,this)})}subscribeHudChanges(e){this._hud=e}updateWidgetUI(e,t,i,o){if(o){const i=utilweb.$(".sliderValue .slider",t);i.on("slidechange",()=>{const t=i.slider("value");this.widgetUI_setAction(e,t)}),i.on("slide",(t,i)=>{const o=i.value;this.widgetUI_setAction(e,o)}),utilweb.$(".ui-slider-handle",i).dblclick(()=>{i.slider("value",0)});const o=utilweb.$(".sliderExtraValue .slider",t);o.on("slidechange",()=>{const t=o.slider("value");this.widgetUI_setAction(e,t)}),o.on("slide",(t,i)=>{const o=i.value;this.widgetUI_setAction(e,o)}),utilweb.$(".ui-slider-handle",o).dblclick(()=>{o.slider("value",0)});const n=utilweb.$(".checkboxValue .checkbox",t);n.change(()=>{const t=n.is(":checked");this.widgetUI_setAction(e,t)});const s=utilweb.$(".dropdownValue .select",t);s.off("change"),s.on("change",()=>{const t=s.find(":selected").val();this.widgetUI_setAction(e,t)});const r=utilweb.$(".textValue .value",t);r.off("change"),r.on("change",()=>{const t=r.val();this.widgetUI_setAction(e,t)})}i&&this.widgetUI_switch(e,t),this.widgetUI_showValue(e,t)}widgetUI_showValue(t,i){let o=this.widgetUI_formatValue(t);this._hud&&this._hud.UpdateValue(t,o),t.unexpectedType&&(o={text:msg.WRONG_TYPE,textboxColor:s.COLOR_WARN}),e._inInterfaceMonitorShowValue=!0,void 0!==o.text&&utilweb.$(e.ui.CL_TB_VALUE,i).val(o.text),void 0!==o.textboxColor&&utilweb.$(e.ui.CL_TB_VALUE,i).css({background:o.textboxColor}),void 0!==o.extraText&&utilweb.$(e.ui.CL_TB_VALUE_EXTRA,i).val(o.extraText),void 0!==o.sliderPos&&utilweb.$(e.ui.CL_TB_VALUE_SLIDER,i).slider("value",o.sliderPos),null!=o.checkboxIsOn&&utilweb.$(e.ui.CL_TB_VALUE_CHECKBOX,i).prop("checked",o.checkboxIsOn),e._inInterfaceMonitorShowValue=!1}portConfigUI_update(e,t){throw"Not implemented"}portConfigUI_toExtraConfig(e,t){throw"Not implemented"}}}(interface_monitor||(interface_monitor={}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.