TbVmsCtlrDto.java 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. package com.its.vms.dto;
  2. import com.its.app.AppUtils;
  3. import com.its.app.utils.SysUtils;
  4. import com.its.vms.config.ApplicationConfig;
  5. import com.its.vms.config.DebugConfig;
  6. import com.its.vms.domain.*;
  7. import com.its.vms.domain.enums.eVmsFormType;
  8. import com.its.vms.domain.task.VmsCommandTimeoutTask;
  9. import com.its.vms.entity.TbVmsCtlr;
  10. import com.its.vms.entity.TbVmsCtlrStts;
  11. import com.its.vms.entity.TbVmsCtrlHs;
  12. import com.its.vms.entity.VmsCtlrParam;
  13. import com.its.vms.process.DbmsData;
  14. import com.its.vms.process.DbmsDataProcess;
  15. import com.its.vms.process.DbmsDataType;
  16. import com.its.vms.service.VmsFormService;
  17. import com.its.vms.xnettcp.vms.handler.VmsServerIdleStateHandler;
  18. import com.its.vms.xnettcp.vms.process.TcpServerSendData;
  19. import com.its.vms.xnettcp.vms.process.TcpServerSendDataProcess;
  20. import com.its.vms.xnettcp.vms.protocol.VmsReqFramePacket;
  21. import com.its.vms.xnettcp.vms.protocol.dto.*;
  22. import com.its.vms.xnettcp.vms.protocol.enums.eVmsFileSaveLocation;
  23. import com.its.vms.xnettcp.vms.protocol.enums.eVmsFormObjectKind;
  24. import com.its.vms.xnettcp.vms.protocol.enums.eVmsImageType;
  25. import com.its.vms.xnettcp.vms.protocol.enums.eVmsOpCode;
  26. import com.its.vms.xnettcp.vms.protocol.impl.*;
  27. import io.netty.channel.Channel;
  28. import io.netty.channel.ChannelFuture;
  29. import io.netty.channel.ChannelHandlerContext;
  30. import lombok.*;
  31. import lombok.extern.slf4j.Slf4j;
  32. import java.io.Serializable;
  33. import java.net.InetSocketAddress;
  34. import java.nio.ByteBuffer;
  35. import java.text.SimpleDateFormat;
  36. import java.util.List;
  37. import java.util.Map;
  38. import java.util.Timer;
  39. import java.util.concurrent.ConcurrentHashMap;
  40. @Slf4j
  41. @Getter
  42. @Setter
  43. @ToString
  44. @Builder
  45. @NoArgsConstructor//(access = AccessLevel.PROTECTED)
  46. @AllArgsConstructor
  47. public class TbVmsCtlrDto implements Serializable {
  48. private static final long serialVersionUID = 1L;
  49. private int index;
  50. private Long vmsCtlrNmbr;
  51. private Long groupNo;
  52. private Integer ctlrLocalNo;
  53. private String ctlrId;
  54. private String name;
  55. private String ctlrIp;
  56. private String ctlrPort;
  57. private String usagTypeCd;
  58. private String frmTypeCd;
  59. private String typeCd;
  60. private String modlTypeCd;
  61. private String operMode;
  62. private Integer cmncfailSlotNmbr;
  63. private Integer pwerFailSlotNmbr;
  64. private String cmtrinfrCnctYn;
  65. private String wthrinfrCnctYn;
  66. private String envrinfrCnctYn;
  67. private Integer maxPhaseNum;
  68. private String istlLctnNm;
  69. private String istlLctnAddr;
  70. private String trfcStrgUseYn;
  71. private Long locIfscId;
  72. private Integer defPhseChngCycl; // 기본메시지주기
  73. private String panlOnTime; // 전광판 ON TIME
  74. private String panlOffTime; // 전광판 OFF TIME
  75. private Integer panlPwerMode; // 전광판 전원 모드(0x00:꺼짐,0x01:켜짐,0x02:자동,0x09:알수없음)
  76. private Integer fanMode; // FAN 동작모드(0x00:꺼짐,0x01:켜짐,0x02:자동,0x09:알수없음)
  77. private Integer fanRunTmpr; // 팬 동작 온도
  78. private Integer hetrMode; // 히터 동작모드(0x00:꺼짐,0x01:켜짐,0x02:자동,0x09:알수없음)
  79. private Integer hetrRunTmpr; // 히터 동작 온도
  80. private Integer brghMode; // 휘도 모드(0x00:주간,0x01:야간,0x02:자동,0x09:수동)
  81. private Integer brghCurrStep; // 휘도 현재 단계(0~100)
  82. private Integer brghWeekStep; // 휘도 주간 단계(0~100)
  83. private Integer brghNghtStep; // 휘도 야간 단계(0~100)
  84. private Integer modlErrRate; // VMS 모듈 오류 율
  85. private Integer cmncFailRate; // VMS 통신 오류 기본 값
  86. private Integer protocolVer;
  87. private String delYn;
  88. private int vmsWidth;
  89. private int vmsHeight;
  90. private int modlRowNum;
  91. private int modlColNum;
  92. private int powrRowNum;
  93. private int powrColNum;
  94. private String localFormDir;
  95. private String ftpFormDir;
  96. private boolean ftpDownload;
  97. private boolean symbolDownload;
  98. private int maxCngstForm; // 정체폼 생성 최대 갯수
  99. private int cngstForms;
  100. private boolean existCngsForm;
  101. private boolean provide;
  102. private boolean evehIngForm;
  103. private boolean evehEndForm;
  104. private VmsFormManager formManager;
  105. /**
  106. * VMS 메시지 생성 메모리
  107. */
  108. private VmsEvehicle evechile;
  109. private VmsSchedule schedule; // 스케쥴 정보
  110. private VmsEvent incident; // 돌발정보
  111. private VmsEvent event; // 공사행사정보
  112. private VmsModule module;
  113. private VmsLuminance luminance;
  114. private VmsControlMode controlMode;
  115. private byte txtOpCode;
  116. private TbVmsCtlrStts stts;
  117. private int netState;
  118. private boolean isDupCon;
  119. private boolean isDupLogin;
  120. private String dstIpAddr;
  121. private Channel channel = null;
  122. private Channel dupChannel = null;
  123. private InetSocketAddress cliReq;
  124. private long syncTime;
  125. private VmsFrameSequence seq;
  126. private Integer downloadFormId;
  127. private VmsDownloadFile downloadFile; // 제어기로 다운로드할 파일정보(TB_VMS_DOWNLOAD)
  128. private VmsDownloadData downloadData; // 제어기로 다운로드할 파일 데이터
  129. private ConcurrentHashMap<Integer, VmsDownloadForm> downloadFormMap = null;
  130. private ConcurrentHashMap<Integer, TbVmsSymbLibDnldDto> dnldSymbMap = null;
  131. private ConcurrentHashMap<Integer, VmsScheduleSymbDto> reqDnldSymbMap;
  132. Integer dnldSymbLibNmbr;
  133. private ConcurrentHashMap<Long, TbVmsRltnIfscDto> rltnIfscMap = null; // VMS 에 설정된 VMS 정보제공구간 목록
  134. private ConcurrentHashMap<Short, Timer> registeredCommandTimer = null;
  135. private ConcurrentHashMap<Short, VmsCommandTimeoutTask> registeredCommand = null;
  136. private ConcurrentHashMap<Long, TbVmsCtrlHs> userCommands = null;
  137. private int connectCount;
  138. private String connectTm;
  139. private String disConnectTm;
  140. private long lastRecvTime;
  141. private VmsDebug debug;
  142. private TcpServerSendDataProcess dataProcess; // 제어기로 데이터를 전송할 전송 전송 큐를 처리할 스레드
  143. public void init() {
  144. this.debug = new VmsDebug();
  145. this.stts = new TbVmsCtlrStts(this.vmsCtlrNmbr);
  146. this.seq = new VmsFrameSequence();
  147. this.downloadFormMap = new ConcurrentHashMap<>();
  148. this.dnldSymbMap = new ConcurrentHashMap<>();
  149. this.reqDnldSymbMap = new ConcurrentHashMap<>();
  150. this.dnldSymbLibNmbr = 0;
  151. this.registeredCommandTimer = new ConcurrentHashMap<>();
  152. this.registeredCommand = new ConcurrentHashMap<>();
  153. this.userCommands = new ConcurrentHashMap<>();
  154. this.rltnIfscMap = new ConcurrentHashMap<>();
  155. this.formManager = new VmsFormManager(this.vmsWidth, this.vmsHeight);
  156. this.evechile = new VmsEvehicle();
  157. this.schedule = new VmsSchedule(); // 스케쥴 정보
  158. this.incident = new VmsEvent(); // 돌발정보
  159. this.event = new VmsEvent(); // 공사행사정보
  160. this.module = new VmsModule();
  161. this.luminance = new VmsLuminance();
  162. this.controlMode = new VmsControlMode();
  163. this.downloadFormId = 0;
  164. this.downloadFile = new VmsDownloadFile();
  165. this.downloadData = new VmsDownloadData();
  166. this.connectCount = 0;
  167. this.connectTm = "-";
  168. this.disConnectTm = "-";
  169. this.lastRecvTime = 0;
  170. this.ftpDownload = false;
  171. this.symbolDownload = false;
  172. this.maxCngstForm = VmsConstants.VMS_MAX_CNGS_FORM;
  173. this.cngstForms = 0;
  174. this.evehIngForm = false;
  175. this.evehEndForm = false;
  176. initDownloadFileInfo();
  177. initDownloadFormDataInfo();
  178. initNet();
  179. this.dataProcess = new TcpServerSendDataProcess(this);
  180. this.dataProcess.run();
  181. }
  182. public String getLogKey() {
  183. return this.ctlrId;
  184. }
  185. /**
  186. * 파일 다운로드 정보 초기화
  187. */
  188. public void initDownloadFileInfo() {
  189. this.downloadFile.setEnable(false);
  190. this.downloadFile.setSaveFlag(true);
  191. this.downloadFile.setDTimer(System.currentTimeMillis());
  192. this.downloadFile.setCount(0);
  193. }
  194. /**
  195. * 폼 파일 다운로드 정보를 초기화
  196. * @return
  197. */
  198. public void initDownloadFormDataInfo() {
  199. this.downloadData.init();
  200. this.downloadFormMap.forEach((formId, obj) -> {
  201. obj.setAlreadyDownload(false);
  202. });
  203. }
  204. /**
  205. * 제어기 전송 패킷의 패킷 번호를 구한다.
  206. * @return
  207. */
  208. public short getSeqNext() {
  209. return this.seq.nextValue();
  210. }
  211. /**
  212. * 제어기 전송 스레드 타스크 큐에 명령을 전송
  213. * @param data
  214. * @return
  215. */
  216. public synchronized boolean addRequestData(TcpServerSendData data) {
  217. return this.dataProcess.add(data);
  218. }
  219. /**
  220. * 제어기 네트워크 최초 접속시 발생 이벤트
  221. * @param ctx
  222. */
  223. public synchronized void connected(ChannelHandlerContext ctx) {
  224. this.netState = NET.LOGIN_REQ;
  225. this.connectTm = SysUtils.getSysTimeStr();
  226. this.channel = ctx.channel();
  227. this.lastRecvTime = System.currentTimeMillis();
  228. this.connectCount++;
  229. this.stts.initNormal();
  230. clearRegisteredCommandTimer();
  231. }
  232. /**
  233. * 제어기 네트워크 연결 종료 이벤트
  234. */
  235. public synchronized void disconnected() {
  236. clearRegisteredCommandTimer();
  237. this.netState = NET.CLOSED;
  238. this.channel = null;
  239. this.disConnectTm = SysUtils.getSysTimeStr();
  240. this.stts.initError();
  241. }
  242. public String getLastRecvTimeFmt() {
  243. SimpleDateFormat sdfDate = new SimpleDateFormat("MM-dd HH:mm:ss");
  244. return sdfDate.format(this.lastRecvTime);
  245. }
  246. public void resetConnectCount() {
  247. if (this.netState == NET.CLOSED)
  248. this.connectCount = 0;
  249. else
  250. this.connectCount = 1;
  251. }
  252. void initNet() {
  253. this.netState = NET.CLOSED;
  254. this.isDupCon = false;
  255. this.isDupLogin = false;
  256. this.dstIpAddr = "";
  257. this.channel = null;
  258. this.dupChannel = null;
  259. this.cliReq = null;
  260. this.syncTime = 0;
  261. }
  262. /**
  263. * 제어기 명령 타임아웃 타스크 클리어
  264. */
  265. public synchronized void clearRegisteredCommandTimer() {
  266. this.registeredCommand.clear();
  267. for (Map.Entry<Short, Timer> e : this.registeredCommandTimer.entrySet()) {
  268. Timer task = e.getValue();
  269. task.cancel();
  270. }
  271. this.registeredCommandTimer.clear();
  272. }
  273. /**
  274. * 제어기 명령 타임아웃 타스크 추가
  275. * @param cmdTimeoutTask
  276. * @return
  277. */
  278. public synchronized void addRegisteredCommandsTimer(VmsCommandTimeoutTask cmdTimeoutTask) {
  279. long timeoutSec = 1000L * 5;
  280. Timer timer = new Timer();
  281. timer.schedule(cmdTimeoutTask, timeoutSec);
  282. short packetNmbr = (short)(cmdTimeoutTask.getPacket().getOpCode().getValue() & 0xFF);
  283. this.registeredCommandTimer.put(packetNmbr, timer);
  284. this.registeredCommand.put(packetNmbr, cmdTimeoutTask);
  285. log.info("addRegisteredCommandsTimer: VMS {}, Task {} EA, OpCode {}.",
  286. cmdTimeoutTask.getCtlr().getVmsCtlrNmbr(), this.registeredCommandTimer.size(), cmdTimeoutTask.getPacket().getOpCode());
  287. }
  288. /**
  289. * 제어기 명령 타임아웃 타스크 제거
  290. * @param opCode
  291. */
  292. public synchronized void removeRegisteredCommandsTimer(eVmsOpCode opCode) {
  293. short packetNmbr = (short)(opCode.getValue() & 0xFF);
  294. Timer timer = this.registeredCommandTimer.get(packetNmbr);
  295. if (timer != null) {
  296. timer.cancel();
  297. this.registeredCommandTimer.remove(packetNmbr);
  298. }
  299. VmsCommandTimeoutTask cmdTimeoutTask = this.registeredCommand.get(packetNmbr);
  300. if (cmdTimeoutTask != null) {
  301. this.registeredCommand.remove(packetNmbr);
  302. log.info("removeRegisteredCommandsTimer: VMS {}, Task {} EA, OpCode {}.",
  303. cmdTimeoutTask.getCtlr().getVmsCtlrNmbr(), this.registeredCommandTimer.size(), cmdTimeoutTask.getPacket().getOpCode());
  304. }
  305. }
  306. /**
  307. * Channel Send Data
  308. * @param packet
  309. * @param retryCnt
  310. * @return
  311. */
  312. public synchronized boolean sendData(VmsReqFramePacket packet, int retryCnt) {
  313. boolean result = false;
  314. ByteBuffer sendBuffer = packet.getByteBuffer();
  315. String packetDesc = packet.getOpCodeDesc();
  316. log.info("~REQUEST-{}. VMS {}, {} Bytes.", packetDesc, this.vmsCtlrNmbr, sendBuffer.capacity());
  317. if (this.channel != null) {
  318. ChannelFuture f = this.channel.writeAndFlush(sendBuffer);
  319. f.awaitUninterruptibly();
  320. if (f.isDone() || f.isSuccess()) {
  321. result = true;
  322. } else {
  323. log.error("~REQUEST-{}. VMS {}, sendData Failed. {} Bytes.", packetDesc, this.vmsCtlrNmbr, sendBuffer.array().length);
  324. }
  325. } else {
  326. log.error("~REQUEST-{}. VMS {}, sendData Failed. Not Connected. {} Bytes.", packetDesc, this.vmsCtlrNmbr, sendBuffer.array().length);
  327. }
  328. if (result) {
  329. VmsCommandTimeoutTask cmdTimeoutTask = new VmsCommandTimeoutTask(this, packet, retryCnt);
  330. addRegisteredCommandsTimer(cmdTimeoutTask);
  331. }
  332. return result;
  333. }
  334. public boolean channelClose() {
  335. if (getChannel() == null || getNetState() == NET.CLOSED) {
  336. log.error("Close Request: channel not connected: [{}]", this);
  337. return false;
  338. }
  339. VmsServerIdleStateHandler.disconnectChannel(this, getChannel());
  340. return true;
  341. }
  342. public boolean reset() {
  343. if (getChannel() == null || getNetState() == NET.CLOSED) {
  344. log.error("Reset Request: channel not connected: [{}]", this);
  345. return false;
  346. }
  347. VmsReqStatusControl resetControl = new VmsReqStatusControl(this);
  348. resetControl.controlReset();
  349. return addRequestData(new TcpServerSendData(eVmsOpCode.OP_VMS_STATUS_CONTROL, resetControl));
  350. }
  351. public synchronized boolean removeUserCommands(Long packetNmbr) {
  352. TbVmsCtrlHs command = this.userCommands.get(packetNmbr);
  353. if (command != null) {
  354. this.userCommands.remove(packetNmbr);
  355. return true;
  356. }
  357. return false;
  358. }
  359. public synchronized TbVmsCtrlHs getUserCommands(Long packetNmbr) {
  360. TbVmsCtrlHs command = this.userCommands.get(packetNmbr);
  361. return command;
  362. }
  363. public TbVmsCtlr toDto() {
  364. return TbVmsCtlr.builder()
  365. .vmsCtlrNmbr(this.vmsCtlrNmbr)
  366. .vmsCtlrLocalNo(this.ctlrLocalNo)
  367. .vmsCtlrId(this.ctlrId)
  368. .vmsNm(this.name)
  369. .vmsCtlrIp(this.ctlrIp)
  370. .vmsUsagTypeCd(this.usagTypeCd)
  371. .vmsFrmTypeCd(this.frmTypeCd)
  372. .vmsTypeCd(this.typeCd)
  373. .vmsModlTypeCd(this.modlTypeCd)
  374. .vmsCtlrPort(this.ctlrPort)
  375. .operMode(this.operMode)
  376. .cmncFailRate(this.cmncFailRate)
  377. .brghNghtStep(this.brghNghtStep)
  378. .brghWeekStep(this.brghWeekStep)
  379. .defPhseChngCycl(this.defPhseChngCycl)
  380. .modlErrRate(this.modlErrRate)
  381. .cmncfailSlotNmbr(this.cmncfailSlotNmbr)
  382. .pwerFailSlotNmbr(this.pwerFailSlotNmbr)
  383. .delYn(this.delYn)
  384. .cmtrinfrCnctYn(this.cmtrinfrCnctYn)
  385. .wthrinfrCnctYn(this.wthrinfrCnctYn)
  386. .envrinfrCnctYn(this.envrinfrCnctYn)
  387. .vmsMaxPhseNum(this.maxPhaseNum)
  388. .panlOnTime(this.panlOnTime)
  389. .panlOffTime(this.panlOffTime)
  390. .panlPwerMode(this.panlPwerMode)
  391. .brghMode(this.brghMode)
  392. .istlLctnNm(this.istlLctnNm)
  393. .trfcStrgUseYn(this.trfcStrgUseYn)
  394. .vmsLocIfscId(this.locIfscId)
  395. .fanRunTmpr(this.fanRunTmpr)
  396. .hetrRunTmpr(this.hetrRunTmpr)
  397. .fanMode(this.fanMode)
  398. .hetrMode(this.hetrMode)
  399. .brghCurrStep(this.brghCurrStep)
  400. .istlLctnAddr(this.istlLctnAddr)
  401. .protocolVer(this.protocolVer)
  402. .build();
  403. }
  404. /**
  405. * 제어기에 메시지를 표출하기 위한 작업.
  406. * 1. 제어기에 표출할 폼 정보를 다운로드 한다. - downloadForm
  407. * 2. 파일 다운로드(이미지, 심볼) - downloadFile
  408. * 3. 폼 스케쥴 다운로드 - downloadFormSchedule
  409. * 4. Blank - downloadBlank
  410. * @return
  411. */
  412. public boolean downloadForm() {
  413. VmsFormService formService = (VmsFormService) AppUtils.getBean(VmsFormService.class);
  414. DebugConfig debug = (DebugConfig) AppUtils.getBean(DebugConfig.class);
  415. this.txtOpCode = (byte)0x00;
  416. this.downloadData.init();
  417. int forms = 0;
  418. int formCnt = this.formManager.count();
  419. if (formCnt == 0) {
  420. log.info("downloadForm: VMS {}, Form Data Not Found.", this.vmsCtlrNmbr);
  421. return true;
  422. }
  423. if (formCnt > this.maxPhaseNum) {
  424. log.error("downloadForm: VMS {}, Form Count Over: {}/{} EA.", this.vmsCtlrNmbr, formCnt, this.maxPhaseNum);
  425. formCnt = this.maxPhaseNum;
  426. }
  427. VmsDownloadData.VmsDownloadDataInfo[] units = this.downloadData.getUnits();
  428. for (int ii = 0; ii < formCnt; ii++) {
  429. VmsForm pForm = this.formManager.getItem(ii);
  430. if (!pForm.isSuccess()) {
  431. log.error("downloadForm: VMS {}, SEQ {}, SUCCESS {}", this.vmsCtlrNmbr, ii, pForm.isSuccess());
  432. continue;
  433. }
  434. Integer vmsFormId = pForm.getVmsFormId();
  435. TbVmsFormDto vmsForm = formService.find(vmsFormId);
  436. if (vmsForm == null) {
  437. log.error("downloadForm: VMS {}, SEQ {}, FORM ID {} Not Found.", this.vmsCtlrNmbr, ii, vmsFormId);
  438. continue;
  439. }
  440. units[forms].setVmsFormId(vmsFormId);
  441. units[forms].setDownload(true);
  442. units[forms].setFormIdx(ii);
  443. //units[forms].setBitmapId(forms + 1000);
  444. units[forms].setBitmapId(pForm.getDnldFormNo());
  445. units[forms].setFormNo(9000 + forms);
  446. units[forms].setDisplaySec(pForm.getDsplHh());
  447. units[forms].setDisplayType(pForm.getVmsFormDsplMthdCd());
  448. units[forms].setBkClr(pForm.getVmsFormColrCd());
  449. if (vmsForm.getVmsFormTypeCd() == eVmsFormType.eFormTp_hongbo.getValue()) {
  450. // 다운로드 할 폼이 홍보폼이면 여러번 다운로드 하지 않도록 메모리에서 관리하자.
  451. VmsDownloadForm downloadForm = this.downloadFormMap.get(vmsFormId);
  452. if (downloadForm != null) {
  453. // 이전에 다운로드한 폼 정보가 존재하면
  454. if (!vmsForm.getUpdtDt().equals(downloadForm.getUpdtDt())) {
  455. // 업데이트시각이 다르기때문에 신규폼으로 판단한다.
  456. downloadForm.setAlreadyDownload(false);
  457. downloadForm.setUpdtDt(vmsForm.getUpdtDt());
  458. units[forms].setDownload(true); // 현재 스케쥴폼으로 다운로드 플래그 설정
  459. }
  460. if (downloadForm.isAlreadyDownload()) {
  461. // 이미 이전에 다운로드를 했기때문에 이번에는 제어기로 다운로드를 하지 않는다.
  462. units[forms].setDownload(false);
  463. }
  464. }
  465. else {
  466. // 이전에 다운로드 한 정보가 없기때문에 메모리에 저장해 놓는다.
  467. downloadForm = new VmsDownloadForm();
  468. downloadForm.setVmsFormId(vmsFormId);
  469. downloadForm.setAlreadyDownload(false);
  470. downloadForm.setUpdtDt(vmsForm.getUpdtDt());
  471. this.downloadFormMap.put(vmsFormId, downloadForm);
  472. }
  473. }
  474. forms++;
  475. }
  476. if (debug.isDebug()) {
  477. for (int ii = 0; ii < forms; ii++) {
  478. log.info("downloadForm: VMS {}, Form schedule({}), VMS_FORM_ID: {}, FormIdx: {}, FormId: {}, BitmapId: {}, IsDownload: {}",
  479. this.vmsCtlrNmbr, ii, units[ii].getVmsFormId(), units[ii].getFormIdx(), units[ii].getFormNo(), units[ii].getBitmapId(), units[ii].isDownload());
  480. }
  481. }
  482. this.downloadData.setMaxSchedule(forms);
  483. this.downloadData.setDownloadCnt(0);
  484. this.downloadData.setDefault("B".equals(this.operMode));
  485. if (this.downloadData.isDefault()) {
  486. // 기본모드인 경우
  487. // 폼 ID "FID0000" 에 여러개의 폼을 다운로드 해야함.
  488. //e_vms_download_form = 0x9A,// Download Form 송신 Form download 센터 → VMS
  489. //e_vms_file_download = 0x82,// 데이터 다운로드 송신 INI, CFG , Bitmap , Data파일송신 센터 → VMS
  490. //e_vms_download_schedule_form = 0x96,// Display Schedule Form 송신 계획된 Form 표출 요구 센터 → VMS
  491. //e_vms_blank = 0x9E,// Blank 송신 schedule 표출 센터 → VMS
  492. downloadDefaultForm();
  493. }
  494. else {
  495. // 스케쥴 모드인 경우(A:자동, F:고정)
  496. //e_vms_download_form = 0x9A,// Download Form 송신 Form download 센터 → VMS
  497. //e_vms_file_download = 0x82,// 데이터 다운로드 송신 INI, CFG , Bitmap , Data파일송신 센터 → VMS
  498. //e_vms_download_schedule_form = 0x96,// Display Schedule Form 송신 계획된 Form 표출 요구 센터 → VMS
  499. //e_vms_blank = 0x9E,// Blank 송신 schedule 표출 센터 → VMS
  500. downloadAutoFixForm();
  501. }
  502. return true;
  503. }
  504. /**
  505. * 기본 스케쥴의 폼 정보는 하나의 폼 패킷에 다운로드 해야 여러 폼을 표출할 수 있다.
  506. * 제어기에서 FID0000 인 폼이 기본 표출폼 이기 때문이다.
  507. * @return
  508. */
  509. public boolean downloadDefaultForm() {
  510. // Download Form (기본폼은 하나의 폼에 여러폼을 다운로드한다.)
  511. int formCnt = this.downloadData.getMaxSchedule();
  512. if (formCnt <= 0) {
  513. log.info("downloadDefaultForm: VMS {}, Download Schedule Form Count Zero. {} EA.", this.vmsCtlrNmbr, formCnt);
  514. return true;
  515. }
  516. log.info("downloadDefaultForm: VMS {}, Form {} EA.", this.vmsCtlrNmbr, formCnt);
  517. VmsFormDataDto formData = new VmsFormDataDto(VmsConstants.DEFAULT_FORM_ID, formCnt);
  518. VmsDownloadData.VmsDownloadDataInfo[] units = this.downloadData.getUnits();
  519. for (int ii = 0; ii < formCnt; ii++) {
  520. VmsForm pForm = this.formManager.getItem(units[ii].getFormIdx());
  521. int formBitmapId = units[ii].getBitmapId();
  522. int formBlinking = pForm.getVmsFormDsplMthdCd();
  523. int formBkClr = units[ii].getBkClr();
  524. int formDisplayType = units[ii].getDisplayType();
  525. int formDisplaySec = units[ii].getDisplaySec();
  526. Integer vmsFormId = units[ii].getVmsFormId();
  527. if (pForm.isObjectDownload()) {
  528. // 모든 객체를 추가해 줘야 한다.
  529. List<VmsFormObject> objects = pForm.getObjects();
  530. VmsFormDto formDto = formData.addForm(vmsFormId, formDisplaySec, formDisplayType, formBkClr, objects.size());
  531. for (int jj = 0; jj < objects.size(); jj++) {
  532. VmsFormObject formObj = objects.get(jj);
  533. int objSize = formObj.getObjectSize();
  534. int blinking = formObj.getBlinking();
  535. int posX = formObj.getPosX();
  536. int posY = formObj.getPosY();
  537. int bkClr = formObj.getBkColor();
  538. VmsFormObj formObjDto = null;
  539. if (objects.get(jj).getObjectKind() == eVmsFormObjectKind.OBJECT_TEXT) {
  540. int clrR = formObj.getFontClr().getRed();
  541. int clrG = formObj.getFontClr().getGreen();
  542. int clrB = formObj.getFontClr().getBlue();
  543. formObjDto = new VmsFormObjText(objSize, blinking, posX, posY, bkClr, clrR, clrG, clrB, formObj.getFontSize(), formObj.getFontNameCd(), formObj.getFontBold(), formObj.getTextData());
  544. }
  545. else if (objects.get(jj).getObjectKind() == eVmsFormObjectKind.OBJECT_BITMAP_ID) {
  546. formObjDto = new VmsFormObjBitmapId(objSize, blinking, posX, posY, bkClr, formObj.getDsplWidth(), formObj.getDsplHeight(), eVmsImageType.VMS_IMAGE_TYPE_BMP.getValue(), units[ii].getBitmapId());
  547. }
  548. else if (objects.get(jj).getObjectKind() == eVmsFormObjectKind.OBJECT_VIDEO_FILE) {
  549. formObjDto = new VmsFormObjVideo(objSize, blinking, posX, posY, bkClr, formObj.getDsplWidth(), formObj.getDsplHeight(), formObj.getVideoFileName());
  550. }
  551. else if (objects.get(jj).getObjectKind() == eVmsFormObjectKind.OBJECT_STREAM_URL) {
  552. formObjDto = new VmsFormObjStream(objSize, blinking, posX, posY, bkClr, formObj.getDsplWidth(), formObj.getDsplHeight(), formObj.getStrmAddr());
  553. }
  554. else {
  555. formObjDto = new VmsFormObjBitmap(objSize, blinking, posX, posY, bkClr, formObj.getDsplWidth(), formObj.getDsplHeight(), eVmsImageType.VMS_IMAGE_TYPE_BMP.getValue(), formObj.getImageData());
  556. }
  557. formObjDto.calSize();
  558. formDto.addObject(formObjDto);
  559. }
  560. }
  561. else {
  562. // 이미지를 통째로 다운로드 한다.
  563. VmsFormDto formDto = formData.addForm(vmsFormId, formDisplaySec, formDisplayType, formBkClr, 1);
  564. VmsFormObj formObjDto = new VmsFormObjBitmapId(1, formBlinking, 0, 0, formBkClr, this.vmsWidth, this.vmsHeight, eVmsImageType.VMS_IMAGE_TYPE_BMP.getValue(), formBitmapId);
  565. formObjDto.calSize();
  566. formDto.addObject(formObjDto);
  567. }
  568. }
  569. formData.calFormCount();
  570. VmsReqDownloadForm downloadForm = new VmsReqDownloadForm(this, formData);
  571. return sendData(downloadForm, 1);
  572. }
  573. /**
  574. * 자동 및 고정 스케쥴인 경우 폼정보 하나를 하나의 패킷으로 전송한다.
  575. * @return
  576. */
  577. public boolean downloadAutoFixForm() {
  578. // Download Form (패킷하나에 하나의 폼 정보를 다운로드한다.)
  579. DebugConfig debug = (DebugConfig) AppUtils.getBean(DebugConfig.class);
  580. int formCnt = this.downloadData.getMaxSchedule();
  581. if (formCnt <= 0) {
  582. log.info("downloadAutoFixForm: VMS {}, Download Schedule Form Count Zero. {} EA.", this.vmsCtlrNmbr, formCnt);
  583. return true;
  584. }
  585. int downloadCnt = this.downloadData.getDownloadCnt();
  586. log.info("downloadAutoFixForm: VMS {}, Schedule Form {} EA, Download Count {} EA.", this.vmsCtlrNmbr, formCnt, downloadCnt);
  587. if (downloadCnt >= formCnt) {
  588. // 폼정보를 모두 다운로드 했기때문에 폼파일을 다운로드 해야 한다.
  589. this.downloadData.setDownloadCnt(0); // 폼이미지파일을 다운로드해야 하기때문에 다운로드 인덱스를 다시 0으로 리셋
  590. return downloadFile();
  591. }
  592. // 폼아이디는 제어기가 최초에 접속했을때 한번만 내려보내기 때문에
  593. // 폼아이디를 여기서 설정해 주어야 한다.
  594. VmsDownloadData.VmsDownloadDataInfo[] units = this.downloadData.getUnits();
  595. int formIdx = units[downloadCnt].getFormIdx();
  596. VmsForm pForm = this.formManager.getItem(formIdx);
  597. int formBitmapId = units[downloadCnt].getBitmapId();
  598. int formBlinking = pForm.getVmsFormDsplMthdCd();
  599. int formBkClr = units[downloadCnt].getBkClr();
  600. int formDisplayType = units[downloadCnt].getDisplayType();
  601. int formDisplaySec = units[downloadCnt].getDisplaySec();
  602. Integer vmsFormId = units[downloadCnt].getVmsFormId();
  603. int formId = units[downloadCnt].getFormNo();
  604. int downloadFormCnt = 1;
  605. VmsFormDataDto formData = new VmsFormDataDto(formId, downloadFormCnt);
  606. if (pForm.isObjectDownload()) {
  607. // 모든 객체를 추가해 줘야 한다.
  608. List<VmsFormObject> objects = pForm.getObjects();
  609. VmsFormDto formDto = formData.addForm(vmsFormId, formDisplaySec, formDisplayType, formBkClr, objects.size());
  610. for (int jj = 0; jj < objects.size(); jj++) {
  611. VmsFormObject formObj = objects.get(jj);
  612. int objSize = formObj.getObjectSize();
  613. int blinking = formObj.getBlinking();
  614. int posX = formObj.getPosX();
  615. int posY = formObj.getPosY();
  616. int bkClr = formObj.getBkColor();
  617. VmsFormObj formObjDto;
  618. if (objects.get(jj).getObjectKind() == eVmsFormObjectKind.OBJECT_TEXT) {
  619. int clrR = formObj.getFontClr().getRed();
  620. int clrG = formObj.getFontClr().getGreen();
  621. int clrB = formObj.getFontClr().getBlue();
  622. formObjDto = new VmsFormObjText(objSize, blinking, posX, posY, bkClr, clrR, clrG, clrB, formObj.getFontSize(), formObj.getFontNameCd(), formObj.getFontBold(), formObj.getTextData());
  623. }
  624. else if (objects.get(jj).getObjectKind() == eVmsFormObjectKind.OBJECT_BITMAP_ID) {
  625. formObjDto = new VmsFormObjBitmapId(objSize, blinking, posX, posY, bkClr, formObj.getDsplWidth(), formObj.getDsplHeight(), eVmsImageType.VMS_IMAGE_TYPE_BMP.getValue(), units[downloadCnt].getBitmapId());
  626. }
  627. else if (objects.get(jj).getObjectKind() == eVmsFormObjectKind.OBJECT_VIDEO_FILE) {
  628. formObjDto = new VmsFormObjVideo(objSize, blinking, posX, posY, bkClr, formObj.getDsplWidth(), formObj.getDsplHeight(), formObj.getVideoFileName());
  629. }
  630. else if (objects.get(jj).getObjectKind() == eVmsFormObjectKind.OBJECT_STREAM_URL) {
  631. formObjDto = new VmsFormObjStream(objSize, blinking, posX, posY, bkClr, formObj.getDsplWidth(), formObj.getDsplHeight(), formObj.getStrmAddr());
  632. }
  633. else {
  634. formObjDto = new VmsFormObjBitmap(objSize, blinking, posX, posY, bkClr, formObj.getDsplWidth(), formObj.getDsplHeight(), eVmsImageType.VMS_IMAGE_TYPE_BMP.getValue(), formObj.getImageData());
  635. }
  636. formObjDto.calSize();
  637. formDto.addObject(formObjDto);
  638. }
  639. }
  640. else {
  641. VmsFormDto formDto = formData.addForm(vmsFormId, formDisplaySec, formDisplayType, formBkClr, 1);
  642. VmsFormObj formObjDto = new VmsFormObjBitmapId(1, formBlinking, 0, 0, formBkClr, this.vmsWidth, this.vmsHeight, eVmsImageType.VMS_IMAGE_TYPE_BMP.getValue(), formBitmapId);
  643. formObjDto.calSize();
  644. formDto.addObject(formObjDto);
  645. }
  646. formData.calFormCount();
  647. this.downloadData.setDownloadCnt(downloadCnt+1);
  648. if (debug.isDebug()) {
  649. log.info("downloadAutoFixForm: VMS {}, Schedule Form {} EA, Download Count {} EA, VmsFormId {}, FormId {}, BitmapId {}.",
  650. this.vmsCtlrNmbr, formCnt, downloadCnt + 1, pForm.getVmsFormId(), formId, formBitmapId);
  651. }
  652. VmsReqDownloadForm downloadForm = new VmsReqDownloadForm(this, formData);
  653. return sendData(downloadForm, 1);
  654. }
  655. /**
  656. * 폼 이미지 및 기타 폼에 표출할 심볼 이미지가 다운로드 완료가 된후에 스케쥴 정보를 표출하도록 한다.
  657. * @return
  658. */
  659. public boolean downloadFile() {
  660. DebugConfig debug = (DebugConfig) AppUtils.getBean(DebugConfig.class);
  661. int formCnt = this.downloadData.getMaxSchedule();
  662. if (formCnt <= 0) {
  663. log.info("downloadFile: VMS {}, Download Schedule Form Count Zero. {} EA.", this.vmsCtlrNmbr, formCnt);
  664. return true;
  665. }
  666. int downloadCnt = this.downloadData.getDownloadCnt();
  667. log.info("downloadFile: VMS {}, Schedule Form {} EA, Download Count {} EA.", this.vmsCtlrNmbr, formCnt, downloadCnt);
  668. if (downloadCnt >= formCnt) {
  669. // 폼파일이(폼이미지파일) 모두 다운로드 되었으므로 스케쥴 정보를 다운로드 한다.
  670. return downloadFormSchedule(); // Display Schedule Form
  671. }
  672. this.downloadFormId = 0;
  673. ApplicationConfig config = (ApplicationConfig)AppUtils.getBean(ApplicationConfig.class);
  674. VmsDownloadData.VmsDownloadDataInfo[] units = this.downloadData.getUnits();
  675. for (int ii = downloadCnt; ii < formCnt; ii++) {
  676. this.downloadData.setDownloadCnt(downloadCnt+1);
  677. int vmsFormId = units[ii].getVmsFormId();
  678. int formId = units[ii].getFormNo();
  679. int bitmapId = units[ii].getBitmapId();
  680. int formIdx = units[ii].getFormIdx();
  681. VmsForm pForm = this.formManager.getItem(formIdx);
  682. if (pForm.getVmsFormTypeCd() == eVmsFormType.eFormTp_hongbo.getValue()) {
  683. // 홈보폼인 경우 다운로드 폼 ID를 저장해 놓는다.
  684. this.downloadFormId = vmsFormId;
  685. }
  686. if (config.isCheckNewForm() && !units[ii].isDownload()) {
  687. // 이미 다운로드 했기 때문에 다시 다운로드 하지 않는다.
  688. log.info("downloadFile: VMS {}, IDX {}, VmsFormId {}, FormId {}, BitmapId {}, formIdx {}, DownloadFormID: {}, already download...",
  689. this.vmsCtlrNmbr, ii, vmsFormId, formId, bitmapId, formIdx, this.downloadFormId);
  690. this.downloadFormId = 0;
  691. continue;
  692. }
  693. if (debug.isDebug()) {
  694. log.info("downloadFile: VMS {}, Idx {}, VmsFormId {}, FormId {}, BitmapId {}, formIdx {}, DownloadFormID: {}",
  695. this.vmsCtlrNmbr, ii, pForm.getVmsFormId(), formId, bitmapId, formIdx, this.downloadFormId);
  696. }
  697. String fileName = String.format("BID%04d.BMP", bitmapId);
  698. eVmsFileSaveLocation saveLoc = eVmsFileSaveLocation.LOC_DOWNLOAD_PROG_IMAGE;
  699. VmsReqDataDownload dataDownload = new VmsReqDataDownload(this, saveLoc, fileName, pForm.getImageData());
  700. return sendData(dataDownload, 1);
  701. }
  702. // 폼이미지 정보가 모두 다운로드 되었으므로 스케쥴 정보를 다운로드 한다.
  703. return downloadFormSchedule(); // Display Schedule Form
  704. }
  705. /**
  706. * 제어기에 표출할 폼의 스케쥴 정보를 다운로드 한다.
  707. * @return
  708. */
  709. public boolean downloadFormSchedule() {
  710. // 도로공사 표준에 최대 10개의 스케쥴을 사용하도록 되어 있음.
  711. DebugConfig debug = (DebugConfig) AppUtils.getBean(DebugConfig.class);
  712. int maxSchedule = VmsConstants.VMS_MIN_DOWNLOAD_FORMS;
  713. int formCnt = this.downloadData.getMaxSchedule();
  714. if (formCnt <= 0) {
  715. log.info("downloadScheduleForm: VMS {}, Download Schedule Form Count Zero. {} EA.", this.vmsCtlrNmbr, formCnt);
  716. return true;
  717. }
  718. short[] formId = new short[maxSchedule];
  719. byte[] dispSec = new byte[maxSchedule];
  720. for (int ii = 0; ii < maxSchedule; ii++) {
  721. formId[ii] = 0;
  722. dispSec[ii] = 0;
  723. }
  724. log.info("downloadFormSchedule: VMS {}, Schedule {} EA, Default Schedule {}.", this.vmsCtlrNmbr, formCnt, this.downloadData.isDefault());
  725. if (this.downloadData.isDefault()) {
  726. formId[0] = (short)VmsConstants.DEFAULT_FORM_ID;
  727. dispSec[0] = 0;
  728. VmsDownloadData.VmsDownloadDataInfo[] units = this.downloadData.getUnits();
  729. for (int ii = 0; ii < formCnt; ii++) {
  730. dispSec[0] += units[ii].getDisplaySec();
  731. }
  732. log.info("downloadFormSchedule: VMS {}, Schedule {} EA, Default Schedule {}.", this.vmsCtlrNmbr, formCnt, this.downloadData.isDefault());
  733. }
  734. else {
  735. for (int ii = 0; ii < formCnt && ii < maxSchedule; ii++) {
  736. formId[ii] = (short) this.downloadData.getUnits()[ii].getFormNo();
  737. dispSec[ii] = (byte)(this.downloadData.getUnits()[ii].getDisplaySec() & 0xFF);
  738. if (debug.isDebug()) {
  739. log.info("downloadFormSchedule: VMS {}, Schedule {} EA, Idx {}, FormId {}, DisplayTm {}.", this.vmsCtlrNmbr, formCnt, ii + 1, formId[ii], dispSec[ii]);
  740. }
  741. }
  742. }
  743. VmsReqDownloadFormSchedule downloadFormSchedule = new VmsReqDownloadFormSchedule(this, formId, dispSec);
  744. return sendData(downloadFormSchedule, 1);
  745. }
  746. /**
  747. * 스케쥴을 표출하도록 Blank 명령을 전송한다.
  748. * @return
  749. */
  750. public boolean downloadBlank() {
  751. log.info("downloadBlank: VMS {}.", this.vmsCtlrNmbr);
  752. VmsReqBlank reqBlank = new VmsReqBlank(this);
  753. return sendData(reqBlank, 1);
  754. }
  755. /**
  756. * 제어기로 심벌라이브러리를 다운로드한다.
  757. * @return
  758. */
  759. public boolean downloadSymbLib() {
  760. this.dnldSymbLibNmbr = 0;
  761. if (this.reqDnldSymbMap.size() == 0) {
  762. return false;
  763. }
  764. VmsScheduleSymbDto dnldSymb = null;
  765. for (Map.Entry<Integer, VmsScheduleSymbDto> e : this.reqDnldSymbMap.entrySet()) {
  766. dnldSymb = e.getValue();
  767. break;
  768. }
  769. if (dnldSymb != null) {
  770. this.dnldSymbLibNmbr = dnldSymb.getDnldSymbLibNmbr();
  771. String fileName = String.format("BID%04d.BMP", this.dnldSymbLibNmbr);
  772. eVmsFileSaveLocation saveLoc = eVmsFileSaveLocation.LOC_DOWNLOAD_PROG_IMAGE;
  773. log.info("downloadSymbLib: VMS {}, fileName {} .", this.vmsCtlrNmbr, fileName);
  774. VmsReqDataDownload dataDownload = new VmsReqDataDownload(this, saveLoc, fileName, dnldSymb.getImageData());
  775. sendData(dataDownload, 1);
  776. return true;
  777. }
  778. return false;
  779. }
  780. /*
  781. private int powerCtrlMode; // 전원제어 모드 1 Byte 0x00 : 꺼짐, 0x01 : 켜짐,
  782. private int fanRunMode; // Fan 동작모드 1 Byte 0x00 : 꺼짐, 0x01 : 켜짐, 0x02 : 자동, 0x09: Unknown
  783. private int fanRunTemp; // Fan 의 동작개시온도 1 Byte 온도( 0x00 ~0x03f )
  784. private int heaterRunMode; // Heater 의 동작모드 1 Byte 0x00 : 꺼짐, 0x01 : 켜짐, 0x02 : 자동, 0x09: Unknown
  785. private int heaterRunTemp; // Heater 의 동작개시온도 1 Byte 온도(0x00 ~ 0x3f )
  786. private int brightMode; // 화면의 밝기 - 휘도 모드, 0x00:주간, 0x01:야간, 0x02:Auto, 0x03:수동
  787. private int brightCurr; // 화면의 밝기 - 현재 휘도값, 0~100
  788. private int brightWeek; // 화면의 밝기 - 주간 휘도값, 0~100
  789. private int brightNght; // 화면의 밝기 - 야간 휘도값, 0~100
  790. private int blinkTime; // 깜빡이는 시간주기 1 Byte 문자 비트맵의 깜빡이는 시간주기 0x00 ~ 0x1e( 0.1 ~3.0 )
  791. private short scnTurnTime; // 디폴트 시나리오로 전환시간 2 Byte 디폴트 시나리오로 전환될 때까지 기다리는 시간, 단위 : 초
  792. private int modlErrRate; // 장애 모듈비율(%) 1 Byte 에러난 픽셀의 백분율 (0~100: 초기값:10%)
  793. */
  794. public void updateParameter(int powerCtrlMode, int fanRunMode, int fanRunTemp, int heaterRunMode, int heaterRunTemp,
  795. int brightMode, int brightCurr, int brightWeek, int brightNght, int blinkTime, short scnTurnTime, int modlErrRate) {
  796. boolean isDifferent = false;
  797. if (powerCtrlMode != this.panlPwerMode) {
  798. isDifferent = true;
  799. this.panlPwerMode = powerCtrlMode;
  800. }
  801. if (fanRunMode != this.fanMode) {
  802. isDifferent = true;
  803. this.fanMode = fanRunMode;
  804. }
  805. if (fanRunTemp != this.fanRunTmpr) {
  806. isDifferent = true;
  807. this.fanRunTmpr = fanRunTemp;
  808. }
  809. if (heaterRunMode != this.hetrMode) {
  810. isDifferent = true;
  811. this.hetrMode = heaterRunMode;
  812. }
  813. if (heaterRunTemp != this.hetrRunTmpr) {
  814. isDifferent = true;
  815. this.hetrRunTmpr = heaterRunTemp;
  816. }
  817. if (brightMode != this.brghMode) {
  818. isDifferent = true;
  819. this.brghMode = brightMode;
  820. }
  821. if (brightCurr != this.brghCurrStep) {
  822. isDifferent = true;
  823. this.brghCurrStep = brightCurr;
  824. }
  825. if (brightWeek != this.brghWeekStep) {
  826. isDifferent = true;
  827. this.brghWeekStep = brightWeek;
  828. }
  829. if (brightNght != this.brghNghtStep) {
  830. isDifferent = true;
  831. this.brghNghtStep = brightNght;
  832. }
  833. if (scnTurnTime != this.defPhseChngCycl) {
  834. isDifferent = true;
  835. this.defPhseChngCycl = (int)scnTurnTime;
  836. }
  837. if (modlErrRate != this.modlErrRate) {
  838. isDifferent = true;
  839. this.modlErrRate = modlErrRate;
  840. }
  841. if (isDifferent) {
  842. DbmsDataProcess dbmsDataProcess = (DbmsDataProcess) AppUtils.getBean(DbmsDataProcess.class);
  843. dbmsDataProcess.add(new DbmsData(DbmsDataType.DBMS_DATA_CTLR_PARAMETER, false, toParamEntity()));
  844. }
  845. }
  846. public VmsCtlrParam toParamEntity() {
  847. return VmsCtlrParam.builder()
  848. .vmsCtlrNmbr(this.vmsCtlrNmbr)
  849. .panlPwerMode(this.panlPwerMode)
  850. .fanMode(this.fanMode)
  851. .fanRunTmpr(this.fanRunTmpr)
  852. .hetrMode(this.hetrMode)
  853. .hetrRunTmpr(this.hetrRunTmpr)
  854. .brghMode(this.brghMode)
  855. .brghCurrStep(this.brghCurrStep)
  856. .brghWeekStep(this.brghWeekStep)
  857. .brghNghtStep(this.brghNghtStep)
  858. .modlErrRate(this.modlErrRate)
  859. .cmncFailRate(this.cmncFailRate)
  860. .build();
  861. }
  862. }