语音指令

This commit is contained in:
tiger_zhou 2023-04-03 13:36:36 +08:00
parent f6dd8e7a42
commit d141fd8e52
17 changed files with 169 additions and 126 deletions

View File

@ -1,11 +1,12 @@
package club.joylink.rtss.configuration;
import club.joylink.rtss.simulation.cbtc.command.voice2.analyse.AnalyseChain;
import club.joylink.rtss.simulation.cbtc.command.voice2.analyse.DefaultPinYinSplitWordAnalyse;
import club.joylink.rtss.simulation.cbtc.command.voice2.analyse.TestAnalye;
import club.joylink.rtss.simulation.cbtc.command.voice2.match.IVoiceCommandMatcher;
import club.joylink.rtss.simulation.cbtc.command.voice2.match.DefaultPinYinViolenceMatch;
import club.joylink.rtss.simulation.cbtc.command.voice2.work.IDeviceWorkHandle;
import club.joylink.rtss.simulation.cbtc.command.voice2.work.VoiceCommandAnalyseWork;
import club.joylink.rtss.simulation.cbtc.command.voice2.work.device.StandWork;
import club.joylink.rtss.simulation.cbtc.command.voice2.work.device.SwitchWork;
import org.springframework.context.annotation.Bean;
@ -19,7 +20,9 @@ public class VoiceCommandConfig {
@PostConstruct
private void initAnalyse(){
//加入指令分析
VoiceCommandAnalyseWork.addAnalyse(new DefaultPinYinSplitWordAnalyse());
AnalyseChain.addAnalyse(new TestAnalye());
AnalyseChain.addAnalyse(new DefaultPinYinSplitWordAnalyse());
// VoiceCommandAnalyseWork.addAnalyse(new DefaultPinYinSplitWordAnalyse());
}
/**

View File

@ -54,9 +54,9 @@ public class VoiceConfigDataService implements IVoiceConfigDataService, IVoiceCo
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(Objects.nonNull(dataVO.getDeviceType()),"请选择操控的设备类型");
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(Objects.nonNull(dataVO.getOperateType()),"请选择设备对应的操作");
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(dataVO.getOperateType().getDeviceType() == dataVO.getDeviceType(),"设备的操作与设备类型不匹配");
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(!CollectionUtils.isEmpty(dataVO.getWakeUpParmas()),"设备唤醒匹配关键字不能为空");
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(Objects.nonNull(dataVO.getWakeUpParmas()),"设备唤醒匹配关键字不能为空");
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(Objects.nonNull(dataVO.getParamConfig()),"操作参数不能为空");
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(ArrayUtils.isNotEmpty(dataVO.getParamConfig().getActionKW()),"操作关键字不能为空");
// BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(Objects.nonNull(dataVO.getParamConfig()),"操作关键字不能为空");
VoiceDeviceConfig2 vc = dataVO.converBean();
vc.setCreateId(userInfoVO.getAccountVO().getId());

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.simulation.cbtc.command.voice2;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.ConfigData;
import club.joylink.rtss.vo.voice.VoiceConfigDataVO;
import java.util.List;

View File

@ -3,12 +3,13 @@ package club.joylink.rtss.simulation.cbtc.command.voice2;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.voice.IVoiceService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.command.voice2.analyse.AnalyseChain;
import club.joylink.rtss.simulation.cbtc.command.voice2.match.IVoiceCommandMatcher;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.CommandParse;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.ConfigData;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.VoiceCommand;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.WorkResult;
import club.joylink.rtss.simulation.cbtc.command.voice2.work.VoiceCommandAnalyseWork;
import club.joylink.rtss.simulation.cbtc.command.voice2.work.VoiceCommandWork;
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
@ -30,7 +31,8 @@ public class VoiceCommandHandle {
@Autowired
private IVoiceCommandMatcher commandMatcher;
@Autowired
private VoiceCommandAnalyseWork analyseWork;
private VoiceCommandWork analyseWork;
public List<WorkResult> voiceCommand(Simulation simulation, String source){
List<ConfigData> configDataList = simulation.getVoiceConfigDataList();
@ -50,7 +52,8 @@ public class VoiceCommandHandle {
BusinessExceptionAssertEnum.VOICE_COMMAND_PARSE_ERROR.assertTrue(!CollectionUtils.isEmpty(commandList),"语音指令未识别匹配的内容");
List<WorkResult> workResultList = Lists.newArrayList();
for (VoiceCommand command : commandList) {
CommandParse commandParse = analyseWork.analyse(simulation,command,result);
AnalyseChain analyseChain = new AnalyseChain();
CommandParse commandParse = analyseChain.parse(simulation,command,result);
if(Objects.isNull(commandParse)){
log.error("数据结失败 类型[{}] 动作[{}] 语音指令[{}]",command.getOperate().getDeviceType(),command.getOperate(),result);
}else{

View File

@ -0,0 +1,34 @@
package club.joylink.rtss.simulation.cbtc.command.voice2.analyse;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.CommandParse;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.VoiceCommand;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
public class AnalyseChain {
private final static List<IVoiceCommandAnalyse> ANALYSE_LIST = Lists.newArrayList();
public static void addAnalyse(IVoiceCommandAnalyse analyse){
boolean exist = ANALYSE_LIST.stream().anyMatch(d-> StringUtils.equalsIgnoreCase(d.getClass().getSimpleName(),analyse.getClass().getSimpleName()));
if(!exist){
ANALYSE_LIST.add(analyse);
}
}
private int index = 0;
public CommandParse parse(Simulation simulation, VoiceCommand command, String sourceCommandStr){
if(ANALYSE_LIST.isEmpty()){
return null;
}
if(index + 1 > ANALYSE_LIST.size()){
return null;
}
IVoiceCommandAnalyse analyse = ANALYSE_LIST.get(index++);
return analyse.parseCommand(simulation,command,sourceCommandStr,this);
}
}

View File

@ -14,20 +14,20 @@ import org.ansj.domain.Term;
import org.ansj.library.DicLibrary;
import org.ansj.splitWord.analysis.DicAnalysis;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Objects;
public class DefaultPinYinSplitWordAnalyse implements VoiceCommandAnalyse {
public class DefaultPinYinSplitWordAnalyse implements IVoiceCommandAnalyse {
@Override
public synchronized CommandParse parseCommandDescribe(Simulation simulation, VoiceCommand command, String sourceCommand) {
public CommandParse parseCommand(Simulation simulation, VoiceCommand command, String sourceCommandStr, AnalyseChain chain) {
this.initDic(simulation,command);
String pinyinStr = PinYinUtil.toPinYinSplitBlankSpace(sourceCommand);
String pinyinStr = PinYinUtil.toPinYinSplitBlankSpace(sourceCommandStr);
Result reslut = DicAnalysis.parse(pinyinStr);
List<ParseDetail> resultList = Lists.newArrayList();
CommandParse commandParse = new CommandParse();
commandParse.setDetail(resultList);
for (Term term : reslut) {
String name = term.getName().toUpperCase();
String nature = term.getNatureStr();
@ -37,42 +37,47 @@ public class DefaultPinYinSplitWordAnalyse implements VoiceCommandAnalyse {
}
}
}
if(CollectionUtils.isEmpty(resultList)){
return chain.parse(simulation,command,sourceCommandStr);
}
CommandParse commandParse = new CommandParse();
commandParse.setDetail(resultList);
return commandParse;
}
private void initDic(Simulation simulation,VoiceCommand command){
DicLibrary.clear(DicLibrary.DEFAULT);
for (Station station : simulation.getRepository().getStationList()) {
String pinYinTmp = PinYinUtil.toPinYinSplitBlankSpace(station.getName()).toLowerCase();
List<String> pinyin = Splitter.onPattern("\\s").omitEmptyStrings().splitToList(pinYinTmp);
DicLibrary.insert(DicLibrary.DEFAULT,pinYinTmp, VoiceCommandAnalyse.DESCRIBE_NATURE,DicLibrary.DEFAULT_FREQ);
DicLibrary.insert(DicLibrary.DEFAULT,pinYinTmp, IVoiceCommandAnalyse.DESCRIBE_NATURE,DicLibrary.DEFAULT_FREQ);
List<List<String>> subPinYinList = Lists.partition(pinyin,2);
for (List<String> strings : subPinYinList) {
String t = Joiner.on(" ").skipNulls().join(strings);
DicLibrary.insert(DicLibrary.DEFAULT,t, VoiceCommandAnalyse.DESCRIBE_NATURE,DicLibrary.DEFAULT_FREQ);
DicLibrary.insert(DicLibrary.DEFAULT,t, IVoiceCommandAnalyse.DESCRIBE_NATURE,DicLibrary.DEFAULT_FREQ);
}
subPinYinList = Lists.partition(pinyin,3);
for (List<String> strings : subPinYinList) {
String t = Joiner.on(" ").skipNulls().join(strings);
DicLibrary.insert(DicLibrary.DEFAULT,t, VoiceCommandAnalyse.DESCRIBE_NATURE,DicLibrary.DEFAULT_FREQ);
DicLibrary.insert(DicLibrary.DEFAULT,t, IVoiceCommandAnalyse.DESCRIBE_NATURE,DicLibrary.DEFAULT_FREQ);
}
}
String[] pinYinWakeUp = PinYinUtil.toPinYins(command.getWakeUpKW());
for (String s : pinYinWakeUp) {
DicLibrary.insert(DicLibrary.DEFAULT,s.toLowerCase(),DicLibrary.DEFAULT_NATURE,DicLibrary.DEFAULT_FREQ);
}
String[] pinYinAction = PinYinUtil.toPinYins(command.getOperateConfigData().getActionKW());
for (String s : pinYinAction) {
DicLibrary.insert(DicLibrary.DEFAULT,s.toLowerCase(),DicLibrary.DEFAULT_NATURE,DicLibrary.DEFAULT_FREQ);
}
String[] pinYinNature = PinYinUtil.toPinYins(command.getOperateConfigData().getNatureKW());
String[] pinYinWakeUp = PinYinUtil.toPinYins(command.getWakeUpKW().getWakeups());
String[] pinYinAction = PinYinUtil.toPinYins(command.getWakeUpKW().getOperates());
// String[] pinYinNature = PinYinUtil.toPinYins(command.getOperateConfigData().getNatureKW());
for (String s : pinYinNature) {
DicLibrary.insert(DicLibrary.DEFAULT,s.toLowerCase(), VoiceCommandAnalyse.DESCRIBE_NATURE,DicLibrary.DEFAULT_FREQ);
this.insertDic(pinYinWakeUp,DicLibrary.DEFAULT_NATURE);
this.insertDic(pinYinAction,DicLibrary.DEFAULT_NATURE);
// this.insertDic(pinYinNature,IVoiceCommandAnalyse.DESCRIBE_NATURE);
}
private void insertDic(String[] dics , String nature){
for (String s : dics) {
DicLibrary.insert(DicLibrary.DEFAULT,s.toLowerCase(),nature,DicLibrary.DEFAULT_FREQ);
}
}
}

View File

@ -4,13 +4,17 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.CommandParse;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.VoiceCommand;
public interface VoiceCommandAnalyse {
public interface IVoiceCommandAnalyse {
String DESCRIBE_NATURE = "nature";
/**
* 解析命令
* @param Command 命令原文
* @return 解析后的数据
* @param simulation
* @param command
* @param sourceCommand
* @param chain
* @return
*/
CommandParse parseCommandDescribe(Simulation simulation, VoiceCommand Command, String sourceCommandStr);
CommandParse parseCommand(Simulation simulation, VoiceCommand command, String sourceCommand, AnalyseChain chain);
}

