/** * フレームの種類を判別して、登録されたRequestProcessorの適切なメソッドを呼び出す。 すでに処理済みであれば何も行なわない。 * * @param subnet 受信したフレームの送受信が行なわれたサブネット * @param frame 受信したフレーム * @param processed 指定されたフレームがすでに処理済みである場合にはtrue、そうでなければfalse * @return 指定されたフレームを処理した場合にはtrue、そうでなければfalse */ @Override public boolean process(Subnet subnet, Frame frame, boolean processed) { logger.entering(className, "process", new Object[] {subnet, frame, processed}); if (processed) { logger.exiting(className, "process", false); return false; } if (!frame.getCommonFrame().isStandardPayload()) { logger.exiting(className, "process", false); return false; } boolean success = false; CommonFrame cf = frame.getCommonFrame(); StandardPayload payload = cf.getEDATA(StandardPayload.class); if (payload == null) { logger.exiting(className, "process", false); return false; } switch (payload.getESV()) { case SetI: success = this.processSetI(subnet, frame); break; case SetC: success = this.processSetC(subnet, frame); break; case Get: success = this.processGet(subnet, frame); break; case SetGet: success = this.processSetGet(subnet, frame); break; case INF_REQ: success = this.processINF_REQ(subnet, frame); break; case INF: success = this.processINF(subnet, frame); break; case INFC: success = this.processINFC(subnet, frame); break; } logger.exiting(className, "process", success); return success; }
@Override public void run() { try { Frame recvFrame = subnet.recv(); CommonFrame recvCommonFrame = recvFrame.getCommonFrame(); StandardPayload recvPayload = (StandardPayload) recvCommonFrame.getEDATA(); CommonFrame sendCommonFrame = new CommonFrame(recvPayload.getDEOJ(), recvPayload.getSEOJ(), ESV.Get_Res); sendCommonFrame.setTID(recvCommonFrame.getTID()); StandardPayload sendPayload = (StandardPayload) sendCommonFrame.getEDATA(); sendPayload.addFirstProperty(new Property(EPC.xE0, new Data((byte) 0x12, (byte) 0x34))); Frame sendFrame = new Frame(subnet.getLocalNode(), recvFrame.getSender(), sendCommonFrame); this.listener.process(subnet, sendFrame, false); } catch (SubnetException e) { e.printStackTrace(); fail(); } }