Ejemplo n.º 1
0
  private void processSegmentDataEvent(InvokeIDType id, EventReportArgumentSimple event) {
    PM_Store pmstore = this.state_handler.getMDS().getPM_Store(event.getObj_handle());
    if (pmstore == null) return;

    RelativeTime rt = event.getEvent_time();
    Logging.debug("Relative Time: " + rt.getValue().getValue().intValue());

    try {
      SegmentDataEvent sde =
          ASN1_Tools.decodeData(
              event.getEvent_info(),
              SegmentDataEvent.class,
              this.state_handler.getMDS().getDeviceConf().getEncondigRules());
      SegmentDataResult sdr = pmstore.Segment_Data_Event(sde);

      EventReportResultSimple errs =
          MessageFactory.genEventReportResultSimple(
              event, sdr, state_handler.getMDS().getDeviceConf().getEncondigRules());
      DataApdu data = new DataApdu();
      MessageChoiceType mct = new MessageChoiceType();
      mct.selectRors_cmip_confirmed_event_report(errs);
      data.setInvoke_id(id);
      data.setMessage(mct);

      state_handler.send(MessageFactory.composeApdu(data, state_handler.getMDS().getDeviceConf()));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  @SuppressWarnings("unchecked")
  @Override
  public synchronized boolean processEvent(Event event) {
    switch (event.getTypeOfEvent()) {
      case EventType.REQ_GET_PM_STORE:
        ExternalEvent<Boolean, GetPmStoreEventData> pmEvent =
            (ExternalEvent<Boolean, GetPmStoreEventData>) event;
        PM_Store pm_store =
            this.state_handler.getMDS().getPM_Store(pmEvent.getPrivData().getHandle());
        pm_store.GET(pmEvent);
        return true;

      case EventType.REQ_SET:
        ExternalEvent<Boolean, SetEventData> setEvent =
            (ExternalEvent<Boolean, SetEventData>) event;
        DIM obj = state_handler.getMDS().getObject(setEvent.getPrivData().getObjectHandle());
        try {
          SET_Service serv = (SET_Service) obj;
          serv.SET(setEvent, setEvent.getPrivData().getAttribute());
        } catch (ClassCastException e) {
          Logging.error(
              "Set cannot be done in object: "
                  + setEvent.getPrivData().getObjectHandle().getValue().getValue()
                  + " it does not implement a SET service");
        }
        return true;

      case EventType.REQ_MDS:
        state_handler.getMDS().GET(event);
        return true;

      case EventType.REQ_GET_SEGMENT_INFO:
        ExternalEvent<List<PM_Segment>, GetPmSegmentEventData> pmSegEvent =
            (ExternalEvent<List<PM_Segment>, GetPmSegmentEventData>) event;
        PM_Store store =
            this.state_handler.getMDS().getPM_Store(pmSegEvent.getPrivData().getHandle());
        store.Get_Segment_Info(pmSegEvent, pmSegEvent.getPrivData().getSegmSelection());
        return true;

      case EventType.REQ_TRIG_SEGMENT_DATA_XFER:
        ExternalEvent<Boolean, TrigPMSegmentXferEventData> xferEvent =
            (ExternalEvent<Boolean, TrigPMSegmentXferEventData>) event;
        PM_Store s =
            this.state_handler.getMDS().getPM_Store(xferEvent.getPrivData().getStoreHandle());

        TrigSegmDataXferReq tsdxr = new TrigSegmDataXferReq();
        tsdxr.setSeg_inst_no(xferEvent.getPrivData().getInsNumber());
        s.Trig_Segment_Data_Xfer(xferEvent, tsdxr);
        return true;

      case EventType.REQ_SET_TIME:
        state_handler.getMDS().Set_Time(event);
        return true;

      case EventType.IND_TRANS_DESC:
        Logging.error("2.2) IND Transport disconnect. Should indicate to application layer...");
        state_handler.changeState(new MDisconnected(state_handler));
        return true;

      case EventType.IND_TIMEOUT:
        state_handler.send(MessageFactory.AbrtApdu(event.getReason()));
        state_handler.changeState(new MUnassociated(state_handler));
        return true;

      case EventType.REQ_ASSOC_REL:
        state_handler.send(MessageFactory.RlrqApdu_NORMAL());
        state_handler.changeState(new MDisassociating(state_handler));
        try {
          ExternalEvent<Boolean, Object> eevent = (ExternalEvent<Boolean, Object>) event;
          eevent.processed(true, ErrorCodes.NO_ERROR);
        } catch (ClassCastException e) {

        }
        return true;

      case EventType.REQ_ASSOC_ABORT:
        state_handler.send(MessageFactory.AbrtApdu_UNDEFINED());
        state_handler.changeState(new MUnassociated(state_handler));
        return true;

      case EventType.REC_CORRUPTED_APDU:
        state_handler.send(MessageFactory.AbrtApdu_UNDEFINED());
        state_handler.changeState(new MUnassociated(state_handler));
        return true;

      case EventType.REC_APDU_OVERFLOW:
        EventAPDUOverflow eao = (EventAPDUOverflow) event;

        if (!eao.getApduType().isPrstSelected()) {
          Logging.error("APDU exceeded maximum length is non PrstApdu");
          state_handler.send(MessageFactory.AbrtApdu_UNDEFINED());
          state_handler.changeState(new MUnassociated(state_handler));
        }

        try {
          DataApdu data =
              ASN1_Tools.decodeData(
                  eao.getApduType().getPrst().getValue(),
                  DataApdu.class,
                  this.state_handler.getMDS().getDeviceConf().getEncondigRules());
          state_handler.send(
              MessageFactory.ROER_PROTOCOL_VIOLATION_Apdu(
                  data, state_handler.getMDS().getDeviceConf()));
        } catch (Exception e) {
          e.printStackTrace();
          state_handler.send(MessageFactory.AbrtApdu_UNDEFINED());
          state_handler.changeState(new MUnassociated(state_handler));
        }

        return true;
      case EventType.NOTI_MEASURE:
        System.out.println("sending measure");
        state_handler.send(generateMeasureApdu());
        return true;

      default:
        return false;
    }
  }