public AbstractMRMessage createOutPacket(){
  int cmdlen=3;
  byte cmdcode=0x03;
  byte addrhi=0x00;
  byte addrlo=0x00;
  byte settinghi=0x00;
  byte settinglo=0x00;
  boolean bulk_message=true;
  int c=0;
  while (c < outputbitsPerCard) {
    if ((outputType[c] != AcelaNode.ONOFF) || (outputSpecial[c] != 0)) {
      bulk_message=false;
    }
    c++;
  }
  if (!bulk_message) {
    c=0;
    boolean foundfirst=false;
    boolean foundanother=false;
    while (c < outputbitsPerCard) {
      if (outputNeedToSend[c] && foundfirst) {
        foundanother=true;
      }
      if (outputNeedToSend[c] && !foundfirst) {
        foundfirst=true;
      }
      c++;
    }
    if (foundanother) {
      setMustSend();
    }
  }
  Integer tempint=Integer.valueOf(startingOutputAddress);
  addrlo=tempint.byteValue();
  if (bulk_message) {
    if (nodeType == TB) {
      cmdlen=4;
      cmdcode=0x07;
      int tempsettings=(outputArray[3] ^ outputWired[3]) * 8 + (outputArray[2] ^ outputWired[2]) * 4 + (outputArray[1] ^ outputWired[1]) * 2 + (outputArray[0] ^ outputWired[0]) * 1;
      settinglo=(byte)(tempsettings);
    }
    if (nodeType == D8) {
      cmdlen=4;
      cmdcode=0x08;
      int tempsettings=(outputArray[3] ^ outputWired[3]) * 8 + (outputArray[2] ^ outputWired[2]) * 4 + (outputArray[1] ^ outputWired[1]) * 2 + (outputArray[0] ^ outputWired[0]) * 1;
      tempsettings=(outputArray[7] ^ outputWired[7]) * 128 + (outputArray[6] ^ outputWired[6]) * 64 + (outputArray[5] ^ outputWired[5]) * 32 + (outputArray[4] ^ outputWired[4]) * 16 + tempsettings;
      settinglo=(byte)(tempsettings);
    }
    if ((nodeType == WM) || (nodeType == SY)) {
      cmdlen=3;
      cmdcode=0x01;
    }
    if (nodeType == SC) {
      cmdlen=3;
      cmdcode=0x01;
    }
    if ((nodeType == SM) || (nodeType == SW) || (nodeType == YM)) {
      cmdlen=5;
      cmdcode=0x09;
      int tempsettings=(outputArray[3] ^ outputWired[3]) * 8 + (outputArray[2] ^ outputWired[2]) * 4 + (outputArray[1] ^ outputWired[1]) * 2 + (outputArray[0] ^ outputWired[0]) * 1;
      tempsettings=(outputArray[7] ^ outputWired[7]) * 128 + (outputArray[6] ^ outputWired[6]) * 64 + (outputArray[5] ^ outputWired[5]) * 32 + (outputArray[4] ^ outputWired[4]) * 16 + tempsettings;
      settinglo=(byte)(tempsettings);
      int tempsettings2=(outputArray[11] ^ outputWired[11]) * 8 + (outputArray[10] ^ outputWired[10]) * 4 + (outputArray[9] ^ outputWired[9]) * 2 + (outputArray[8] ^ outputWired[8]) * 1;
      tempsettings2=(outputArray[15] ^ outputWired[15]) * 128 + (outputArray[14] ^ outputWired[14]) * 64 + (outputArray[13] ^ outputWired[13]) * 32 + (outputArray[12] ^ outputWired[12]) * 16 + tempsettings2;
      settinghi=(byte)(tempsettings2);
    }
  }
 else {
    c=0;
    boolean foundsomething=false;
    while ((c < outputbitsPerCard) && !foundsomething) {
      if (outputNeedToSend[c]) {
        Integer tempaddr=Integer.valueOf(c + addrlo);
        addrlo=tempaddr.byteValue();
        outputNeedToSend[c]=false;
        foundsomething=true;
        if (outputSpecial[c] == 0) {
          if (outputType[c] == AcelaNode.ONOFF) {
            int tempcommand=(outputArray[c] ^ outputWired[c]);
            if (tempcommand == 0) {
              tempcommand=2;
            }
            cmdcode=(byte)(tempcommand);
            cmdlen=3;
          }
          if (outputType[c] == AcelaNode.BLINK) {
            int tempcommand=outputArray[c];
            if ((tempcommand == 1) && (outputWired[c] == 1)) {
              tempcommand=5;
            }
            if ((tempcommand == 1) && (outputWired[c] == 0)) {
              tempcommand=6;
            }
            if (tempcommand == 0) {
              tempcommand=2;
            }
            cmdcode=(byte)(tempcommand);
            if (cmdcode == 0x02) {
              cmdlen=3;
            }
 else {
              cmdlen=4;
              settinglo=(byte)outputLength[c];
            }
          }
          if (outputType[c] == AcelaNode.PULSE) {
            int tempcommand=outputArray[c];
            if ((tempcommand == 1) && (outputWired[c] == 1)) {
              tempcommand=4;
            }
            if ((tempcommand == 1) && (outputWired[c] == 0)) {
              tempcommand=3;
            }
            if (tempcommand == 0) {
              tempcommand=2;
            }
            cmdcode=(byte)(tempcommand);
            if (cmdcode == 0x02) {
              cmdlen=3;
            }
 else {
              cmdlen=4;
              settinglo=(byte)outputLength[c];
            }
          }
        }
 else {
switch (outputSignalHeadType[c]) {
case DOUBLE:
{
switch (outputSpecial[c]) {
case 1:
                cmdcode=0x0c;
              settinglo=0x01;
            break;
case 2:
          cmdcode=0x0c;
        settinglo=0x02;
      break;
case 3:
    cmdcode=0x0c;
  settinglo=0x08;
break;
case 4:
cmdcode=0x0c;
settinglo=0x08;
break;
case 5:
cmdcode=0x0c;
settinglo=0x04;
break;
case 6:
cmdcode=0x0c;
settinglo=0x08;
break;
case 7:
cmdcode=0x0c;
settinglo=0x00;
break;
default :
cmdcode=0x0c;
settinglo=0x03;
break;
}
break;
}
case TRIPLE:
{
switch (outputSpecial[c]) {
case 1:
cmdcode=0x0d;
settinglo=0x01;
break;
case 2:
cmdcode=0x0d;
settinglo=0x02;
break;
case 3:
cmdcode=0x0d;
settinglo=0x04;
break;
case 4:
cmdcode=0x0d;
settinglo=0x08;
break;
case 5:
cmdcode=0x0d;
settinglo=0x10;
break;
case 6:
cmdcode=0x0d;
settinglo=0x20;
break;
case 7:
cmdcode=0x0d;
settinglo=0x00;
break;
default :
cmdcode=0x0d;
settinglo=0x03;
break;
}
break;
}
case BPOLAR:
{
switch (outputSpecial[c]) {
case 1:
cmdcode=0x0c;
settinglo=0x01;
break;
case 2:
cmdcode=0x0c;
settinglo=0x02;
break;
case 3:
cmdcode=0x0c;
settinglo=0x10;
break;
case 4:
cmdcode=0x0c;
settinglo=0x20;
break;
case 5:
cmdcode=0x0c;
settinglo=0x04;
break;
case 6:
cmdcode=0x0c;
settinglo=0x08;
break;
case 7:
cmdcode=0x0c;
settinglo=0x00;
break;
default :
cmdcode=0x0c;
settinglo=0x03;
break;
}
break;
}
case WIGWAG:
{
switch (outputSpecial[c]) {
case 1:
cmdcode=0x0c;
settinglo=0x0B;
break;
case 2:
cmdcode=0x0c;
settinglo=0x0B;
break;
case 3:
cmdcode=0x0c;
settinglo=0x0B;
break;
case 4:
cmdcode=0x0c;
settinglo=0x0B;
break;
case 5:
cmdcode=0x0c;
settinglo=0x0B;
break;
case 6:
cmdcode=0x0c;
settinglo=0x0B;
break;
case 7:
cmdcode=0x0c;
settinglo=0x00;
break;
default :
cmdcode=0x0c;
settinglo=0x0F;
break;
}
break;
}
default :
{
switch (outputSpecial[c]) {
case 1:
cmdcode=0x0d;
settinglo=0x01;
break;
case 2:
cmdcode=0x0d;
settinglo=0x03;
break;
case 3:
cmdcode=0x0d;
settinglo=0x04;
break;
case 4:
cmdcode=0x0d;
settinglo=0x08;
break;
case 5:
cmdcode=0x0d;
settinglo=0x10;
break;
case 6:
cmdcode=0x0d;
settinglo=0x30;
break;
case 7:
cmdcode=0x0d;
settinglo=0x00;
break;
default :
cmdcode=0x0d;
settinglo=0x03;
break;
}
}
}
cmdlen=4;
}
}
c++;
}
}
AcelaMessage m=new AcelaMessage(cmdlen);
m.setElement(0,cmdcode);
m.setElement(1,addrhi);
m.setElement(2,addrlo);
if (cmdlen > 3) {
if (cmdlen > 4) {
m.setElement(3,settinghi);
}
 else {
m.setElement(3,settinglo);
}
}
if (cmdlen > 4) {
m.setElement(4,settinglo);
}
m.setBinary(true);
return m;
}

