예제 #1
0
 @Override
 public boolean setItemAlpha(int id, int alpha) {
   // TODO Auto-generated method stub
   if (info == null || alpha < 0 || alpha > 255) {
     return false;
   }
   if (info.getnTransparent() == alpha) {
     return true;
   }
   info.setnTransparent(alpha);
   text.setM_alphaPadding(alpha); // 设置透明度
   textItem.resetAlpha(alpha);
   SKSceneManage.getInstance().onRefresh(items);
   return false;
 }
예제 #2
0
 @Override
 public boolean setItemBackcolor(int id, short r, short g, short b) {
   // TODO Auto-generated method stub
   if (info != null) {
     int color = Color.rgb(r, g, b);
     if (color == info.getnBackColor()) {
       return true;
     }
     info.setnBackColor(color);
     text.setM_backColorPadding(color);
     textItem.resetColor(color, 2);
     SKSceneManage.getInstance().onRefresh(items);
     return true;
   }
   return false;
 }
예제 #3
0
  /** 打开自定义键盘 */
  private void openBoard() {
    if (SKKeyPopupWindow.keyFlagIsShow && !GlobalPopWindow.popIsShow) {
      popKey.setLastText(showValue);
      popKey.setShowMax(Integer.toString(info.getnShowCharNumber()));
      popKey.setShowMin(Integer.toString(0));
      popKey.setnStartX(info.getnBoardX());
      popKey.setnStartY(info.getnBoardY());
      popKey.initPopUpWindow();

      // 允许输入 并且勾选了输入提示 则更换背景
      if (info.isbIsinput() && info.isbInputSign()) {
        drawBack = true;
        SKSceneManage.getInstance().onRefresh(items);
      }
      popKey.showPopUpWindow();
    }
  }
예제 #4
0
 @Override
 public int getItemTop(int id) {
   // TODO Auto-generated method stub
   if (info != null) {
     return info.getnStartY();
   }
   return -1;
 }
예제 #5
0
 @Override
 public int getItemHeight(int id) {
   // TODO Auto-generated method stub
   if (info != null) {
     return info.getnHeight();
   }
   return -1;
 }
예제 #6
0
  /** 系统键盘 */
  private void openKey() {
    // 如果显示类型是密码 则传-1 过去 辨别inputType 是text 还是password

    if (!GlobalPopWindow.popIsShow && SKKeyPopupWindow.keyFlagIsShow) {
      if (null != pop) {
        pop.setCallback(keyback);
        pop.initPopupWindow();
        pop.setInputMax(Integer.toString(info.getnShowCharNumber()));
        pop.setInputMin(Integer.toString(0));
        // 允许输入 并且勾选了输入提示 则更换背景
        if (info.isbIsinput() && info.isbInputSign()) {
          drawBack = true;
          SKSceneManage.getInstance().onRefresh(items);
        }
        pop.showPopupWindow();
      }
    }
  }
예제 #7
0
 @Override
 public short[] getItemBackcolor(int id) {
   // TODO Auto-generated method stub
   // nCurrentState;
   if (info != null) {
     return getColor(info.getnBackColor());
   }
   return null;
 }
