Beispiel #1
0
  public void GET(Event event) {
    try {
      HANDLE handle = (HANDLE) getAttribute(Nomenclature.MDC_ATTR_ID_HANDLE).getAttributeType();
      DataApdu data = MessageFactory.PrstRoivCmpGet(getMDS(), handle);
      ApduType apdu = MessageFactory.composeApdu(data, getMDS().getDeviceConf());
      InvokeIDType invokeId = data.getInvoke_id();
      getMDS().getStateHandler().send(apdu);

      DimTimeOut to =
          new DimTimeOut(TimeOut.PM_STORE_TO_GET, invokeId.getValue(), getMDS().getStateHandler()) {

            @SuppressWarnings("unchecked")
            @Override
            public void procResponse(DataApdu data) {
              Logging.debug("GOT_PMSOTRE invoke_id " + data.getInvoke_id().getValue().intValue());
              ExternalEvent<Boolean, GetPmStoreEventData> event = null;
              try {
                event = (ExternalEvent<Boolean, GetPmStoreEventData>) this.getEvent();
              } catch (ClassCastException e) {

              }

              if (!data.getMessage().isRors_cmip_getSelected()) {
                Logging.debug("TODO: Unexpected response format");
                if (event != null) event.processed(false, ErrorCodes.UNEXPECTED_ERROR);
                return;
              }

              GetResultSimple grs = data.getMessage().getRors_cmip_get();
              HANDLE handle =
                  (HANDLE) getAttribute(Nomenclature.MDC_ATTR_ID_HANDLE).getAttributeType();
              if (handle == null) {
                Logging.debug("Error: Can't get HANDLE attribute in PM_STORE object");
                if (event != null) event.processed(false, ErrorCodes.UNEXPECTED_ERROR);
                return;
              }

              if (grs.getObj_handle().getValue().getValue().intValue()
                  != handle.getValue().getValue().intValue()) {
                Logging.debug(
                    "TODO: Unexpected object handle, should be value "
                        + handle.getValue().getValue().intValue());
                if (event != null) event.processed(false, ErrorCodes.UNEXPECTED_ERROR);
                return;
              }

              try {
                Hashtable<Integer, Attribute> attribs;
                attribs =
                    getAttributes(
                        grs.getAttribute_list(), getMDS().getDeviceConf().getEncondigRules());
                Iterator<Integer> i = attribs.keySet().iterator();
                while (i.hasNext()) {
                  Attribute attr = attribs.get(i.next());
                  if (getAttribute(attr.getAttributeID()) != null) {
                    addAttribute(attr);
                  }
                }
              } catch (Exception e) {
                e.printStackTrace();
              }

              if (event != null) event.processed(true, ErrorCodes.NO_ERROR);
            }
          };

      to.setEvent(event);
      to.start();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #2
0
  @Override
  public void Get_Segment_Info(
      ExternalEvent<List<PM_Segment>, GetPmSegmentEventData> event, SegmSelection ss) {
    try {
      DataApdu data = MessageFactory.PrstRoivCmipAction(this, ss);
      ApduType apdu = MessageFactory.composeApdu(data, getMDS().getDeviceConf());
      InvokeIDType invokeId = data.getInvoke_id();
      getMDS().getStateHandler().send(apdu);

      DimTimeOut to =
          new DimTimeOut(TimeOut.PM_STORE_TO_CA, invokeId.getValue(), getMDS().getStateHandler()) {

            @SuppressWarnings("unchecked")
            @Override
            public void procResponse(DataApdu data) {

              ExternalEvent<List<PM_Segment>, GetPmSegmentEventData> event =
                  (ExternalEvent<List<PM_Segment>, GetPmSegmentEventData>) getEvent();

              if (!data.getMessage().isRors_cmip_confirmed_actionSelected()) {
                Logging.debug("Error: Unexpected response format");
                event.processed(null, ErrorCodes.UNEXPECTED_ERROR);
                return;
              }

              ActionResultSimple ars = data.getMessage().getRors_cmip_confirmed_action();
              OID_Type oid = ars.getAction_type();
              if (Nomenclature.MDC_ACT_SEG_GET_INFO != oid.getValue().getValue().intValue()) {
                Logging.debug("Error: Unexpected response format");
                event.processed(null, ErrorCodes.UNEXPECTED_ERROR);
                return;
              }

              try {
                SegmentInfoList sil =
                    ASN1_Tools.decodeData(
                        ars.getAction_info_args(),
                        SegmentInfoList.class,
                        getMDS().getDeviceConf().getEncondigRules());
                Iterator<SegmentInfo> i = sil.getValue().iterator();
                while (i.hasNext()) {
                  SegmentInfo si = i.next();
                  InstNumber in = si.getSeg_inst_no();
                  AttributeList al = si.getSeg_info();

                  Hashtable<Integer, Attribute> attribs;
                  attribs = getAttributes(al, getMDS().getDeviceConf().getEncondigRules());
                  MPM_Segment pm_segment = new MPM_Segment(attribs);
                  addPM_Segment(pm_segment);
                  Logging.debug("Got PM_Segment " + in.getValue().intValue());
                }

              } catch (Exception e) {
                e.printStackTrace();
              }

              List<PM_Segment> segments = new ArrayList<PM_Segment>(MPM_Store.this.getSegments());
              event.processed(segments, ErrorCodes.NO_ERROR);
            }
          };

      to.setEvent(event);
      to.start();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #3
0
  @Override
  public void Trig_Segment_Data_Xfer(
      ExternalEvent<Boolean, TrigPMSegmentXferEventData> event, TrigSegmDataXferReq tsdx) {
    DataApdu data = MessageFactory.PrstRoivCmipConfirmedAction(this, tsdx);
    ApduType apdu = MessageFactory.composeApdu(data, getMDS().getDeviceConf());
    InvokeIDType invokeId = data.getInvoke_id();
    getMDS().getStateHandler().send(apdu);

    DimTimeOut to =
        new DimTimeOut(TimeOut.PM_STORE_TO_CA, invokeId.getValue(), getMDS().getStateHandler()) {

          @SuppressWarnings("unchecked")
          @Override
          public void procResponse(DataApdu data) {

            ExternalEvent<Boolean, TrigPMSegmentXferEventData> event =
                (ExternalEvent<Boolean, TrigPMSegmentXferEventData>) getEvent();

            if (!data.getMessage().isRors_cmip_confirmed_actionSelected()) {
              Logging.error("Error: Unexpected response format");
              event.processed(false, ErrorCodes.UNEXPECTED_ERROR);
              return;
            }

            ActionResultSimple ars = data.getMessage().getRors_cmip_confirmed_action();
            OID_Type oid = ars.getAction_type();
            if (Nomenclature.MDC_ACT_SEG_TRIG_XFER != oid.getValue().getValue().intValue()) {
              Logging.error("Error: Unexpected response format");
              event.processed(false, ErrorCodes.UNEXPECTED_ERROR);
              return;
            }

            try {
              TrigSegmDataXferRsp rsp =
                  ASN1_Tools.decodeData(
                      ars.getAction_info_args(),
                      TrigSegmDataXferRsp.class,
                      getMDS().getDeviceConf().getEncondigRules());
              InstNumber in = rsp.getSeg_inst_no();
              TrigSegmXferRsp tsxr = rsp.getTrig_segm_xfer_rsp();
              int result = tsxr.getValue().intValue();
              if (result == 0) {
                event.processed(true, ErrorCodes.NO_ERROR);
                return;
              }

              // TODO: Create and set proper error using "result" variable
              event.processed(false, ErrorCodes.UNEXPECTED_ERROR);
              Logging.error("InstNumber " + in.getValue().intValue() + " error " + result);

            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        };

    // TODO: Add a timeout for data transfer (see 8.9.5.6 and MDC_ATTR_TRANSFER_TIMEOUT att from
    // PMSegment)

    to.setEvent(event);
    to.start();
  }