Merge remote-tracking branch 'origin/ssdwcs' into ssdwcs
New file |
| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.asrs.entity.BasExt; |
| | | import com.zy.asrs.service.BasExtService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class BasExtController extends BaseController { |
| | | |
| | | @Autowired |
| | | private BasExtService basExtService; |
| | | |
| | | @RequestMapping(value = "/basExt/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(basExtService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/basExt/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<BasExt> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(basExtService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/basExt/add/auth") |
| | | @ManagerAuth |
| | | public R add(BasExt basExt) { |
| | | basExtService.insert(basExt); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/basExt/update/auth") |
| | | @ManagerAuth |
| | | public R update(BasExt basExt){ |
| | | if (Cools.isEmpty(basExt) || null==basExt.getExtNo()){ |
| | | return R.error(); |
| | | } |
| | | basExtService.updateById(basExt); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/basExt/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | basExtService.deleteById(id); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/basExt/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | EntityWrapper<BasExt> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("basExt")); |
| | | convert(map, wrapper); |
| | | List<BasExt> list = basExtService.selectList(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/basExtQuery/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<BasExt> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("ext_no", condition); |
| | | Page<BasExt> page = basExtService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (BasExt basExt : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", basExt.getExtNo()); |
| | | map.put("value", basExt.getExtNo()); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/basExt/check/column/auth") |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<BasExt> wrapper = new EntityWrapper<BasExt>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != basExtService.selectOne(wrapper)){ |
| | | return R.parse(BaseRes.REPEAT).add(getComment(BasExt.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | // List<Map<String, Object>> res = new ArrayList<>(); |
| | | for (RgvSlave rgvSlave : slaveProperties.getRgv()) { |
| | | if (rgvSlave.getId() == rgvNo){ |
| | | if (rgvSlave.getId().equals(rgvNo)){ |
| | | rgvSlave.setDemo(true); |
| | | } |
| | | } |
| | |
| | | } |
| | | // List<Map<String, Object>> res = new ArrayList<>(); |
| | | for (RgvSlave rgvSlave : slaveProperties.getRgv()) { |
| | | if (rgvSlave.getId() == rgvNo){ |
| | | if (rgvSlave.getId().equals(rgvNo)){ |
| | | rgvSlave.setDemo(false); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @GetMapping("/demo/status/rgvStatus") |
| | | public R demoStatusTrue1(Integer rgvNo,Integer status){ |
| | | if (Cools.isEmpty(rgvNo)){ |
| | | return R.error("请选择rgv"); |
| | | } |
| | | if (Cools.isEmpty(status)){ |
| | | return R.error("选择按钮有误"); |
| | | } |
| | | // List<Map<String, Object>> res = new ArrayList<>(); |
| | | for (RgvSlave rgvSlave : slaveProperties.getRgv()) { |
| | | // 获取RGV信息 |
| | | SiemensRgvThread rgvThread = (SiemensRgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo); |
| | | if (rgvThread == null) { |
| | | throw new CoolException("RGV不在线"); |
| | | } |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | throw new CoolException("RGV不在线"); |
| | | } |
| | | String DB = ""; |
| | | if (rgvSlave.getId().equals(rgvNo)){ |
| | | switch (status){ |
| | | case 5://强制启动 |
| | | DB="4.4"; |
| | | break; |
| | | // case 6://复位信号 |
| | | // DB="4.5"; |
| | | // break; |
| | | case 7://报警消音 |
| | | DB="4.6"; |
| | | break; |
| | | case 8://启动 |
| | | DB="4.7"; |
| | | break; |
| | | case 9://停止 |
| | | DB="5.0"; |
| | | break; |
| | | case 10://急停 |
| | | DB="5.1"; |
| | | break; |
| | | case 11://复位按钮 |
| | | DB="5.2"; |
| | | break; |
| | | case 12://手动 |
| | | DB="5.3"; |
| | | break; |
| | | case 13://手动定位 |
| | | DB="5.4"; |
| | | break; |
| | | case 14://单机 |
| | | DB="5.5"; |
| | | break; |
| | | case 15://联机 |
| | | DB="5.6"; |
| | | break; |
| | | case 16://货叉定位回中 |
| | | DB="5.7"; |
| | | break; |
| | | default: |
| | | return R.error("按钮不存在????!!!"); |
| | | } |
| | | if (MessageQueue.offer(SlaveType.Rgv, rgvNo, new Task(10, DB))) { |
| | | return R.ok(); |
| | | } else { |
| | | return R.error("命令下发失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/demo/switch") |
| | |
| | | import com.zy.asrs.domain.vo.PlcErrorTableVo; |
| | | import com.zy.asrs.domain.vo.SiteTableVo; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.BasExt; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.BasExtService; |
| | | import com.zy.asrs.utils.CommandUtils; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.ExtSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.protocol.ExtProtocol; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.thread.BarcodeThread; |
| | | import com.zy.core.thread.MelsecExtThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private BasExtService basExtService; |
| | | |
| | | |
| | | @GetMapping("/io/mode/info/site") |
| | |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | | @GetMapping("/list/ext/auth") |
| | | @ManagerAuth(memo = "机械臂信息") |
| | | public R extList(){ |
| | | List<SiteTableVo> list = new ArrayList<>(); |
| | | // 持久数据 |
| | | List<BasExt> basExts = basExtService.selectList(new EntityWrapper<BasExt>().orderBy("ext_no")); |
| | | for (BasExt ext : basExts) { |
| | | SiteTableVo vo = new SiteTableVo(); |
| | | vo.setDevNo(ext.getExtNo()); // 站点编号 |
| | | vo.setInEnable(ext.getExtTask()); // 可入 可取 |
| | | vo.setOutEnable(ext.getExtPut()); // 可出 可放 |
| | | list.add(vo); |
| | | } |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | | @PostMapping("/table/plc/errors") |
| | | @ManagerAuth(memo = "输送设备plc异常信息表") |
| | | public R plcErrorTable(){ |
New file |
| | |
| | | package com.zy.asrs.entity; |
| | | |
| | | import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("asr_bas_ext") |
| | | public class BasExt implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @ApiModelProperty(value= "编号") |
| | | @TableId(value = "ext_no", type = IdType.INPUT) |
| | | @TableField("ext_no") |
| | | private Integer extNo; |
| | | |
| | | /** |
| | | * 允许取(checkBox) |
| | | */ |
| | | @ApiModelProperty(value= "允许取(checkBox)") |
| | | @TableField("ext_task") |
| | | private String extTask = "N"; |
| | | |
| | | /** |
| | | * 允许放(checkBox) |
| | | */ |
| | | @ApiModelProperty(value= "允许放(checkBox)") |
| | | @TableField("ext_put") |
| | | private String extPut = "N"; |
| | | |
| | | public BasExt() {} |
| | | |
| | | public BasExt(Integer extNo,String extTask,String extPut) { |
| | | this.extNo = extNo; |
| | | this.extTask = extTask; |
| | | this.extPut = extPut; |
| | | } |
| | | |
| | | // BasExt basExt = new BasExt( |
| | | // null, // 编号[非空] |
| | | // null, // 允许取(checkBox) |
| | | // null // 允许放(checkBox) |
| | | // ); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.mapper; |
| | | |
| | | import com.zy.asrs.entity.BasExt; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface BasExtMapper extends BaseMapper<BasExt> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.service; |
| | | |
| | | import com.zy.asrs.entity.BasExt; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | public interface BasExtService extends IService<BasExt> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.zy.asrs.mapper.BasExtMapper; |
| | | import com.zy.asrs.entity.BasExt; |
| | | import com.zy.asrs.service.BasExtService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("basExtService") |
| | | public class BasExtServiceImpl extends ServiceImpl<BasExtMapper, BasExt> implements BasExtService { |
| | | |
| | | } |
| | |
| | | import com.zy.core.model.command.LedCommand; |
| | | import com.zy.core.model.command.RgvCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.model.protocol.ExtProtocol; |
| | | import com.zy.core.model.protocol.RgvProtocol; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.BarcodeThread; |
| | | import com.zy.core.thread.LedThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import com.zy.core.thread.SiemensRgvThread; |
| | | import com.zy.core.thread.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | for (RgvSlave rgv : slaveProperties.getRgv()) { |
| | | if (!rgv.getDemo()){ |
| | | continue; |
| | | |
| | | } |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | |
| | | } |
| | | } |
| | | |
| | | public synchronized void ExtTaskAndPut() throws InterruptedException { |
| | | for (ExtSlave extSlave : slaveProperties.getExt()) { |
| | | // if (!rgv.getDemo()) { |
| | | // continue; |
| | | // } |
| | | MelsecExtThread extThread = (MelsecExtThread) SlaveConnection.get(SlaveType.Ext, extSlave.getId()); |
| | | ExtProtocol extProtocol = extThread.getExtProtocol(); |
| | | if (extProtocol == null) { |
| | | continue; |
| | | } |
| | | // else { |
| | | // extProtocol = extProtocol.clone(); |
| | | // } |
| | | if (extProtocol.isTake()){//允许取 |
| | | |
| | | }else if (extProtocol.isPut()){//允许放 |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | // generator.table="sys_host"; |
| | | // sqlserver |
| | | generator.sqlOsType = SqlOsType.SQL_SERVER; |
| | | generator.url="127.0.0.1:1433;databasename=ghtzasrs"; |
| | | generator.url="192.168.4.15:1433;databasename=ssdasrs"; |
| | | generator.username="sa"; |
| | | generator.password="sa@123"; |
| | | generator.table="man_vacuum_mast"; |
| | | generator.table="asr_bas_ext"; |
| | | generator.packagePath="com.zy.asrs"; |
| | | generator.js = false; |
| | | generator.html = false; |
| | |
| | | @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "登录") |
| | | public R loginAction(String mobile, String password){ |
| | | //验证许可证是否有效 |
| | | LicenseVerify licenseVerify = new LicenseVerify(); |
| | | boolean verify = licenseVerify.verify(); |
| | | if (!verify) {//许可证已失效 |
| | | return R.parse(CodeRes.SYSTEM_20001); |
| | | } |
| | | // LicenseVerify licenseVerify = new LicenseVerify(); |
| | | // boolean verify = licenseVerify.verify(); |
| | | // if (!verify) {//许可证已失效 |
| | | // return R.parse(CodeRes.SYSTEM_20001); |
| | | // } |
| | | if (mobile.equals("super") && password.equals(Cools.md5(superPwd))) { |
| | | Map<String, Object> res = new HashMap<>(); |
| | | res.put("username", mobile); |
| | |
| | | // mainService.RGVDemoShow0(); |
| | | // mainService.RGVDemoShow1(); |
| | | mainService.RGVDemoShow2(); |
| | | //机械臂允许取货、允许放货 |
| | | mainService.ExtTaskAndPut(); |
| | | |
| | | |
| | | } catch (Exception e) { |
| | |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.LedSlave; |
| | | import com.zy.core.model.RgvSlave; |
| | | import com.zy.core.model.*; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | for (Slave rgv : slaveProperties.getRgv()) { |
| | | MessageQueue.init(SlaveType.Rgv, rgv); |
| | | } |
| | | |
| | | // 初始化机械臂mq |
| | | for (Slave ext : slaveProperties.getExt()) { |
| | | MessageQueue.init(SlaveType.Ext, ext); |
| | | } |
| | | // // 初始化Led灯mq |
| | | // for (Slave led : slaveProperties.getLed()) { |
| | | // MessageQueue.init(SlaveType.Led, led); |
| | |
| | | new Thread((Runnable) rgvThread).start(); |
| | | SlaveConnection.put(SlaveType.Rgv, rgv.getId(), rgvThread); |
| | | } |
| | | // 初始化机械臂线程 |
| | | log.info("初始化Ext线程..................................................."); |
| | | for (ExtSlave ext : slaveProperties.getExt()) { |
| | | MelsecExtThread extThread = new MelsecExtThread(ext); |
| | | new Thread(extThread).start(); |
| | | SlaveConnection.put(SlaveType.Ext, ext.getId(), extThread); |
| | | } |
| | | // // 初始化LED线程 |
| | | // log.info("初始化LED线程..................................................."); |
| | | // for (LedSlave led : slaveProperties.getLed()) { |
| | |
| | | // 堆垛机输出日志 |
| | | public static ArrayBlockingQueue<String> RGV = new ArrayBlockingQueue<>(32); |
| | | |
| | | public static ArrayBlockingQueue<String> Ext = new ArrayBlockingQueue<>(32); |
| | | |
| | | } |
| | |
| | | Led, |
| | | Scale, |
| | | Car, |
| | | Rgv |
| | | Rgv, |
| | | Ext |
| | | ; |
| | | |
| | | public static SlaveType findInstance(String s){ |
New file |
| | |
| | | package com.zy.core.model; |
| | | |
| | | import com.zy.core.Slave; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @Data |
| | | public class ExtSlave extends Slave { |
| | | |
| | | private Integer rack; |
| | | |
| | | private Integer slot; |
| | | |
| | | private Integer offset; |
| | | |
| | | private Boolean demo; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.core.model.protocol; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/8/7 |
| | | */ |
| | | @Data |
| | | public class ExtProtocol { |
| | | |
| | | private Integer extNo = 1; |
| | | |
| | | public boolean take = false;//允许取信号 |
| | | |
| | | public boolean put = false;//允许放信号 |
| | | |
| | | @Override |
| | | public ExtProtocol clone() { |
| | | try { |
| | | return (ExtProtocol) super.clone(); |
| | | } catch (CloneNotSupportedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.zy.core.properties; |
| | | |
| | | import com.zy.core.Slave; |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.LedSlave; |
| | | import com.zy.core.model.RgvSlave; |
| | | import com.zy.core.model.*; |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | private List<Slave> car = new ArrayList<>(); |
| | | |
| | | private List<RgvSlave> rgv = new ArrayList<>(); |
| | | |
| | | private List<ExtSlave> ext = new ArrayList<>(); |
| | | } |
New file |
| | |
| | | package com.zy.core.thread; |
| | | |
| | | import HslCommunication.Core.Types.OperateResult; |
| | | import HslCommunication.Core.Types.OperateResultExOne; |
| | | import HslCommunication.Profinet.Melsec.MelsecMcNet; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.BasExt; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.BasExtService; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.ExtSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.protocol.ExtProtocol; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 机械臂线程 //Extraman==>机械臂 |
| | | * Created by vincent on 2020/8/4 |
| | | */ |
| | | @Data |
| | | @Slf4j |
| | | public class MelsecExtThread implements Runnable, ThreadHandler { |
| | | |
| | | private MelsecMcNet melsecMcNet; |
| | | private ExtSlave slave; |
| | | private ExtProtocol extProtocol; |
| | | private short heartBeatVal = 1; |
| | | private boolean resetFlag = false; |
| | | |
| | | public boolean isRunning = true; |
| | | |
| | | public MelsecExtThread(ExtSlave slave) { |
| | | this.slave = slave; |
| | | } |
| | | |
| | | @Override |
| | | @SuppressWarnings("InfiniteLoopStatement") |
| | | public void run() { |
| | | System.out.println("线程启动"); |
| | | System.out.println("extProtocol:"+extProtocol); |
| | | this.connect(); |
| | | // try { |
| | | // Thread.sleep(2000); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | while (isRunning) { |
| | | try { |
| | | int step = 1; |
| | | Task task = MessageQueue.poll(SlaveType.Ext, slave.getId()); |
| | | if (task != null) { |
| | | step = task.getStep(); |
| | | } |
| | | switch (step) { |
| | | // 读数据 |
| | | case 1: |
| | | readStatus(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | // 心跳 |
| | | // heartbeat(); |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 初始化机械臂状态 |
| | | */ |
| | | private void initExt() { |
| | | if (null == extProtocol) { |
| | | extProtocol = new ExtProtocol(); |
| | | } |
| | | extProtocol.setTake(false); |
| | | extProtocol.setPut(false); |
| | | } |
| | | |
| | | @Override |
| | | public boolean connect() { |
| | | boolean result = false; |
| | | melsecMcNet = new MelsecMcNet(slave.getIp(), slave.getPort()); |
| | | OperateResult connect = melsecMcNet.ConnectServer(); |
| | | if(connect.IsSuccess){ |
| | | result = true; |
| | | OutputQueue.Ext.offer(MessageFormat.format( "【{0}】机械臂plc连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | log.info("MelsecExt"+" - 1"+" - 机械臂plc连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | } else { |
| | | OutputQueue.Ext.offer(MessageFormat.format("【{0}】机械臂plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}] ", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | log.error("MelsecExt"+" - 2"+" - 机械臂plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | initExt(); |
| | | } |
| | | // melsecMcNet.ConnectClose(); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 读取状态 |
| | | */ |
| | | private void readStatus(){ |
| | | try { |
| | | OperateResultExOne<byte[]> result = melsecMcNet.Read("D1035", (short) 56); |
| | | if (result.IsSuccess) { |
| | | if (null == extProtocol) { |
| | | extProtocol = new ExtProtocol(); |
| | | extProtocol.setExtNo(slave.getId()); |
| | | } |
| | | extProtocol.setTake(melsecMcNet.getByteTransform().TransBool(result.Content, 0)); |
| | | extProtocol.setPut(melsecMcNet.getByteTransform().TransBool(result.Content, 0)); |
| | | // extProtocol.setMode(melsecMcNet.getByteTransform().TransInt16(result.Content, 0)); |
| | | // extProtocol.setTaskNo(melsecMcNet.getByteTransform().TransInt16(result.Content, 2)); |
| | | |
| | | |
| | | // 根据实时信息更新数据库 |
| | | BasExtService extService = SpringUtils.getBean(BasExtService.class); |
| | | BasExt basExt = new BasExt(); |
| | | basExt.setExtNo(slave.getId()); |
| | | basExt.setExtTask(extProtocol.isTake()?"Y":"N"); |
| | | basExt.setExtPut(extProtocol.isPut()?"Y":"N"); |
| | | if (!extService.updateById(basExt)){ |
| | | log.error("MelsecExt"+" - 4"+" - 机械臂plc数据库更新失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | }else { |
| | | OutputQueue.Ext.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | } |
| | | } else { |
| | | BasExtService extService = SpringUtils.getBean(BasExtService.class); |
| | | BasExt basExt = new BasExt(); |
| | | basExt.setExtNo(slave.getId()); |
| | | basExt.setExtTask("N"); |
| | | basExt.setExtPut("N"); |
| | | extService.updateById(basExt); |
| | | OutputQueue.Ext.offer(MessageFormat.format("【{0}】{1}机械臂plc状态信息失败",DateUtils.convert(new Date()), slave.getId())); |
| | | throw new CoolException(MessageFormat.format( "机械臂plc状态信息失败 ===>> [id:{0}] [ip:{1}] [port:{2}]", slave.getId(), slave.getIp(), slave.getPort())); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | OutputQueue.Ext.offer(MessageFormat.format("【{0}】读取机械臂plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | log.error("MelsecExt"+" - 5"+" - 读取机械臂plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | initExt(); |
| | | } finally { |
| | | // sign = System.currentTimeMillis(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | melsecMcNet.ConnectClose(); |
| | | } |
| | | |
| | | /** |
| | | * 心跳 |
| | | */ |
| | | private void heartbeat(){ |
| | | if (heartBeatVal >= 30000) { |
| | | heartBeatVal = -30000; |
| | | } else { |
| | | heartBeatVal =(short) (heartBeatVal+1); |
| | | } |
| | | OperateResult write = melsecMcNet.Write("D1011", heartBeatVal); |
| | | if (!write.IsSuccess) { |
| | | log.error("MelsecExt"+" - 9"+" - 机械臂plc心跳通讯失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /******************************************************************************************/ |
| | | /**************************************** 测试专用 *****************************************/ |
| | | /*****************************************************************************************/ |
| | | public static void main(String[] args) throws InterruptedException { |
| | | |
| | | } |
| | | |
| | | // 提供一个方法来停止线程 |
| | | public void requestStop() { |
| | | isRunning = false; |
| | | } |
| | | |
| | | // 提供一个方法来重启线程 |
| | | public Thread restartThread() { |
| | | isRunning = true; |
| | | Thread newThread = new Thread(this); |
| | | newThread.start(); |
| | | return newThread; |
| | | } |
| | | |
| | | } |
| | |
| | | import HslCommunication.Profinet.Siemens.SiemensPLCS; |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasRgv; |
| | |
| | | // commandAvoidanceXY.setDestinationStaNo2((short)0); // 目标站 |
| | | commandAvoidanceXY.setCommand((short)0); |
| | | write(commandAvoidanceXY); |
| | | break; |
| | | case 10: |
| | | write10((String) task.getData()); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | //小车强制、复位、报警消音、启动、停止、急停、复位、手动、手动定位、单机、联机、货叉回中 |
| | | private boolean write10(String status) throws InterruptedException { |
| | | if (Cools.isEmpty(status)) { |
| | | log.error("RGV写入命令为空"); |
| | | return false; |
| | | } |
| | | OperateResult result = siemensNet.Write("DB19."+status, true); |
| | | if (result != null && result.IsSuccess) { |
| | | Thread.sleep(200); |
| | | this.readStatus(); |
| | | log.info("RGV 命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON("DB19."+status)); |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), "DB19."+status)); |
| | | return true; |
| | | } else { |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】写入RGV plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [DB块:{4}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status)); |
| | | log.error("写入RGV plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [DB块:{4}]", slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | siemensNet.ConnectClose(); |
| | |
| | | */ |
| | | @RequestMapping(value = "/getLicenseDays") |
| | | public R getLicenseDays() { |
| | | if (true){ |
| | | return R.ok().add(0); |
| | | } |
| | | LicenseVerify licenseVerify = new LicenseVerify(); |
| | | LicenseContent verifyInfo = licenseVerify.getVerifyInfo(); |
| | | if (verifyInfo == null) { |
| | |
| | | |
| | | LicenseVerify licenseVerify = new LicenseVerify(); |
| | | //安装证书 |
| | | LicenseContent install = licenseVerify.install(param); |
| | | // LicenseContent install = licenseVerify.install(param); |
| | | |
| | | logger.info("++++++++ 许可证加载结束 ++++++++"); |
| | | |
| | | return install != null; |
| | | // return install != null; |
| | | return true; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | |
| | | rack: 0 |
| | | slot: 0 |
| | | demo: false |
| | | # EXT穿梭车1 |
| | | ext[0]: |
| | | id: 1 |
| | | ip: 10.10.10.200 |
| | | port: 6000 |
| | | rack: 0 |
| | | slot: 0 |
| | | demo: false |
| | | crn[0]: #堆垛机1 |
| | | id: 1 |
| | | ip: 172.17.91.2 |
| | |
| | | name: @pom.build.finalName@ |
| | | datasource: |
| | | driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
| | | url: jdbc:sqlserver://127.0.0.1:1433;databasename=ghtzasrs |
| | | url: jdbc:sqlserver://192.168.4.15:1433;databasename=ssdasrs |
| | | username: sa |
| | | password: sa@123 |
| | | mvc: |
| | |
| | | |
| | | #License相关配置 |
| | | license: |
| | | subject: ghtzwcs |
| | | subject: ssdwcs |
| | | publicAlias: publicCert |
| | | storePass: public_zhongyang_123456789 |
| | | licensePath: license.lic |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.mapper.BasExtMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.zy.asrs.entity.BasExt"> |
| | | <result column="ext_no" property="extNo" /> |
| | | <result column="ext_task" property="extTask" /> |
| | | <result column="ext_put" property="extPut" /> |
| | | |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html lang="en"> |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>Ext设备</title> |
| | | <link rel="stylesheet" href="../../static/wcs/css/element.css"> |
| | | <script type="text/javascript" src="../../static/wcs/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../../static/wcs/js/common.js"></script> |
| | | <script type="text/javascript" src="../../static/wcs/js/vue.min.js"></script> |
| | | <script type="text/javascript" src="../../static/wcs/js/element.js"></script> |
| | | </head> |
| | | |
| | | <body> |
| | | <div id="app" style="display: flex;justify-content: center;flex-wrap: wrap;"> |
| | | <div style="width: 100%;"> |
| | | <el-table border ref="singleTable" :data="tableData" highlight-current-row |
| | | max-height="450" style="width: 100%"> |
| | | <el-table-column property="devNo" label="机械臂编号"> |
| | | </el-table-column> |
| | | <el-table-column property="inEnable" label="允许取"> |
| | | </el-table-column> |
| | | <el-table-column property="outEnable" label="允许放"> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </div> |
| | | <script> |
| | | var app = new Vue({ |
| | | el: '#app', |
| | | data: { |
| | | tableData: [], |
| | | }, |
| | | created() { |
| | | this.init() |
| | | }, |
| | | watch: { |
| | | |
| | | }, |
| | | methods: { |
| | | init() { |
| | | this.getTableData() |
| | | |
| | | setInterval(() => { |
| | | this.getTableData() |
| | | }, 1000) |
| | | }, |
| | | getTableData() { |
| | | let that = this; |
| | | $.ajax({ |
| | | url: baseUrl + "/site/list/ext/auth", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: {}, |
| | | dataType: 'json', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'GET', |
| | | success: function (res) { |
| | | console.log(res) |
| | | that.tableData = res.data |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }) |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
| | |
| | | </el-form> |
| | | |
| | | <div> |
| | | <el-button v-if="demo === 'N' " @click="demos('true')" type="warning">演示</el-button> |
| | | <el-button v-if="demo === 'Y' " @click="demos('false')" type="warning">取消演示</el-button> |
| | | <el-button v-if="demo === 'N' " @click="demos('true')" type="info">演示</el-button> |
| | | <el-button v-if="demo === 'Y' " @click="demos('false')" type="info">取消演示</el-button> |
| | | </div> |
| | | <div style="margin: 10px auto 10px auto" v-if="demo === 'N' "> |
| | | <el-button @click="rgvStatus(8)" type="primary">启动</el-button> |
| | | <el-button @click="rgvStatus(9)" type="primary">停止</el-button> |
| | | <el-button @click="rgvStatus(14)" type="primary">单机</el-button> |
| | | <el-button @click="rgvStatus(15)" type="primary">联机</el-button> |
| | | <el-button @click="rgvStatus(11)" type="primary">复位按钮</el-button> |
| | | </div> |
| | | <div style="margin: 10px auto 10px auto" v-if="demo === 'N' "> |
| | | <el-button @click="rgvStatus(7)" type="warning">报警消音</el-button> |
| | | <el-button @click="rgvStatus(12)" type="warning">手动</el-button> |
| | | <el-button @click="rgvStatus(13)" type="warning">手动定位</el-button> |
| | | </div> |
| | | <div style="margin: 10px auto 10px auto" v-if="demo === 'N' "> |
| | | <el-button :style="" @click="rgvStatus(5)" type="danger">强制启动</el-button> |
| | | <el-button @click="rgvStatus(10)" type="danger">急停</el-button> |
| | | <el-button @click="rgvStatus(16)" type="danger">货叉定位回中</el-button> |
| | | </div> |
| | | <div style="margin-top: 5px" v-if="demo === 'Y'"> |
| | | <el-button @click="staTova(2,1)" type="warning">输送-置换1</el-button> |
| | |
| | | }); |
| | | }) |
| | | }, |
| | | rgvStatus(method){ |
| | | let that = this |
| | | that.$confirm('此操作存在风险,是否继续','提示',{ |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(()=>{ |
| | | $.ajax({ |
| | | url: baseUrl + "/rgv/demo/status/rgvStatus", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data:{ |
| | | rgvNo : this.formParam.rgvNo, |
| | | status : Number(method) |
| | | }, |
| | | method: 'Get', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'success' |
| | | }); |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | }, |
| | | requestOperate(method) { |
| | | let that = this |
| | | that.$confirm('此操作存在风险,是否继续','提示',{ |