예제 #8
0
 /**
  * 具体的画法
  *
  * @param paint
  * @param canvas
  */
 private void draw(Paint paint, Canvas canvas) {
   // 外形不为空画外形
   if (null != info.getsShapId()) {
     if (imageItem == null) {
       imageItem = new ImageDrawItem(info.getsShapId(), mRect);
     }
     imageItem.draw(paint, canvas);
   }
   // 画静态文本
   drawTextValue(paint, canvas);
   // 画点击输入背景提示框
   if (drawBack) {
     if (bgBitmap == null) {
       bgBitmap = ImageFileTool.getBitmap(R.drawable.rect_red_bg, mContext);
       bgRect = new Rect(0, 0, bgBitmap.getWidth(), bgBitmap.getHeight());
     }
     if (bgBitmap != null) {
       canvas.setDrawFilter(
           new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
       if (mBitmapPaint == null) {
         mBitmapPaint = new Paint();
         mBitmapPaint.setDither(true);
         mBitmapPaint.setAntiAlias(true);
       }
       canvas.drawBitmap(bgBitmap, bgRect, mRect, mBitmapPaint);
     }
   }
   // 不可触控加上锁图标
   if (!isTouchFlag && SystemInfo.isbLockIcon()) {
     if (mLockBitmap == null) {
       mLockBitmap = ImageFileTool.getBitmap(R.drawable.lock, mContext);
     }
     if (mLockBitmap != null) {
       if (mBitmapPaint == null) {
         mBitmapPaint = new Paint();
         mBitmapPaint.setDither(true);
         mBitmapPaint.setAntiAlias(true);
       }
       canvas.drawBitmap(mLockBitmap, info.getnStartX(), info.getnStartY(), mBitmapPaint);
     }
   }
 }
예제 #9
0
 private void doTouch(boolean bitFlag) {
   if (null == info) {
     return;
   }
   if (!isTouchFlag || !isShowFlag) {
     return;
   }
   if (info.isbIsinput()) {
     if (info.getnKeyId() == -1) // 为-1 时调用系统键盘
     {
       openKey();
     } else {
       openBoard();
     }
     // 如果是由位地址控制键盘打开的 并且勾选了自动复位 则将那个位地址值复位
     if (bitFlag && info.isbAutoChangeBit()) {
       setBit(info.getsBitAddress(), 0);
     }
   }
 }
예제 #10
0
 @Override
 public boolean setItemWidth(int id, int w) {
   // TODO Auto-generated method stub
   if (info != null) {
     if (w == info.getnWidth()) {
       return true;
     }
     if (w < 0 || w > SKSceneManage.getInstance().getSceneInfo().getnSceneWidth()) {
       return false;
     }
     info.setnWidth((short) w);
     items.rect.right = w - items.rect.width() + items.rect.right;
     items.mMoveRect = new Rect();
     text.setRectWidth(items.rect.width());
     SKSceneManage.getInstance().onRefresh(items);
   } else {
     return false;
   }
   return true;
 }
예제 #11
0
 @Override
 public boolean setItemHeight(int id, int h) {
   // TODO Auto-generated method stub
   if (info != null) {
     if (h == info.getnHeight()) {
       return true;
     }
     if (h < 0 || h > SKSceneManage.getInstance().getSceneInfo().getnSceneHeight()) {
       return false;
     }
     info.setnHeight((short) h);
     items.rect.bottom = h - items.rect.height() + items.rect.bottom;
     items.mMoveRect = new Rect();
     text.setRectHeight(items.rect.height());
     SKSceneManage.getInstance().onRefresh(items);
   } else {
     return false;
   }
   return true;
 }
예제 #12
0
  /** 初始化数据 */
  private void init() {
    if (null == info) {
      return;
    }

    if (null == popKey) {
      popKey =
          new SKKeyPopupWindow(
              SKSceneManage.getInstance().mContext,
              false,
              info.getnKeyId(),
              DATA_TYPE.OTHER_DATA_TYPE);
      popKey.setCallback(callback);
      popKey.setInputType(false);
      if ((AcillCode.PASSWORD & info.getnCode()) == AcillCode.PASSWORD) {
        popKey.setPassWord(true);
      } else {
        popKey.setPassWord(false);
      }
    }
    if ((AcillCode.PASSWORD & info.getnCode()) == AcillCode.PASSWORD) {
      pop =
          new GlobalPopWindow(
              SKSceneManage.getInstance().getCurrentScene(),
              WINDOW_TYPE.KEYBOARD,
              3,
              DATA_TYPE.OTHER_DATA_TYPE); // 3
      // 代表密码
    } else {
      pop =
          new GlobalPopWindow(
              SKSceneManage.getInstance().getCurrentScene(),
              WINDOW_TYPE.KEYBOARD,
              2,
              DATA_TYPE.OTHER_DATA_TYPE); // 2代表字母
    }

    asciiIsShow();
    asciiIsTouch();
    SKSceneManage.getInstance().onRefresh(items);
  }
예제 #13
0
 @Override
 public boolean setItemTop(int id, int y) {
   // TODO Auto-generated method stub
   if (info != null) {
     if (y == info.getnStartY()) {
       return true;
     }
     if (y < 0 || y > SKSceneManage.getInstance().getSceneInfo().getnSceneHeight()) {
       return false;
     }
     info.setnStartY(y);
     int t = items.rect.top;
     items.rect.top = y;
     items.rect.bottom = y - t + items.rect.bottom;
     items.mMoveRect = new Rect();
     text.setStartY(y);
     SKSceneManage.getInstance().onRefresh(items);
   } else {
     return false;
   }
   return true;
 }
예제 #14
0
  /**
   * 写入编码转换
   *
   * @param inputString 输入的字符
   * @return 写入的字节数组
   */
  private byte[] converCodeWrite(String inputString) {
    String tempString = inputString;
    byte[] returnByte = null;
    try {
      returnByte = inputString.getBytes("US-ASCII");
      if ((info.getnCode() & AcillCode.INPUTHEIGHTLOWER) == AcillCode.INPUTHEIGHTLOWER) {
        tempString = convertHightLower(tempString);
        if ((info.getnCode() & AcillCode.UNICODE) == AcillCode.UNICODE) {
          returnByte = tempString.getBytes("UNICODE");
        } else {
          returnByte = tempString.getBytes();
        }
      }

      if ((info.getnCode() & AcillCode.UNICODE) == AcillCode.UNICODE) {
        returnByte = tempString.getBytes("UNICODE");
      }
    } catch (Exception e) {
      // TODO: handle exception
    }

    return returnByte;
  }
예제 #15
0
  @Override
  public boolean setItemLeft(int id, int x) {
    // TODO Auto-generated method stub

    if (info != null) {
      if (x == info.getnStartX()) {
        return true;
      }
      if (x < 0 || x > SKSceneManage.getInstance().getSceneInfo().getnSceneWidth()) {
        return false;
      }

      int l = items.rect.left;
      info.setnStartX(x);
      items.rect.left = x;
      items.rect.right = x - l + items.rect.right;
      items.mMoveRect = new Rect();
      text.setStartX(x);
      SKSceneManage.getInstance().onRefresh(items);
    } else {
      return false;
    }
    return true;
  }
예제 #16
0
  /**
   * 转换编码 再显示
   *
   * @param temp return 转换编码之后的 要显示的字符串
   */
  private String converCodeShow(byte[] bTemp) {
    String returnValue = new String(bTemp);
    try {
      if ((AcillCode.UNICODE & info.getnCode()) == AcillCode.UNICODE) {
        returnValue = new String(bTemp, "UNICODE");

      } else {
        returnValue = new String(bTemp);
      }

      if (AcillCode.SHOWHEIGHTLOWER == (AcillCode.SHOWHEIGHTLOWER & info.getnCode())) {
        returnValue = convertHightLower(returnValue);
      }

      if ((AcillCode.PASSWORD & info.getnCode()) == AcillCode.PASSWORD) {
        returnValue = "******";
      }
    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();
    }

    return returnValue;
  }
예제 #17
0
 @Override
 public void addrValueNotic(Vector<Byte> nStatusValue) {
   // TODO Auto-generated method stub
   if ((AcillCode.UNICODE & info.getnCode()) == AcillCode.UNICODE) {
     byte[] byteValue = new byte[nStatusValue.size() + 2];
     byteValue[0] = -1;
     byteValue[1] = -2;
     for (int i = 0; i < nStatusValue.size(); i++) {
       byteValue[i + 2] = nStatusValue.get(i);
     }
     showValue = converCodeShow(byteValue);
   } else {
     byte[] byteValue = new byte[nStatusValue.size()];
     for (int i = 0; i < nStatusValue.size(); i++) {
       byteValue[i] = nStatusValue.get(i);
     }
     showValue = converCodeShow(byteValue);
   }
   // Log.d("AAAAA", "showValue="+showValue);
   SKSceneManage.getInstance().onRefresh(items);
 }
예제 #18
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    // 允许输入
    SKSceneManage.getInstance().time = 0;
    boolean touch = false;
    int x = (int) event.getX();
    int y = (int) event.getY();
    if (null == info) {
      return false;
    }

    if (info.geteInputTypeId() == INPUT_TYPE.BIT) {
      return false;
    }
    if (x < info.getnStartX()
        || x > info.getnStartX() + info.getnWidth()
        || y < info.getnStartY()
        || y > info.getnStartY() + info.getnHeight()) {
      return false;
    } else {
      if (!info.isbIsinput()) { // 不允许输入 直接返回
        return false;

      } else {
        if (!isTouchFlag || !isShowFlag) {

          if (!isTouchFlag && info != null) {
            if (info.getmTouchinInfo() != null) {
              if (event.getAction() == MotionEvent.ACTION_DOWN) {
                if (info.getmTouchinInfo().isbTouchByUser()) {
                  SKSceneManage.getInstance().turnToLoginPop();
                }
              }
            }
          }

          return false;
        }

        if (event.getAction() == MotionEvent.ACTION_DOWN) {

          isOnclick = true;
          if (info.getmTouchinInfo() == null) {
            doTouch(notTouchOpenKey);
          } else {
            if (info.getmTouchinInfo().isbTimeoutCancel() == true
                && info.getmTouchinInfo().getnPressTime() > 0) {
              if (null == hand) {
                hand = new myMainHandler(Looper.getMainLooper());
              }
              hand.sendEmptyMessageDelayed(
                  TOUCHHANDER, info.getmTouchinInfo().getnPressTime() * 100);
            } else {
              doTouch(notTouchOpenKey);
            }
          }
          touch = true;
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
          return true;
        } else if (MotionEvent.ACTION_UP == event.getAction()
            || MotionEvent.ACTION_CANCEL == event.getAction()) {
          isOnclick = false;
          touch = true;
        }
      }
    }

    return touch;
  }
