Beispiel #1
0
  /** 注册地址值 */
  private void registAddr() {
    // TODO Auto-generated method stub
    if (null != info.getnAddress()) {
      SKPlcNoticThread.getInstance().addNoticProp(info.getnAddress(), valueCall, false, sceneId);
    }

    if (null != info.getmOffSetAddr()) {
      SKPlcNoticThread.getInstance().addNoticProp(info.getmOffSetAddr(), addOffSet, false, sceneId);
    }

    // 注册触控地址值
    if (touchByAddr && null != info.getmTouchinInfo().getTouchAddrProp()) {
      ADDRTYPE addrType = info.getmTouchinInfo().geteCtlAddrType();
      if (addrType == ADDRTYPE.BITADDR) {
        SKPlcNoticThread.getInstance()
            .addNoticProp(info.getmTouchinInfo().getTouchAddrProp(), touchCall, true, sceneId);
      } else {
        SKPlcNoticThread.getInstance()
            .addNoticProp(info.getmTouchinInfo().getTouchAddrProp(), touchCall, false, sceneId);
      }
    }

    // 注册显现地址值
    if (showByAddr && null != info.getmShowInfo().getShowAddrProp()) {
      ADDRTYPE addrType = info.getmShowInfo().geteAddrType();
      if (addrType == ADDRTYPE.BITADDR) {
        SKPlcNoticThread.getInstance()
            .addNoticProp(info.getmShowInfo().getShowAddrProp(), showCall, true, sceneId);
      } else {
        SKPlcNoticThread.getInstance()
            .addNoticProp(info.getmShowInfo().getShowAddrProp(), showCall, false, sceneId);
      }
    }
    // 位控制键盘是否弹出
    if (null != info.getsBitAddress()) {
      SKPlcNoticThread.getInstance()
          .addNoticProp(info.getsBitAddress(), bitKeyBoard, true, sceneId);
    }
  }
Beispiel #2
0
        @Override
        public void addrValueNotic(Vector<Byte> nStatusValue) {
          if (nStatusValue != null) {
            if (info.getnAddress() != null) {
              Vector<Short> mIData = new Vector<Short>();
              boolean result = PlcRegCmnStcTools.bytesToShorts(nStatusValue, mIData);
              if (result) {
                int value = mIData.get(0);
                int temp = info.getnAddress().nAddrValue + value;
                if (temp < 0) {
                  SKPlcNoticThread.getInstance().destoryCallback(valueCall, sceneId);
                  showValue = "";
                  SKSceneManage.getInstance().onRefresh(items);
                  return;
                }
                if (info.getmOffSetAddress() == null) {
                  AddrProp addrProp = new AddrProp();
                  addrProp.eAddrRWprop = info.getnAddress().eAddrRWprop;
                  addrProp.eConnectType = info.getnAddress().eConnectType;
                  addrProp.nAddrId = info.getnAddress().nAddrId;
                  addrProp.nAddrLen = info.getnAddress().nAddrLen;
                  addrProp.nAddrValue = temp;
                  addrProp.nPlcStationIndex = info.getnAddress().nPlcStationIndex;
                  addrProp.nRegIndex = info.getnAddress().nRegIndex;
                  addrProp.nUserPlcId = info.getnAddress().nUserPlcId;
                  addrProp.sPlcProtocol = info.getnAddress().sPlcProtocol;
                  info.setmOffSetAddress(addrProp);
                } else {
                  info.getmOffSetAddress().nAddrValue = temp;
                }

                SKPlcNoticThread.getInstance().destoryCallback(valueCall, sceneId);
                SKPlcNoticThread.getInstance()
                    .addNoticProp(info.getmOffSetAddress(), valueCall, false, sceneId, true);

                if (info.getnAddress().eConnectType > 1) {
                  SKSceneManage.getInstance()
                      .updateSceneReadAddrs(sceneId, info.getmOffSetAddress());
                }
              }
            }
          }
        }
Beispiel #3
0
  /**
   * 将值写入地址
   *
   * @param inputKeyString
   */
  private void writeToAddr(String inputKeyString) {
    // 输入完成后,执行通知操作通知
    noticeAddr(info.getmTouchinInfo(), true);
    // 进行输入完成后 执行宏指令
    // 若启用宏指令
    if (true == info.isbIsStartStatement()) {
      // 请求执行控件宏指令
      MacroManager.getInstance(null).Request(MSERV.CALLCM, (short) info.getnScriptId());
    }
    // 将输入的值进行数据类型进行转换
    byte[] by = converCodeWrite(inputKeyString);
    // 将输入转换后的数组写入地址
    Vector<Byte> dataList = new Vector<Byte>();

    if (0 != by.length) {
      if ((AcillCode.UNICODE & info.getnCode()) == AcillCode.UNICODE) {
        for (int i = 2; i < by.length; i++) {
          dataList.add(by[i]);
        }
      } else {
        for (int i = 0; i < by.length; i++) {
          dataList.add(by[i]);
        }
      }
    }
    SEND_DATA_STRUCT mSendData = new SEND_DATA_STRUCT();
    mSendData.eDataType = DATA_TYPE.ASCII_STRING;
    mSendData.eReadWriteCtlType = READ_WRITE_COM_TYPE.GLOBAL_LOOP_W;
    if (null != info.getnAddress()) {
      if (info.getmOffSetAddress() != null) {
        int nAddrLeng = info.getmOffSetAddress().nAddrLen;
        if (nAddrLeng * 2 > dataList.size()) {
          for (int i = dataList.size(); i < nAddrLeng * 2; i++) {
            dataList.add((byte) 0x00);
          }
        }

        if (info.isInputIsShow()) // 输入地址跟显示地址一样
        {
          PlcRegCmnStcTools.setRegAsciiData(info.getmOffSetAddress(), dataList, mSendData);
        } else {
          // 输入地址跟显示地址不一样,写入地址时,传入输入地址
          PlcRegCmnStcTools.setRegAsciiData(info.getInputAddr(), dataList, mSendData);
        }

      } else {
        int nAddrLeng = info.getnAddress().nAddrLen;
        if (nAddrLeng * 2 > dataList.size()) {
          for (int i = dataList.size(); i < nAddrLeng * 2; i++) {
            dataList.add((byte) 0x00);
          }
        }
        if (info.isInputIsShow()) // 输入地址跟显示地址一样
        {
          PlcRegCmnStcTools.setRegAsciiData(info.getnAddress(), dataList, mSendData);
        } else {
          PlcRegCmnStcTools.setRegAsciiData(info.getInputAddr(), dataList, mSendData);
        }
      }
    }
  }