public AbstractMRMessage createOutPacket ( ) { int cmdlen = 3 ; byte cmdcode = 0x03 ; byte addrhi = 0x00 ; byte addrlo = 0x00 ; byte settinghi = 0x00 ; byte settinglo = 0x00 ; boolean bulk_message = true ; int c = 0 ; while ( c < outputbitsPerCard ) { if ( ( outputType [ c ] != AcelaNode . ONOFF ) || ( outputSpecial [ c ] != 0 ) ) { bulk_message = false ; } c ++ ; } if ( ! bulk_message ) { c = 0 ; boolean foundfirst = false ; boolean foundanother = false ; while ( c < outputbitsPerCard ) { if ( outputNeedToSend [ c ] && foundfirst ) { foundanother = true ; } if ( outputNeedToSend [ c ] && ! foundfirst ) { foundfirst = true ; } c ++ ; } if ( foundanother ) { setMustSend ( ) ; } } Integer tempint = Integer . valueOf ( startingOutputAddress ) ; addrlo = tempint . byteValue ( ) ; if ( bulk_message ) { if ( nodeType == TB ) { cmdlen = 4 ; cmdcode = 0x07 ; int tempsettings = ( outputArray [ 3 ] ^ outputWired [ 3 ] ) * 8 + ( outputArray [ 2 ] ^ outputWired [ 2 ] ) * 4 + ( outputArray [ 1 ] ^ outputWired [ 1 ] ) * 2 + ( outputArray [ 0 ] ^ outputWired [ 0 ] ) * 1 ; settinglo = ( byte ) ( tempsettings ) ; } if ( nodeType == D8 ) { cmdlen = 4 ; cmdcode = 0x08 ; int tempsettings = ( outputArray [ 3 ] ^ outputWired [ 3 ] ) * 8 + ( outputArray [ 2 ] ^ outputWired [ 2 ] ) * 4 + ( outputArray [ 1 ] ^ outputWired [ 1 ] ) * 2 + ( outputArray [ 0 ] ^ outputWired [ 0 ] ) * 1 ; tempsettings = ( outputArray [ 7 ] ^ outputWired [ 7 ] ) * 128 + ( outputArray [ 6 ] ^ outputWired [ 6 ] ) * 64 + ( outputArray [ 5 ] ^ outputWired [ 5 ] ) * 32 + ( outputArray [ 4 ] ^ outputWired [ 4 ] ) * 16 + tempsettings ; settinglo = ( byte ) ( tempsettings ) ; } if ( ( nodeType == WM ) || ( nodeType == SY ) ) { cmdlen = 3 ; cmdcode = 0x01 ; } if ( nodeType == SC ) { cmdlen = 3 ; cmdcode = 0x01 ; } if ( ( nodeType == SM ) || ( nodeType == SW ) || ( nodeType == YM ) ) { cmdlen = 5 ; cmdcode = 0x09 ; int tempsettings = ( outputArray [ 3 ] ^ outputWired [ 3 ] ) * 8 + ( outputArray [ 2 ] ^ outputWired [ 2 ] ) * 4 + ( outputArray [ 1 ] ^ outputWired [ 1 ] ) * 2 + ( outputArray [ 0 ] ^ outputWired [ 0 ] ) * 1 ; tempsettings = ( outputArray [ 7 ] ^ outputWired [ 7 ] ) * 128 + ( outputArray [ 6 ] ^ outputWired [ 6 ] ) * 64 + ( outputArray [ 5 ] ^ outputWired [ 5 ] ) * 32 + ( outputArray [ 4 ] ^ outputWired [ 4 ] ) * 16 + tempsettings ; settinglo = ( byte ) ( tempsettings ) ; int tempsettings2 = ( outputArray [ 11 ] ^ outputWired [ 11 ] ) * 8 + ( outputArray [ 10 ] ^ outputWired [ 10 ] ) * 4 + ( outputArray [ 9 ] ^ outputWired [ 9 ] ) * 2 + ( outputArray [ 8 ] ^ outputWired [ 8 ] ) * 1 ; tempsettings2 = ( outputArray [ 15 ] ^ outputWired [ 15 ] ) * 128 + ( outputArray [ 14 ] ^ outputWired [ 14 ] ) * 64 + ( outputArray [ 13 ] ^ outputWired [ 13 ] ) * 32 + ( outputArray [ 12 ] ^ outputWired [ 12 ] ) * 16 + tempsettings2 ; settinghi = ( byte ) ( tempsettings2 ) ; } } else { c = 0 ; boolean foundsomething = false ; while ( ( c < outputbitsPerCard ) && ! foundsomething ) { if ( outputNeedToSend [ c ] ) { Integer tempaddr = Integer . valueOf ( c + addrlo ) ; addrlo = tempaddr . byteValue ( ) ; outputNeedToSend [ c ] = false ; foundsomething = true ; if ( outputSpecial [ c ] == 0 ) { if ( outputType [ c ] == AcelaNode . ONOFF ) { int tempcommand = ( outputArray [ c ] ^ outputWired [ c ] ) ; if ( tempcommand == 0 ) { tempcommand = 2 ; } cmdcode = ( byte ) ( tempcommand ) ; cmdlen = 3 ; } if ( outputType [ c ] == AcelaNode . BLINK ) { int tempcommand = outputArray [ c ] ; if ( ( tempcommand == 1 ) && ( outputWired [ c ] == 1 ) ) { tempcommand = 5 ; } if ( ( tempcommand == 1 ) && ( outputWired [ c ] == 0 ) ) { tempcommand = 6 ; } if ( tempcommand == 0 ) { tempcommand = 2 ; } cmdcode = ( byte ) ( tempcommand ) ; if ( cmdcode == 0x02 ) { cmdlen = 3 ; } else { cmdlen = 4 ; settinglo = ( byte ) outputLength [ c ] ; } } if ( outputType [ c ] == AcelaNode . PULSE ) { int tempcommand = outputArray [ c ] ; if ( ( tempcommand == 1 ) && ( outputWired [ c ] == 1 ) ) { tempcommand = 4 ; } if ( ( tempcommand == 1 ) && ( outputWired [ c ] == 0 ) ) { tempcommand = 3 ; } if ( tempcommand == 0 ) { tempcommand = 2 ; } cmdcode = ( byte ) ( tempcommand ) ; if ( cmdcode == 0x02 ) { cmdlen = 3 ; } else { cmdlen = 4 ; settinglo = ( byte ) outputLength [ c ] ; } } } else { switch ( outputSignalHeadType [ c ] ) { case DOUBLE : { switch ( outputSpecial [ c ] ) { case 1 : cmdcode = 0x0c ; settinglo = 0x01 ; break ; case 2 : cmdcode = 0x0c ; settinglo = 0x02 ; break ; case 3 : cmdcode = 0x0c ; settinglo = 0x08 ; break ; case 4 : cmdcode = 0x0c ; settinglo = 0x08 ; break ; case 5 : cmdcode = 0x0c ; settinglo = 0x04 ; break ; case 6 : cmdcode = 0x0c ; settinglo = 0x08 ; break ; case 7 : cmdcode = 0x0c ; settinglo = 0x00 ; break ; default : cmdcode = 0x0c ; settinglo = 0x03 ; break ; } break ; } case TRIPLE : { switch ( outputSpecial [ c ] ) { case 1 : cmdcode = 0x0d ; settinglo = 0x01 ; break ; case 2 : cmdcode = 0x0d ; settinglo = 0x02 ; break ; case 3 : cmdcode = 0x0d ; settinglo = 0x04 ; break ; case 4 : cmdcode = 0x0d ; settinglo = 0x08 ; break ; case 5 : cmdcode = 0x0d ; settinglo = 0x10 ; break ; case 6 : cmdcode = 0x0d ; settinglo = 0x20 ; break ; case 7 : cmdcode = 0x0d ; settinglo = 0x00 ; break ; default : cmdcode = 0x0d ; settinglo = 0x03 ; break ; } break ; } case BPOLAR : { switch ( outputSpecial [ c ] ) { case 1 : cmdcode = 0x0c ; settinglo = 0x01 ; break ; case 2 : cmdcode = 0x0c ; settinglo = 0x02 ; break ; case 3 : cmdcode = 0x0c ; settinglo = 0x10 ; break ; case 4 : cmdcode = 0x0c ; settinglo = 0x20 ; break ; case 5 : cmdcode = 0x0c ; settinglo = 0x04 ; break ; case 6 : cmdcode = 0x0c ; settinglo = 0x08 ; break ; case 7 : cmdcode = 0x0c ; settinglo = 0x00 ; break ; default : cmdcode = 0x0c ; settinglo = 0x03 ; break ; } break ; } case WIGWAG : { switch ( outputSpecial [ c ] ) { case 1 : cmdcode = 0x0c ; settinglo = 0x0B ; break ; case 2 : cmdcode = 0x0c ; settinglo = 0x0B ; break ; case 3 : cmdcode = 0x0c ; settinglo = 0x0B ; break ; case 4 : cmdcode = 0x0c ; settinglo = 0x0B ; break ; case 5 : cmdcode = 0x0c ; settinglo = 0x0B ; break ; case 6 : cmdcode = 0x0c ; settinglo = 0x0B ; break ; case 7 : cmdcode = 0x0c ; settinglo = 0x00 ; break ; default : cmdcode = 0x0c ; settinglo = 0x0F ; break ; } break ; } default : { switch ( outputSpecial [ c ] ) { case 1 : cmdcode = 0x0d ; settinglo = 0x01 ; break ; case 2 : cmdcode = 0x0d ; settinglo = 0x03 ; break ; case 3 : cmdcode = 0x0d ; settinglo = 0x04 ; break ; case 4 : cmdcode = 0x0d ; settinglo = 0x08 ; break ; case 5 : cmdcode = 0x0d ; settinglo = 0x10 ; break ; case 6 : cmdcode = 0x0d ; settinglo = 0x30 ; break ; case 7 : cmdcode = 0x0d ; settinglo = 0x00 ; break ; default : cmdcode = 0x0d ; settinglo = 0x03 ; break ; } } } cmdlen = 4 ; } } c ++ ; } } AcelaMessage m = new AcelaMessage ( cmdlen ) ; m . setElement ( 0 , cmdcode ) ; m . setElement ( 1 , addrhi ) ; m . setElement ( 2 , addrlo ) ; if ( cmdlen > 3 ) { if ( cmdlen > 4 ) { m . setElement ( 3 , settinghi ) ; } else { m . setElement ( 3 , settinglo ) ; } } if ( cmdlen > 4 ) { m . setElement ( 4 , settinglo ) ; } m . setBinary ( true ) ; return m ; }
public method to create an transmit packet ( serialmessage )