예제 #19
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);
        }
      }
    }
  }
예제 #20
0
  public SKASCIIDisplay(Context context, int itemId, int sceneId, AcillInputInfo info) {
    mContext = context;
    isOnclick = false;
    isTouchFlag = true;
    isShowFlag = true;
    showByUser = false;
    touchByUser = false;
    showByAddr = false;
    touchByAddr = false;
    // keyIsShow = true;
    this.sceneId = sceneId;
    this.itemId = itemId;
    showValue = "";
    mPaint = new Paint();
    items = new SKItems();
    this.info = info;
    notTouchOpenKey = false;

    if (info != null) {
      mRect = new Rect();
      mRect.left = info.getnStartX();
      mRect.right = info.getnStartX() + info.getnWidth();
      mRect.top = info.getnStartY();
      mRect.bottom = info.getnStartY() + info.getnHeight();

      text = new StaticTextModel();
      text.setM_backColorPadding(info.getnBackColor());
      text.setM_eTextAlign(info.getnShowStyle());
      text.setM_nFontColor(info.getnFontColor());
      text.setM_nFontSize(info.getnFontsize());
      text.setM_sFontFamly(info.getsFontStyle());
      text.setM_textLanguageId(1);
      text.setM_textPro((short) (info.geteFontCss()));
      text.setStartX(info.getnTextStartX());
      text.setStartY(info.getnTextStartY());
      text.setRectHeight(info.getnTextHeight());
      text.setRectWidth(info.getnTextWidth());
      text.setM_alphaPadding(info.getnTransparent()); // 设置透明度
      //			if (info.getnTransparent() == 0) {
      //				text.setBorderAlpha(255);
      //				text.setLineColor(Color.BLACK);
      //				text.setLineWidth(1);
      //			}

      textItem = new TextItem(text);
      textItem.initTextPaint();
      textItem.initRectBoderPaint();
      textItem.initRectPaint();

      items.itemId = this.itemId;
      items.nCollidindId = info.getnCollidindId();
      items.nZvalue = info.getnZvalue();
      items.sceneId = sceneId;
      items.rect = mRect;
      items.mGraphics = this;

      if (null != info.getmTouchinInfo()) {
        if (-1 != info.getmTouchinInfo().getnAddrId() && info.getmTouchinInfo().isbTouchByAddr()) {
          touchByAddr = true;
        }
        if (info.getmTouchinInfo().isbTouchByUser()) {
          touchByUser = true;
        }
      }
      if (null != info.getmShowInfo()) {
        if (-1 != info.getmShowInfo().getnAddrId() && info.getmShowInfo().isbShowByAddr()) {
          showByAddr = true;
        }
        if (info.getmShowInfo().isbShowByUser()) {
          showByUser = true;
        }
      }

      // 注册地址值
      registAddr();
    }
  }
예제 #21
0
 private void asciiIsTouch() {
   if (touchByAddr || touchByUser) {
     isTouchFlag = popedomIsTouch(info.getmTouchinInfo());
   }
 }
예제 #22
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());
                }
              }
            }
          }
        }
예제 #23
0
 private void asciiIsShow() {
   if (showByAddr || showByUser) {
     isShowFlag = popedomIsShow(info.getmShowInfo());
   }
 }
예제 #24
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);
    }
  }