View File

@ -27,18 +27,17 @@ public class DefaultPinYinViolenceMatch implements IVoiceCommandMatcher {
private VoiceCommand matching(ConfigData configData,String sourceMsg){
String pinYinSource = PinYinUtil.toPinYinSplitBlankSpace(sourceMsg);
String[] pinYinWakeUp = PinYinUtil.toPinYins(configData.getWakeUpKW());
VoiceCommand command = new VoiceCommand();
if(StringUtils.containsAnyIgnoreCase(pinYinSource,pinYinWakeUp)){
String[] pinYinWakeUp = PinYinUtil.toPinYins(configData.getWakeUpKW().getWakeups());
String[] pinYinOperates = PinYinUtil.toPinYins(configData.getWakeUpKW().getOperates());
if(StringUtils.containsAny(pinYinSource,pinYinWakeUp) && StringUtils.containsAny(pinYinSource,pinYinOperates)){
VoiceCommand command = new VoiceCommand();
command.setWakeUpKW(configData.getWakeUpKW());
// command.setSourceDescrbe(sourceMsg);
}
String[] pinYinAction = PinYinUtil.toPinYins(configData.getOperateConfigData().getActionKW());
if(StringUtils.containsAnyIgnoreCase(pinYinSource,pinYinAction)){
command.setOperate(configData.getOperateType());
command.setOperateConfigData(configData.getOperateConfigData());
return command;
}
return command;
return null;
}
}

View File

@ -13,7 +13,7 @@ import java.util.Objects;
@Data
public class ConfigData {
// private MapElement.DeviceType deviceType;
private String[] wakeUpKW;
private WakeUpParam wakeUpKW;
private OperateConfigData operateConfigData;
private OperateEnum operateType;
@ -23,10 +23,12 @@ public class ConfigData {
configVO.setOperateType(vc.getOperateType());
// configVO.setDeviceType(vc.getDeviceType());
if(StringUtils.isNotEmpty(vc.getWakeUpParmas())){
List<String> wakeUps = JsonUtils.readCollection(vc.getWakeUpParmas(), ArrayList.class,String.class);
String[] ss = new String[wakeUps.size()];
wakeUps.toArray(ss);
configVO.setWakeUpKW(ss);
WakeUpParam wakeUpParam = JsonUtils.read(vc.getWakeUpParmas(),WakeUpParam.class);
// List<String> wakeUps = JsonUtils.readCollection(vc.getWakeUpParmas(), ArrayList.class,String.class);
// String[] ss = new String[wakeUps.size()];
// wakeUps.toArray(ss);
configVO.setWakeUpKW(wakeUpParam);
}
if(Objects.nonNull(vc.getParamConfig())){
OperateConfigData cd = JsonUtils.read(vc.getParamConfig(), OperateConfigData.class);

View File

@ -1,16 +1,31 @@
package club.joylink.rtss.simulation.cbtc.command.voice2.vo;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import lombok.Data;
@Data
public class OperateConfigData {
// private OperateEnum operate;
/**
* 动作关键字 定位(道岔)反位(道岔),跳站(站台)扣车(站台),办理进路
* 需要提取设备的类型
*/
private String[] actionKW;
private MapElement.DeviceType deviceType;
/**
* 属性关键字 上行(站台)
* 提取设备类型的属性
*/
private String[] natureKW;
private DeviceNameType deviceNameType;
/**
* 提取属性关键字
*/
private String[] natureKWs;
/**
* 提取设备名称/code或属性的正则
*/
private String[] regexs;
public enum DeviceNameType{
CODE,NAME,ATTR
}
}

View File

@ -13,7 +13,7 @@ public class VoiceCommand {
/**
* 匹配的类型关键字
*/
private String[] wakeUpKW;
private WakeUpParam wakeUpKW;
@Override
public String toString(){

View File

@ -0,0 +1,10 @@
package club.joylink.rtss.simulation.cbtc.command.voice2.vo;
import lombok.Data;
@Data
public class WakeUpParam {
private String[] wakeups;
private String[] operates;
}

View File

@ -2,11 +2,8 @@ package club.joylink.rtss.simulation.cbtc.command.voice2.work;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.command.voice2.analyse.VoiceCommandAnalyse;
import club.joylink.rtss.simulation.cbtc.command.voice2.operate.OperateEnum;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.CommandParse;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.VoiceCommand;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.WorkResult;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
@ -14,26 +11,16 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@Component
@Slf4j
public class VoiceCommandAnalyseWork {
public class VoiceCommandWork {
@Resource
private List<IDeviceWorkHandle> deviceWorks;
private final static List<VoiceCommandAnalyse> ANALYSE_LIST = new ArrayList<>();
/**
* 添加分析
* @param analyse
*/
public static void addAnalyse(VoiceCommandAnalyse analyse){
ANALYSE_LIST.add(analyse);
}
private IDeviceWorkHandle findDeviceWorkHandle(MapElement.DeviceType deviceType){
IDeviceWorkHandle deviceWork = this.deviceWorks.stream().filter(d->d.deviceType() == deviceType).findFirst().orElse(null);
@ -41,22 +28,6 @@ public class VoiceCommandAnalyseWork {
return deviceWork;
}
/**
* 分析语音指令的描述并返回查找对应的设备
* @param simulation
* @param command
* @return
*/
public CommandParse analyse(Simulation simulation, VoiceCommand command, String sourceCommandStr) {
for (VoiceCommandAnalyse commandAnalyse : ANALYSE_LIST) {
CommandParse commandParse = commandAnalyse.parseCommandDescribe(simulation,command, sourceCommandStr);
if(Objects.nonNull(commandParse)){
return commandParse;
}
}
return null;
}
/**
* 执行操作
* @param simulation

View File

@ -2,7 +2,7 @@ package club.joylink.rtss.simulation.cbtc.command.voice2.work.device;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStandService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.command.voice2.analyse.VoiceCommandAnalyse;
import club.joylink.rtss.simulation.cbtc.command.voice2.analyse.IVoiceCommandAnalyse;
import club.joylink.rtss.simulation.cbtc.command.voice2.operate.OperateEnum;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.CommandParse;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.ParseDetail;
@ -28,7 +28,7 @@ public class StandWork implements IDeviceWorkHandle {
private String findStationCode(Simulation simulation, CommandParse commandParse){
List<ParseDetail> findCommandParse = commandParse.findNotNatureDetail(VoiceCommandAnalyse.DESCRIBE_NATURE);
List<ParseDetail> findCommandParse = commandParse.findNotNatureDetail(IVoiceCommandAnalyse.DESCRIBE_NATURE);
JaroWinklerSimilarity similarity = new JaroWinklerSimilarity();
Map<Double,String> similarityMaper = new HashMap<>();
for (Station station : simulation.getRepository().getStationList()) {
@ -52,7 +52,6 @@ public class StandWork implements IDeviceWorkHandle {
if(StringUtils.isEmpty(stationCode)){
return Optional.empty();
}
// OperateEnum configOperateEnum = commandParse.getOperate();
final boolean isRight = (operate == OperateEnum.STAND_DOWN_HOLD_TRAIN || operate == OperateEnum.STAND_CANCEL_DOWN_HOLD_TRAIN) ? false : true;
Optional<Stand> stand = simulation.getRepository().getStandList().stream().filter(d->d.isRight() == isRight && StringUtils.equalsIgnoreCase(d.getStation().getCode(),stationCode)).findFirst();
return stand;

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.vo.voice;
import club.joylink.rtss.entity.voice2.VoiceDeviceConfig2;
import club.joylink.rtss.simulation.cbtc.command.voice2.operate.OperateEnum;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.OperateConfigData;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.WakeUpParam;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.util.JsonUtils;
import lombok.Data;
@ -28,7 +29,7 @@ public class VoiceConfigDataVO implements Serializable {
/**
* 匹配类型唤醒参数
*/
private List<String> wakeUpParmas;
private WakeUpParam wakeUpParmas;
/**
* 线路
@ -62,13 +63,13 @@ public class VoiceConfigDataVO implements Serializable {
/**
* 操作匹配参数
*/
private OperateConfigData paramConfig;
private List<OperateConfigData> paramConfig;
public VoiceDeviceConfig2 converBean(){
VoiceDeviceConfig2 vc = new VoiceDeviceConfig2();
BeanUtils.copyProperties(this, vc);
if(!CollectionUtils.isEmpty(this.wakeUpParmas)){
if(Objects.nonNull(this.wakeUpParmas)){
vc.setWakeUpParmas(JsonUtils.writeValueAsString(this.wakeUpParmas));
}
if(Objects.nonNull(this.paramConfig)){
@ -88,12 +89,14 @@ public class VoiceConfigDataVO implements Serializable {
configVO.setDeviceType(vc.getDeviceType());
configVO.setOperateType(vc.getOperateType());
if(StringUtils.isNotEmpty(vc.getWakeUpParmas())){
List<String> wakeUps = JsonUtils.readCollection(vc.getWakeUpParmas(),ArrayList.class,String.class);
configVO.setWakeUpParmas(wakeUps);
WakeUpParam wp = JsonUtils.read(vc.getWakeUpParmas(),WakeUpParam.class);
configVO.setWakeUpParmas(wp);
}
if(Objects.nonNull(vc.getWakeUpParmas())){
OperateConfigData cd = JsonUtils.read(vc.getWakeUpParmas(),OperateConfigData.class);
configVO.setParamConfig(cd);
List<OperateConfigData> configDatas = JsonUtils.readCollection(vc.getWakeUpParmas(),ArrayList.class,OperateConfigData.class);
// OperateConfigData cd = JsonUtils.read(vc.getWakeUpParmas(),OperateConfigData.class);
configVO.setParamConfig(configDatas);
}
return configVO;
}

View File

@ -61,46 +61,18 @@ public class SimulationVoiceTest {
Simulation simulation = (Simulation)this.simulationManager.getById(simKey);
// String fileData = this.findLocalVoiceFileData("C:\\Users\\joylink\\Desktop\\voice\\5.txt");
// ParseData result = this.commandService.voiceCommand(simulation,"道岔p0707定位");
// System.out.println(result);
}
@Test
public void testSource(){
LoginUserInfoVO userInfoVO = this.getInfo();
String simKey = simulationService.createSimulation(10601L,userInfoVO);
Simulation simulation = (Simulation)this.simulationManager.getById(simKey);
// String fileData = this.findLocalVoiceFileData("C:\\Users\\joylink\\Desktop\\voice\\5.txt");
// ParseData result = this.commandService.voiceCommand(simulation,"办理p0707道岔定位");
// System.out.println(result);
}
@Test
public void testSource2() throws IOException {
LoginUserInfoVO userInfoVO = this.getInfo();
String simKey = simulationService.createSimulation(10601L,userInfoVO);
Simulation simulation = (Simulation)this.simulationManager.getById(simKey);
String fileData = this.findLocalVoiceFileData("C:\\Users\\joylink\\Desktop\\voice\\5.txt");
List<WorkResult> results = this.commandService.voiceCommand(simulation,fileData);
for (WorkResult result : results) {
System.out.println(result);
}
}
@Test
public void newTest(){
LoginUserInfoVO userInfoVO = this.getInfo();
String simKey = simulationService.createSimulation(10601L,userInfoVO);
Simulation simulation = (Simulation)this.simulationManager.getById(simKey);
List<WorkResult> results = this.commandService.voiceCommand(simulation,"道岔帮你p07017道岔定位");
for (WorkResult result : results) {
System.out.println(result);
}
}
@Test
public void newTestStand(){
LoginUserInfoVO userInfoVO = this.getInfo();
String simKey = simulationService.createSimulation(10642L,userInfoVO);
Simulation simulation = (Simulation)this.simulationManager.getById(simKey);
List<WorkResult> results = this.commandService.voiceCommand(simulation,"办理车站十上行站台扣车");
List<WorkResult> results = this.commandService.voiceCommand(simulation,"道岔p0707定位");
// List<WorkResult> results = this.commandService.voiceCommand(simulation,"办理车站十上行站台扣车");
// List<WorkResult> results = this.commandService.voiceCommand(simulation,"办理车站1上行站台扣车");
for (WorkResult result : results) {
System.out.println(result);

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.services.voice.impl.VoiceConfigDataService;
import club.joylink.rtss.simulation.cbtc.command.voice2.operate.OperateEnum;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.OperateConfigData;
import club.joylink.rtss.simulation.cbtc.command.voice2.vo.WakeUpParam;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.LoginUserInfoVO;
@ -38,16 +39,39 @@ public class VoiceDataManageTest {
VoiceConfigDataVO dataVO = new VoiceConfigDataVO();
dataVO.setDescribe("测试");
dataVO.setMapId(63L);
dataVO.setWakeUpParmas(List.of("道岔"));
WakeUpParam wakeUpParam = new WakeUpParam();
wakeUpParam.setWakeups(new String[]{"道岔"});
wakeUpParam.setOperates(new String[]{"定位"});
dataVO.setWakeUpParmas(wakeUpParam);
dataVO.setDeviceType(MapElement.DeviceType.SWITCH);
dataVO.setOperateType(OperateEnum.SWITCH_DINGWEI);
OperateConfigData configData = new OperateConfigData();
// configData.setOperate(OperateEnum.SWITCH_DINGWEI);
configData.setActionKW(new String[]{"定位"});
dataVO.setParamConfig(configData);
configData.setDeviceType(MapElement.DeviceType.SWITCH);
configData.setDeviceNameType(OperateConfigData.DeviceNameType.NAME);
dataVO.setParamConfig(List.of(configData));
dataService.saveOrUpdate(dataVO,this.getInfo());
}
@Test
public void insert2(){
VoiceConfigDataVO dataVO = new VoiceConfigDataVO();
dataVO.setDescribe("测试站台");
dataVO.setMapId(63L);
WakeUpParam wakeUpParam = new WakeUpParam();
wakeUpParam.setWakeups(new String[]{"站台"});
wakeUpParam.setOperates(new String[]{"扣车"});
dataVO.setWakeUpParmas(wakeUpParam);
dataVO.setDeviceType(MapElement.DeviceType.STAND);
dataVO.setOperateType(OperateEnum.STAND_UP_HOLD_TRAIN);
OperateConfigData configData = new OperateConfigData();
configData.setDeviceType(MapElement.DeviceType.STAND);
configData.setDeviceNameType(OperateConfigData.DeviceNameType.CODE);
// configData.setRegexs(new String[]{"办理(.*)道岔定位","(.*?)道岔定位"});
dataVO.setParamConfig(List.of(configData));
dataService.saveOrUpdate(dataVO,this.getInfo());
}
@Test
public void changeStatus(){
dataService.changeStatus(1L,2);