@ -2,6 +2,7 @@ package org.nl.acs.device_driver.basedriver.agv.xg_agv;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import com.alibaba.fastjson.JSONObject ;
import lombok.Data ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
@ -12,6 +13,7 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver ;
import org.nl.acs.instruction.service.InstructionService ;
import org.nl.acs.instruction.service.dto.Instruction ;
import org.nl.acs.monitor.DeviceStageMonitor ;
import org.nl.acs.opc.Device ;
import org.nl.acs.opc.DeviceAppService ;
import org.nl.acs.route.service.RouteLineService ;
@ -27,12 +29,12 @@ import java.util.Map;
/ * *
* magic3 . 0
* 仙工agv
* /
@Slf4j
@Data
@RequiredArgsConstructor
public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver , ExecutableDeviceDriver {
public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver , ExecutableDeviceDriver , DeviceStageMonitor {
@Autowired
RouteLineService routelineserver = SpringContextHolder . getBean ( "routeLineServiceImpl" ) ;
@Autowired
@ -60,8 +62,8 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
int DI12 = 0 ;
int DO0 = 0 ;
int DO1 = 0 ;
int DO2 = 0 ;
Float x = 0f ;
int DO2 = 0 ;
Float x = 0f ;
Float y = 0f ;
Float angle = 0f ;
int navigation_address = 0 ;
@ -106,7 +108,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
int last_continue_navigation = 0 ;
int last_cancle_navigation = 0 ;
int last_drum_run_status = 0 ;
String message = null ;
String device_code ;
Instruction inst = null ;
protected ItemProtocol itemProtocol = new ItemProtocol ( this ) ;
@ -150,16 +152,39 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
//获取最小电量
if ( ObjectUtil . isEmpty ( this . getDevice ( ) . getExtraValue ( ) . get ( "min_electric" ) ) ) {
message = "未配置最小电量" ;
return ;
}
double min_electric = Double . parseDouble ( ( String ) this . getDevice ( ) . getExtraValue ( ) . get ( "min_electric" ) ) ;
//获取最大电量
if ( ObjectUtil . isEmpty ( this . getDevice ( ) . getExtraValue ( ) . get ( "cancle_electric" ) ) ) {
message = "未配置最大电量" ;
return ;
}
double cancle_electric = Double . parseDouble ( ( String ) this . getDevice ( ) . getExtraValue ( ) . get ( "cancle_electric" ) ) ;
//可执行任务电量
if ( ObjectUtil . isEmpty ( this . getDevice ( ) . getExtraValue ( ) . get ( "task_electric" ) ) ) {
message = "未配置可执行任务电量" ;
return ;
}
double task_electric = Double . parseDouble ( ( String ) this . getDevice ( ) . getExtraValue ( ) . get ( "task_electric" ) ) ;
//休息点
int relax_point = Integer . parseInt ( ( String ) this . getDevice ( ) . getExtraValue ( ) . get ( "relax_point" ) ) ;
if ( ObjectUtil . isEmpty ( this . getDevice ( ) . getExtraValue ( ) . get ( "relax_point" ) ) ) {
message = "未配置休息点" ;
return ;
}
Device relax_point_device = deviceAppService . findDeviceByCode ( ( String ) this . getDevice ( ) . getExtraValue ( ) . get ( "relax_point" ) ) ;
int relax_point = Integer . parseInt ( relax_point_device . getAddress ( ) ) ;
//充电点
int charge_point = Integer . parseInt ( ( String ) this . getDevice ( ) . getExtraValue ( ) . get ( "charge_point" ) ) ;
if ( ObjectUtil . isEmpty ( this . getDevice ( ) . getExtraValue ( ) . get ( "charge_point" ) ) ) {
message = "未配置充电点" ;
return ;
}
Device charge_point_device = deviceAppService . findDeviceByCode ( ( String ) this . getDevice ( ) . getExtraValue ( ) . get ( "charge_point" ) ) ;
int charge_point = Integer . parseInt ( charge_point_device . getAddress ( ) ) ;
List < Instruction > instList = instructionService . findAllInstFromCache ( ) ;
if ( instList . size ( ) > 0 ) {
inst = instList . get ( 0 ) ;
}
@ -176,11 +201,12 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
}
} else {
// log.info("address:{},滚筒状态:{},车子状态:{},DI4:{},DO1:{},DO2:{},导航状态:{}",address,drum_run_status,stop,DI4,DO1,DO2,navigation_status);
int start_device_code = Integer . parseInt ( inst . getStart_device_code ( ) ) ;
int next_device_code = Integer . parseInt ( inst . getNext_device_code ( ) ) ;
Device start_device = deviceAppService . findDeviceByCode ( String . valueOf ( start_device_code ) ) ;
Device next_device = deviceAppService . findDeviceByCode ( String . valueOf ( next_device_code ) ) ;
Device start_device = deviceAppService . findDeviceByCode ( inst . getStart_device_code ( ) ) ;
Device next_device = deviceAppService . findDeviceByCode ( inst . getNext_device_code ( ) ) ;
int start_device_code = Integer . parseInt ( start_device . getAddress ( ) ) ;
int next_device_code = Integer . parseInt ( next_device . getAddress ( ) ) ;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver ;
//指令状态就绪
if ( StrUtil . equals ( "0" , inst . getInstruction_status ( ) ) ) {
@ -283,5 +309,23 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
ReadUtil . write ( itemMap , server ) ;
}
@Override
public JSONObject getDeviceStatusName ( ) {
JSONObject jo = new JSONObject ( ) ;
String mode = "" ;
jo . put ( "device_name" , this . getDevice ( ) . getDevice_name ( ) ) ;
jo . put ( "mode" , mode ) ;
jo . put ( "message" , this . getMessage ( ) ) ;
jo . put ( "is_click" , true ) ;
return jo ;
}
@Override
public void setDeviceStatus ( JSONObject data ) {
}
}