Package promauto.jroboplc

Examples of promauto.jroboplc.ModuleStatus


  @Override
  public ModuleStatus execute() {
//    if (!tagEnable.getBoolean())
//      return ModuleStatus.OK;
   
    ModuleStatus status = super.execute();
    if (status==ModuleStatus.OK) {
     
      for (int attempt=0; attempt<=tagRetrains.getInteger(); attempt++) {
//        System.out.println(".");
       
        // send
        status=ModuleStatus.NO_ANSWER;
        // init data request command
        bufout[0] = 0x55;
        bufout[1] = (byte)(0x40 + tagAddress.getInteger() & 0xFF);
        if (port.writeBytesAA55(bufout)) {

          // receive
          if (port.readBytesAA55(bufin)>0) {
           
//            System.out.println("\n>>>" + attempt + ": " + RpHyperstring.bytesToHexString(bufin));

            // checking control sum
            status=ModuleStatus.BAD_CS;
            if (ModuleIO_PA.checkCS(bufin, tagAddress.getInteger())) {
             
              // process data
              int mask = 1;
              for (int i=0; i<64; i++) {
               
                data[i].set( ((bufin[i/8] & mask) == 0)? 0: 1 );
               
                if ((mask = mask << 1) > 0x80)
                  mask = 1;
              }
             
              status=ModuleStatus.OK;
              break;
            }
          }
        }
        port.discard();
      }

      if (status!=ModuleStatus.OK)
        tagErrorCounter.set(tagErrorCounter.getInteger() + 1);
    }
   
    tagErrorCode.set(status.ordinal());
   
    return status;
  }
View Full Code Here


  @Override
  public ModuleStatus execute() {
//    if (!tagEnable.getBoolean())
//      return ModuleStatus.OK;
   
    ModuleStatus status = super.execute();
    if (status==ModuleStatus.OK) {
      bufout[0] = 0x55;
      bufout[1] = (byte)(0x20 + tagAddress.getInteger() & 0xFF);
       
      int b=0;
      int mask=1;
      for (int i=0; i<64; i++) {
        if (outputs[i].getInteger()>0)
          b = b + mask;
        mask = mask << 1;
       
        if ((i+1)%8 == 0) {
          bufout[i/8+2] = (byte)(b & 0xFF);
          b = 0;
          mask=1;
        }
      }
     
      ModuleIO_PA.setCS(bufout, tagAddress.getInteger());

//      System.out.println("\n---" + RpHyperstring.bytesToHexString(bufout));
     
      port.writeBytesAA55(bufout);

      if (status!=ModuleStatus.OK)
        tagErrorCounter.set(tagErrorCounter.getInteger() + 1);
    }
   
    tagErrorCode.set(status.ordinal());
   
    return status;
  }
View Full Code Here

TOP

Related Classes of promauto.jroboplc.ModuleStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.