IecApplication.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.platform.iec;
  2. import com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration;
  3. import com.platform.iec.master.MasterSysDataHandler;
  4. import com.ydl.iec.iec104.config.Iec104Config;
  5. import com.ydl.iec.iec104.server.Iec104MasterFactory;
  6. import com.ydl.iec.util.Iec104Util;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.boot.CommandLineRunner;
  9. import org.springframework.boot.SpringApplication;
  10. import org.springframework.boot.autoconfigure.SpringBootApplication;
  11. import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  12. import java.util.TimeZone;
  13. /**
  14. * @Description
  15. * @Author chenli
  16. * @Date 2019/7/22
  17. * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
  18. */
  19. @SpringBootApplication(scanBasePackages = {"com.platform"}, exclude = {
  20. DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class})
  21. @Slf4j
  22. public class IecApplication implements CommandLineRunner {
  23. public static void main(String[] args) {
  24. TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
  25. SpringApplication.run(IecApplication.class, args);
  26. }
  27. @Override
  28. public void run(String... args) throws Exception {
  29. log.info("启动主服务,监听iec……………………………………");
  30. Iec104Config iec104Config = new Iec104Config();
  31. iec104Config.setFrameAmountMax((short) 1);
  32. iec104Config.setTerminnalAddress((short) 1);
  33. Iec104MasterFactory.createTcpClientMaster(Iec104Util.host, Iec104Util.port).setDataHandler(new MasterSysDataHandler()).setConfig(iec104Config).run();
  34. Thread.sleep(1000000);
  35. }
  36. /**
  37. * 每小时,五分钟
  38. * {秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}
  39. */
  40. // @Scheduled(cron = "0 */1 * * * ?")
  41. /* private void configureTasks() {
  42. log.info("执行总召唤");
  43. Iec104ThreadLocal.getScheduledTaskPool().sendStartFrame();
  44. Iec104ThreadLocal.getScheduledTaskPool().sendGeneralCall();
  45. log.info("执行总召唤,定时任务时间: " + LocalDateTime.now());
  46. }*/
  47. }