@Test public void testReciveMsg() { TestEngine engine = new TestEngine(); System sys = new System(engine); try { SCSMsg msg = new SCSMsg("*#13**0##"); Calendar now = Config.getInstance().getCurentTime(); sys.reciveMsg(msg); String time = getTime(now); assertEquals("wrong Time",new SCSMsg("*#13**0*" + time + "##"), engine.msgs.poll()); msg = new SCSMsg("*#13**1##"); sys.reciveMsg(msg); String date = getDate(now); assertEquals("wrong Date",new SCSMsg("*#13**1*" + date + "##"), engine.msgs.poll()); } catch (MessageFormatException e) { e.printStackTrace(); } }
@Override public void reciveMsg(SCSMsg msg) { LOGGER.debug("System recived msg: {}", msg); Value value = null; SCSMsg msgResonse = null; if (msg.getWho().getMain() == MUST_WHO && msg.isStatus()) { switch (msg.getProperty().getMain()) { case PM_TIME: if (msg.isStatusProperty()) { msgResonse = this.setTime(msg); } else { value = this.getTime(); } break; case PM_DATE: value = this.getDate(); break; case PM_IP: value = this.getIP(); break; case PM_NETMASK: value = this.getNetMask(); break; case PM_MAC_ADDRESS: value = this.getMac(); break; case PM_SERVER_MODEL: value = this.getModel(); break; case PM_FIRMWARE_VERSION: value = this.getFirmware(); break; case PM_STARTUP_TIME: value = this.getStartUpTime(); break; case PM_TIME_DATE: value = this.getTimeDate(); break; case PM_KERNEL_VERSION: value = this.getKernel(); break; case PM_DISTRIBUTION_VERSION: value = this.getVersion(); break; default: LOGGER.warn("Function not implemented: {}", msg.getProperty().getMain()); } if (value != null) { final Who who = new Who(Integer.toString(MUST_WHO)); msgResonse = new SCSMsg(who, true, msg.getWhere(), null, msg.getProperty(), value); } if (msgResonse != null) { if (this.engine == null) { LOGGER.debug("msg: {}", msgResonse); } else { this.engine.sendCommand(msgResonse, this); } } } else { } }
System extends Thread implements PlugIn { @Override public void reciveMsg(SCSMsg msg) { LOGGER.debug("System recived msg: {}", msg); Value value = null; SCSMsg msgResonse = null; if (msg.getWho().getMain() == MUST_WHO && msg.isStatus()) { switch (msg.getProperty().getMain()) { case PM_TIME: if (msg.isStatusProperty()) { msgResonse = this.setTime(msg); } else { value = this.getTime(); } break; case PM_DATE: value = this.getDate(); break; case PM_IP: value = this.getIP(); break; case PM_NETMASK: value = this.getNetMask(); break; case PM_MAC_ADDRESS: value = this.getMac(); break; case PM_SERVER_MODEL: value = this.getModel(); break; case PM_FIRMWARE_VERSION: value = this.getFirmware(); break; case PM_STARTUP_TIME: value = this.getStartUpTime(); break; case PM_TIME_DATE: value = this.getTimeDate(); break; case PM_KERNEL_VERSION: value = this.getKernel(); break; case PM_DISTRIBUTION_VERSION: value = this.getVersion(); break; default: LOGGER.warn("Function not implemented: {}", msg.getProperty().getMain()); } if (value != null) { final Who who = new Who(Integer.toString(MUST_WHO)); msgResonse = new SCSMsg(who, true, msg.getWhere(), null, msg.getProperty(), value); } if (msgResonse != null) { if (this.engine == null) { LOGGER.debug("msg: {}", msgResonse); } else { this.engine.sendCommand(msgResonse, this); } } } else { } } }
System extends Thread implements PlugIn { @Override public void reciveMsg(SCSMsg msg) { LOGGER.debug("System recived msg: {}", msg); Value value = null; SCSMsg msgResonse = null; if (msg.getWho().getMain() == MUST_WHO && msg.isStatus()) { switch (msg.getProperty().getMain()) { case PM_TIME: if (msg.isStatusProperty()) { msgResonse = this.setTime(msg); } else { value = this.getTime(); } break; case PM_DATE: value = this.getDate(); break; case PM_IP: value = this.getIP(); break; case PM_NETMASK: value = this.getNetMask(); break; case PM_MAC_ADDRESS: value = this.getMac(); break; case PM_SERVER_MODEL: value = this.getModel(); break; case PM_FIRMWARE_VERSION: value = this.getFirmware(); break; case PM_STARTUP_TIME: value = this.getStartUpTime(); break; case PM_TIME_DATE: value = this.getTimeDate(); break; case PM_KERNEL_VERSION: value = this.getKernel(); break; case PM_DISTRIBUTION_VERSION: value = this.getVersion(); break; default: LOGGER.warn("Function not implemented: {}", msg.getProperty().getMain()); } if (value != null) { final Who who = new Who(Integer.toString(MUST_WHO)); msgResonse = new SCSMsg(who, true, msg.getWhere(), null, msg.getProperty(), value); } if (msgResonse != null) { if (this.engine == null) { LOGGER.debug("msg: {}", msgResonse); } else { this.engine.sendCommand(msgResonse, this); } } } else { } } System(EngineManager engine); }
System extends Thread implements PlugIn { @Override public void reciveMsg(SCSMsg msg) { LOGGER.debug("System recived msg: {}", msg); Value value = null; SCSMsg msgResonse = null; if (msg.getWho().getMain() == MUST_WHO && msg.isStatus()) { switch (msg.getProperty().getMain()) { case PM_TIME: if (msg.isStatusProperty()) { msgResonse = this.setTime(msg); } else { value = this.getTime(); } break; case PM_DATE: value = this.getDate(); break; case PM_IP: value = this.getIP(); break; case PM_NETMASK: value = this.getNetMask(); break; case PM_MAC_ADDRESS: value = this.getMac(); break; case PM_SERVER_MODEL: value = this.getModel(); break; case PM_FIRMWARE_VERSION: value = this.getFirmware(); break; case PM_STARTUP_TIME: value = this.getStartUpTime(); break; case PM_TIME_DATE: value = this.getTimeDate(); break; case PM_KERNEL_VERSION: value = this.getKernel(); break; case PM_DISTRIBUTION_VERSION: value = this.getVersion(); break; default: LOGGER.warn("Function not implemented: {}", msg.getProperty().getMain()); } if (value != null) { final Who who = new Who(Integer.toString(MUST_WHO)); msgResonse = new SCSMsg(who, true, msg.getWhere(), null, msg.getProperty(), value); } if (msgResonse != null) { if (this.engine == null) { LOGGER.debug("msg: {}", msgResonse); } else { this.engine.sendCommand(msgResonse, this); } } } else { } } System(EngineManager engine); @Override void reciveMsg(SCSMsg msg); @Override void run(); }
System extends Thread implements PlugIn { @Override public void reciveMsg(SCSMsg msg) { LOGGER.debug("System recived msg: {}", msg); Value value = null; SCSMsg msgResonse = null; if (msg.getWho().getMain() == MUST_WHO && msg.isStatus()) { switch (msg.getProperty().getMain()) { case PM_TIME: if (msg.isStatusProperty()) { msgResonse = this.setTime(msg); } else { value = this.getTime(); } break; case PM_DATE: value = this.getDate(); break; case PM_IP: value = this.getIP(); break; case PM_NETMASK: value = this.getNetMask(); break; case PM_MAC_ADDRESS: value = this.getMac(); break; case PM_SERVER_MODEL: value = this.getModel(); break; case PM_FIRMWARE_VERSION: value = this.getFirmware(); break; case PM_STARTUP_TIME: value = this.getStartUpTime(); break; case PM_TIME_DATE: value = this.getTimeDate(); break; case PM_KERNEL_VERSION: value = this.getKernel(); break; case PM_DISTRIBUTION_VERSION: value = this.getVersion(); break; default: LOGGER.warn("Function not implemented: {}", msg.getProperty().getMain()); } if (value != null) { final Who who = new Who(Integer.toString(MUST_WHO)); msgResonse = new SCSMsg(who, true, msg.getWhere(), null, msg.getProperty(), value); } if (msgResonse != null) { if (this.engine == null) { LOGGER.debug("msg: {}", msgResonse); } else { this.engine.sendCommand(msgResonse, this); } } } else { } } System(EngineManager engine); @Override void reciveMsg(SCSMsg msg); @Override void run(); static final int MUST_WHO; }