- var modbusIp70 = "192.168.2.70" //modbus ip
- var modbusPort70 = 502 //modbus port
- var modbusSlaveId70 = 1 //modbus slaveId master/slave service
- var modbusOffset70 = 0 //Dirección de lectura de señal/Signal read address
- var modbusAddrType70 = "0x" //Signal ata type 0x: Read coil 1x: Read discrete input 3x: Read input register 4x: Read holding register
- var modbusIp71 = "192.168.2.71" //modbus ip
- var modbusPort71 = 502 //modbus port
- var modbusSlaveId71 = 1 //modbus slaveId master/slave service
- var modbusOffset71 = 0 //Dirección de lectura de señal/Signal read address
- var modbusAddrType71 = "0x" //Signal ata type 0x: Read coil 1x: Read discrete input 3x: Read input register 4x: Read holding register
- function boot() {
- // Registration of the response method for the order button of the "Warehouse Shipment" menu
- jj.registerHandler("POST", "/script-api/addDemandDataUI", "addDemandDataUI", false);
- jj.registerHandler("POST", "/script-api/addDemandDataUE", "addDemandDataUE", false);
- jj.registerHandler("POST", "/script-api/DevolucionUI", "DevolucionUI", false); //------update
- jj.registerHandler("POST", "/script-api/DevolucionUE", "DevolucionUE", false); //------update
- // Read Modbus data regularly Rampa MockUp
- jj.defineScheduledFunctions(true, 4000, 4000, "EnvioMockup", [])
- }
- //Función Rampa MockUp
- function EnvioMockup(){
- // 读取 Modbus 信号值
- var signalValue70= jj.readSingleModbusValue(modbusIp70, modbusPort70, modbusSlaveId70, modbusAddrType70, modbusOffset70)
- //jj.scriptLog("INFO", "EnvioMockup70", "Pedido de Mockup enviado!" + signalValue70)
- var signalValue71= jj.readSingleModbusValue(modbusIp71, modbusPort71, modbusSlaveId71, modbusAddrType71, modbusOffset71)
- //jj.scriptLog("INFO", "EnvioMockup71", "Pedido de Mockup enviado!" + signalValue71)
- // 生成任务之前不仅要先读取 Modbus 生成任务信号,还要读取缓存变量 name
- var flag70 = jj.getCacheParam("CB70")// 获取缓存变量 name。
- var flag71 = jj.getCacheParam("CB71")// 获取缓存变量 name。
- // 发起任务的信号值 == 1 && 缓存变量 name != true
- if(signalValue70 == 1 && flag70 != "true" ){
- // 构造任务输入参数
- if (signalValue71 == 1 && flag71 != "true" ) {
- let inputParams = {
- destination:"" //机器人目标站点
- }
- // 构造任务参数
- let orderReq = {
- taskLabel:"MoveMatMockUpOdu", //任务名
- inputParams:JSON.stringify(inputParams)
- }
- // 发起任务
- jj.createWindTask(JSON.stringify(orderReq))
- // 将 name 变量设置为 true。此处仅举例说明,缓存变量的处理,应按实际业务需求进行。
- jj.putCacheParam("CB70", "true")
- jj.putCacheParam("CB71", "true")
- // 打印日志
- jj.scriptLog("INFO", "EnvioMockup", "Pedido de Mockup enviado!")
- }
- }
- }
- // UNIDAD INTERIOR
- function addDemandDataUI(param) {
- var paramObject = JSON.parse(param);
- let response = new ScriptRepsonseEntity();
- let operatorResponse = new OperatorRepsonseEntity();
- // Create Demand Task
- let robotDefLabel = paramObject["robotTaskDef"];
- //let puesto = paramObject["targetSite"];
- let menuId = paramObject["menuId"];
- let addParam = {
- // NOMBRE Demand Task data name, can be customized, and yml Demand Task configuration parameters to maintain uniformity in the defLabel field value
- defLabel: robotDefLabel,
- description: "Abastecimiento UI",
- // The menu id corresponding to the Demand Task supplement needs to be present in the yml configuration
- menuId: "chooseMatSiteUI",
- // Work Type visible in Demand Task data
- workTypes: "COMMON-TYPE",
- // Work Station visible in Demand Task data
- workStations: "UNIDAD INTERIOR",
- createdBy: menuId,
- // Object of the Demand Task content
- content: paramObject,
- // Demand extension field, need to be configured now in the configuration file
- attrList: [{"attributeName": "attribute1","attributeValue": "123"},{"attributeName": "attribute2","attributeValue": "123"}]
- };
- // Create Demand Task data
- jj.addDemand(JSON.stringify(addParam));
- response.body = JSON.stringify(operatorResponse);
- return response;
- }
- // UNIDAD EXTERIOR
- function addDemandDataUE(param) {
- var paramObject = JSON.parse(param);
- let response = new ScriptRepsonseEntity();
- let operatorResponse = new OperatorRepsonseEntity();
- // Create Demand Task
- let robotDefLabel = paramObject["robotTaskDef"];
- let menuId = paramObject["menuId"];
- let addParam = {
- // NOMBRE Demand Task data name, can be customized, and yml Demand Task configuration parameters to maintain uniformity in the defLabel field value
- defLabel: robotDefLabel,
- description: "Abastecimiento UE",
- // The menu id corresponding to the Demand Task supplement needs to be present in the yml configuration
- menuId: "chooseMatSiteUE",
- // Work Type visible in Demand Task data
- workTypes: "COMMON-TYPE",
- // Work Station visible in Demand Task data
- workStations: "UNIDAD EXTERIOR",
- createdBy: menuId,
- // Object of the Demand Task content
- content: paramObject,
- // Demand extension field, need to be configured now in the configuration file
- attrList: [{"attributeName": "attribute1","attributeValue": "123"},{"attributeName": "attribute2","attributeValue": "123"}]
- };
- // Create Demand Task data
- jj.addDemand(JSON.stringify(addParam));
- response.body = JSON.stringify(operatorResponse);
- return response;
- }
- // Response method for clicking on an order on the Demand Task details page, this method is used to generate a handling job based on the start and end point of the call point
- function dealOrderUI(param) {
- let demandInfo = JSON.parse(param);
- // Content of Demand Task
- let contentObject = demandInfo["content"];
- let contentParam = contentObject["params"];
- // Selected call point Worksite id
- let toSiteId = contentParam[0]["value"];
- // Additions to the Demand Task
- let supplementContentObject = demandInfo["suplementContent"];
- let suppleParam = supplementContentObject["params"];
- let fromSiteId = suppleParam[0]["value"];
- let inputParams = {
- fromSiteId: fromSiteId,
- toSiteId: toSiteId
- };
- let taskParam = {
- // Name of the Wind Task to move materials
- taskLabel: "moveMat",
- inputParams: JSON.stringify(inputParams)
- };
- // Running the Wind Task of handling materials
- jj.createWindTask(JSON.stringify(taskParam));
- }
- // Response method for clicking on an order on the Demand Task details page, this method is used to generate a handling job based on the start and end point of the call point
- function dealOrderUE(param) {
- let demandInfo = JSON.parse(param);
- // Content of Demand Task
- let contentObject = demandInfo["content"];
- let contentParam = contentObject["params"];
- // Selected call point Worksite id
- let toSiteId = contentParam[0]["value"];
- // Additions to the Demand Task
- let supplementContentObject = demandInfo["suplementContent"];
- let suppleParam = supplementContentObject["params"];
- let fromSiteId = suppleParam[0]["value"];
- let inputParams = {
- fromSiteId: fromSiteId,
- toSiteId: toSiteId
- };
- let taskParam = {
- // Name of the Wind Task to move materials
- taskLabel: "moveMatUE",
- inputParams: JSON.stringify(inputParams)
- };
- // Running the Wind Task of handling materials
- jj.createWindTask(JSON.stringify(taskParam));
- }
- function DevolucionUI(param){//------update
- //Attention ! followed by //------ changes means it may need to be modified. If not, it means no change is needed.
- //1.Operator parameters are processed and the format is converted (no changes required)
- jj.getLogger().info("Create task parameters:" + param);
- var paramJson = JSON.parse(param);
- var params = paramJson["params"];
- /*2.Read the parameters from the Operator, (change according to the actual situation)
- If the number of incoming parameters is equal to 1: keep 'let from = params[0]["value"]; 'and remove 'let to = params[1]["value"];'.
- If the incoming parameter is equal to 2: just leave it as it is.
- If the incoming parameters are greater than 2; add code as per the rule, e.g.: if the incoming parameters are 3, add 'let site = params[2]["value"];'.
- When reading the parameters passed by the Operator, in the following points need to be noted.
- 1. the naming of the parameters to the left of the equal sign corresponds to [task input parameters] --> [variable name] in wink task, in this case, wink task writes incoming variable names from , to. so in this script, also named from , to.
- 2. the value 0 in params[] corresponds to the first parameter, 1 corresponds to the second parameter, and so on the third parameter is params[2].
- */
- let from = params[0]["value"];//------update
- //let to = params[1]["value"];//------update
- /*3.Determine if the input parameters are empty, and if any of the parameters are empty, a prompt will be made in the Operator.
- 1.if (from == "" || to == "") This is the line that needs to be added or deleted according to the actual number of parameters, as well as changed according to the actual naming of the parameters.
- 2. || This symbol means the or operation, and as long as either side of the symbol holds, the following code is executed
- 3.If there are three or more parameters to be judged, the expression is :if (... || ... || ... || ...)
- 4.operatorResponse.msg = "Please enter the starting site or ending site"; change the pop-up message according to the actual need
- */
- if (from == "" || from == null) { //------update
- jj.getLogger().info("Parametros en blanco!!!!!1");
- var res = { code:400, msg: "Favor indicar puesto" }
- return { code: 400, body: JSON.stringify(res) };
- }
- try {
- //4.Plug the from and to obtained by the previous code into inputParams, and the points to note are as follows
- /*
- 1. both the left and right side of the ':' symbol, the naming is strictly consistent, both correspond to the naming of [task input parameter]-->[variable name] in wink task
- 2. if you need to add, for example, wink task [task input parameters]-->[variable name], in addition to from, to and site, then add code site: site,
- 3. If you need to delete, you can delete the corresponding line directly
- */
- let inputParams = {
- from: from, //------update
- //to: to, //------update
- };
- //5.Generate wink task
- //You need to change the content after taskLabel: to the task name of the corresponding wink task, in this case Devolucion.
- let taskParam = {
- taskLabel: "DevolucionUI",//------update
- inputParams: JSON.stringify(inputParams),
- };
- jj.createWindTask(JSON.stringify(taskParam));
- var res = { code:200, msg: " Tarea Generada !" }
- return { code: 200, body: JSON.stringify(res) };
- } catch (error) {
- jj.getLogger().error("create tss task error", error);
- var res = { code:400, msg: "fail" }
- return { code: 400, body: JSON.stringify(res) };
- }
- }
- function DevolucionUE(param){//------update
- //Attention ! followed by //------ changes means it may need to be modified. If not, it means no change is needed.
- //1.Operator parameters are processed and the format is converted (no changes required)
- jj.getLogger().info("Create task parameters:" + param);
- var paramJson = JSON.parse(param);
- var params = paramJson["params"];
- /*2.Read the parameters from the Operator, (change according to the actual situation)
- If the number of incoming parameters is equal to 1: keep 'let from = params[0]["value"]; 'and remove 'let to = params[1]["value"];'.
- If the incoming parameter is equal to 2: just leave it as it is.
- If the incoming parameters are greater than 2; add code as per the rule, e.g.: if the incoming parameters are 3, add 'let site = params[2]["value"];'.
- When reading the parameters passed by the Operator, in the following points need to be noted.
- 1. the naming of the parameters to the left of the equal sign corresponds to [task input parameters] --> [variable name] in wink task, in this case, wink task writes incoming variable names from , to. so in this script, also named from , to.
- 2. the value 0 in params[] corresponds to the first parameter, 1 corresponds to the second parameter, and so on the third parameter is params[2].
- */
- let from = params[0]["value"];//------update
- //let to = params[1]["value"];//------update
- /*3.Determine if the input parameters are empty, and if any of the parameters are empty, a prompt will be made in the Operator.
- 1.if (from == "" || to == "") This is the line that needs to be added or deleted according to the actual number of parameters, as well as changed according to the actual naming of the parameters.
- 2. || This symbol means the or operation, and as long as either side of the symbol holds, the following code is executed
- 3.If there are three or more parameters to be judged, the expression is :if (... || ... || ... || ...)
- 4.operatorResponse.msg = "Please enter the starting site or ending site"; change the pop-up message according to the actual need
- */
- if (from == "" || from == null) { //------update
- jj.getLogger().info("Parametros en blanco!!!!!1");
- var res = { code:400, msg: "Favor indicar puesto" }
- return { code: 400, body: JSON.stringify(res) };
- }
- try {
- //4.Plug the from and to obtained by the previous code into inputParams, and the points to note are as follows
- /*
- 1. both the left and right side of the ':' symbol, the naming is strictly consistent, both correspond to the naming of [task input parameter]-->[variable name] in wink task
- 2. if you need to add, for example, wink task [task input parameters]-->[variable name], in addition to from, to and site, then add code site: site,
- 3. If you need to delete, you can delete the corresponding line directly
- */
- let inputParams = {
- from: from, //------update
- //to: to, //------update
- };
- //5.Generate wink task
- //You need to change the content after taskLabel: to the task name of the corresponding wink task, in this case Devolucion.
- let taskParam = {
- taskLabel: "DevolucionUE",//------update
- inputParams: JSON.stringify(inputParams),
- };
- jj.createWindTask(JSON.stringify(taskParam));
- var res = { code:200, msg: " Tarea Generada !" }
- return { code: 200, body: JSON.stringify(res) };
- } catch (error) {
- jj.getLogger().error("create tss task error", error);
- var res = { code:400, msg: "fail" }
- return { code: 400, body: JSON.stringify(res) };
- }
- }
- class OperatorRequestEntity {
- constructor() {
- this.robotTaskDef = "";
- this.station = "";
- this.params = [];
- }
- }
- class OperatorRequestParamsEntity {
- constructor() {
- this.key = "";
- this.value = "";
- }
- }
- class OperatorRepsonseEntity {
- constructor() {
- this.code = 200;
- this.msg = "OK";
- }
- }
- class ScriptRepsonseEntity {
- constructor() {
- this.code = 200;
- this.body = "OK";
- }
- }
- class SelectOption {
- constructor() {
- this.value = "";
- this.label = "";
- }
- }
[text] boot.js
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: