Message Handler Example

[Home] [SECS Library] [Host Example] [Equipment Example] [Message Handler Example]

Message Handler Example

This code example is distributed with the SECS Library. It is an example of writing your own “Message Handler” object. This can be used as a model for your own Message Handler.

/*Title:       Example Message Handler
 *Copyright:   Copyright (c) 1998, 1999
 *Author:      Jim Redman
 *Company:     ErgoTech Systems, Inc.
 *Description: Used to test SECS

# SECS-GEM: True
# Test: True
# Not-To-JavaDoc: True
*/
/* The contents of this file are confidental property of ErgoTech Systems, Inc.
 * as described in the file "Ownership.txt". If you did not receive a copy
 * of that file please contact ErgoTech at +1 505 662 5156 or info@ergotech.com.
 */


import java.util.*;
import com.ergotech.secs.*;


/** This object is will have methods call if a msg comes in with the same method name.
*/
public class ExampleMessageHandlerObject {
  public static final String cvsRev =  "CVS Info:$Revision: 1.2 $ $Date: 2003/07/23 18:08:55 $";
  // This code is all pretty self-evident
  // ALL the objects should have JavaDocs at the top of the object that should explain what they do.
  // At least most of the methods also have JavaDocs.
  static public void main (String args[]) {
   /*   try {
     PortManager.allIDsValid =  true; // allow all device ids to be valid
     HSMSPassiveWrapper pw =  new HSMSPassiveWrapper(2345);
     pw.messageHandler( new MessageHandlerObject());
     Logger theLogger = new Logger("Orgi", "Orgi");
     theLogger.setDisplayBytes(true);
     theLogger.setDisplayMessages(true);
     pw.setLogger(0x7fff, theLogger);
     pw.listenForConnections();
   } catch (Throwable e) {
     System.out.println(e);
   }*/
  }


  /** Returns the data without throwing. */
  protected SecsFormat getData (SecsMsg msg) {
   try {
     return msg.getData();
   } catch (SecsException se) {
     se.printStackTrace(); // a pretty unlikely error.
   }

   return null;
  }


  // This method is test receive S1F1 message and send its reply by the S1F2
  public boolean S1F1 (SecsMsg msg) {
   try {
     SecsFormat s1f1 =  getData(msg);
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S1F1:");
     System.out.println(" S1F1 = " + s1f1);
     System.out.println("---------------------------------------------");

     /*   S1F1 send = new S1F1();
   send.setPrimaryMessage(msg);
   send.sendMessage();*/
     if (s1f1 == null) {
       S1F2 reply = new S1F2(new MDLN("s1f2-1"), new SOFTREV("s1f2-2"));
       reply.setPrimaryMessage(msg);
       reply.sendMessage();
     } else {
       System.out.println("Error in S1F1: data not in proper form.  Looking for a null");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }

   return true;
  }


  // This method is test S1F2
  public boolean S1F2 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);
   System.out.println("----------------------------------------");
   System.out.println(" Received reply message S1F2 to S1F1:");
   System.out.println(" S1F2 = " + temp);
   System.out.println("----------------------------------------");
   return true;
  }


  // This method is test receivsing  S1F3 and send its reply by the S1F2
  public boolean S1F3 (SecsMsg msg) {
   try {
     System.out.println("Received S1F3: " + msg);
     SecsFormat s1f3 =  getData(msg);
     S1F4 reply = new S1F4(new SV("s1f4-1"));

     if (s1f3 instanceof SecsFormat00) {
       SecsFormat00 sf00 =  (SecsFormat00)s1f3;

       if (sf00.size() == 1) {
         if (sf00.elementAt(0) instanceof SVID) {
           SVID md =  (SVID)sf00.elementAt(0);
           System.out.println("---------------------------------------------");
           System.out.println(" Received a S1F3: " + msg.getSystemBytes());
           System.out.println(" SVID = " + md);
           System.out.println("---------------------------------------------");
         } else {
           System.out.println("Error in S1F3: data not in proper form.  Looking for a SVID in the first location");
         }
       } else {
         System.out.println("---------------------------------------------");
         System.out.println(" Received a S1F3: " + msg.getSystemBytes());
         System.out.println(" SVID = " + msg);
         System.out.println("---------------------------------------------");
         SecsFormat00 response =  new SecsFormat00(sf00.size());

         for (int count = 0; count < sf00.size(); count++) {
           response.addElement(new SV("S1F4-" + String.valueOf(count)));
         }

         reply =  new S1F4(response);
       }
     } else {
       System.out.println("Error in S1F3: data not in proper form.  Looking for a SecsFormat00");
     }

     reply.setPrimaryMessage(msg);
     reply.sendMessage();
   } catch (Throwable t) {
     t.printStackTrace();
   }

   return true;
  }


  // This method is test S1F4
  public boolean S1F4 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);
   System.out.println("----------------------------------------");
   System.out.println(" Received reply message S1F4 to S1F3:");
   System.out.println(" S1F4 = " + temp);
   System.out.println("----------------------------------------");
   return true;
  }


  // test S1F5 and reply by S1F6
  public boolean S1F5 (SecsMsg msg) {
   SecsFormat s1f5 =  getData(msg);

   if (s1f5 instanceof SFCD) {
     SFCD sd =  (SFCD)s1f5;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S1F5:");
     System.out.println(" SFCD = " + sd);
     System.out.println("---------------------------------------------");
     S1F6 reply = new S1F6();
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S1F5: data not in proper form.  Looking for a SFCD in the first location");
   }

   return true;
  }


  // This method is test S1F6
  public boolean S1F6 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);
   System.out.println("----------------------------------------");
   System.out.println(" Received reply message S1F6 to S1F5:");
   System.out.println(" S1F6 = " + temp);
   System.out.println("----------------------------------------");
   return true;
  }


  // test S1F7 and reply by S1F8
  public boolean S1F7 (SecsMsg msg) {
   SecsFormat s1f7 =  getData(msg);

   if (s1f7 instanceof SFCD) {
     SFCD sd =  (SFCD)s1f7;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S1F7:");
     System.out.println(" SFCD = " + sd);
     System.out.println("---------------------------------------------");
     S1F8 reply = new S1F8();
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S1F7: data not in proper form.  Looking for a SFCD in the first location");
   }

   return true;
  }


  // test S1F9 and reply by S1F10
  public boolean S1F9 (SecsMsg msg) {
   SecsFormat s1f9 =  getData(msg);

   if (s1f9 == null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S1F9:");
     System.out.println(" s1f9 = " + s1f9);
     System.out.println("---------------------------------------------");
     S1F10 reply =  new S1F10((new TSIP((byte)0)), (new TSOP((byte)1)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S1F9: data not in proper form.  Looking for a null in the first location");
   }

   return true;
  }


  // test S1F11 and reply by S1F12
  public boolean S1F11 (SecsMsg msg) {
   SecsFormat s1f11 = getData(msg);

   if (s1f11 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S1F11:");
     System.out.println(" s1f11 = " + s1f11);
     System.out.println("---------------------------------------------");
     S1F12 reply =  new S1F12(new SVID(1), new SVNAME("Svname"), new UNITS("Units"));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S1F11: Zero-Length message. Looking for a s1f11 in the first location");
   }

   return true;
  }


  // This method is test S1F13 and reply by S1F14
  public boolean S1F13 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);

   if (temp instanceof SecsFormat00) {
     SecsFormat00 sf00 =  (SecsFormat00)temp;

     if (sf00.size() == 2) {
       if (sf00.elementAt(0) instanceof MDLN) {
         MDLN md =  (MDLN)sf00.elementAt(0);

         if (sf00.elementAt(1) instanceof SOFTREV) {
           SOFTREV sr = (SOFTREV)sf00.elementAt(1);
           System.out.println("---------------------------------------------");
           System.out.println(" Received a S1F13:");
           System.out.println(" MDLN = " + md);
           System.out.println(" SOFTREV = " + sr);
           System.out.println("---------------------------------------------");
           //           S1F14 reply =  new S1F14(new COMMACK((byte)0), new MDLN("s1f14b"), new SOFTREV("s1f14c"));
           // if we get here, we received a full S1F13, that probably means that we are the host and so
           // should send an empty S1F14
           S1F14 reply =  new S1F14();
           reply.setPrimaryMessage(msg);

           try {
             reply.sendMessage();
           } catch (SecsException se) {
             se.printStackTrace();
           }
         } else {
           System.out.println("Error in S1F13: data not in proper form. Looking for a SOFTREV in the second location");
         }
       } else {
         System.out.println("Error in S1F13: data not in proper form. Looking for a MDLN in the first location");
       }
     } else {
       //System.out.println("Error in S1F13: data not in proper form. We didnt get enought data. Only " + sf00.size() + " bits of data.");
       System.out.println("Received a S1F13:" + temp);

       try {
         S1F14 reply =  new S1F14(new COMMACK((byte)0), new MDLN("s1f14b"), new SOFTREV("s1f14c"));
         reply.setPrimaryMessage(msg);
         reply.sendMessage();
       } catch (SecsException se) {
         se.printStackTrace();
       }
     }
   } else {
     //System.out.println("Error in S1F13: data not in proper form. Looking for a SecsFormat00");
     System.out.println("Received a S1F13:" + temp);

     try {
       S1F14 reply =  new S1F14(new COMMACK((byte)0), new MDLN("s1f14b"), new SOFTREV("s1f14c"));
       reply.setPrimaryMessage(msg);
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   }

   return true;
  }


  // This method is test S1F14 only
  public boolean S1F14 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);

   if (temp instanceof SecsFormat00) {
     SecsFormat00 sf00 =  (SecsFormat00)temp;

     //if (sf00.size() == 2) {
     if (sf00.elementAt(0) instanceof COMMACK) {
       COMMACK ck = (COMMACK)sf00.elementAt(0);

       if (sf00.elementAt(1) instanceof SecsFormat00) {
         SecsFormat00 sf01 =  (SecsFormat00)sf00.elementAt(1);

         //if (sf01.size() == 2) {
         if (sf01.elementAt(0) instanceof MDLN) {
           MDLN md =  (MDLN)sf01.elementAt(0);

           if (sf01.elementAt(1) instanceof SOFTREV) {
             SOFTREV sr = (SOFTREV)sf01.elementAt(1);
             System.out.println("----------------------------------------");
             System.out.println(" Received a S1F14:");
             System.out.println(" COMMACK = " + ck);
             System.out.println(" MDLN = " + md);
             System.out.println(" SOFTREV = " + sr);
             System.out.println("----------------------------------------");
           } else {
             System.out.println("Error in S1F14: data not in proper form. Looking for a SOFTREV in the second location");
           }
         } else {
           System.out.println("Error in S1F14: data not in proper form. Looking for a MDLN in the second location");
         }
       } else {
         System.out.println("Error in S1F14: data not in proper form. Looking for a COMMACK in the first location");
       }
     } else {
       System.out.println("Error in S1F14: data not in proper form. We didnt get enought data. Only " + sf00.size() + " bits of data.");
     }
   } else {
     System.out.println("Error in S1F14: data not in proper form. Looking for a SecsFormat00");
   }

   return true;
  }


  // This method is test S1F15 and SEND its reply by the S1F16
  public boolean S1F15 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);

   if (temp == null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S1F15:");
     System.out.println(" S1F15 = " + temp);
     System.out.println("---------------------------------------------");
     S1F16 reply =  new S1F16(new OFLACK(0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S1F15: data not in proper form. Looking for a null");
   }

   return true;
  }


  // This method is test S1F17 and wait its reply by the S1F18
  public boolean S1F17 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);

   if (temp == null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S1F17:");
     System.out.println(" S1F17 = " + temp);
     System.out.println("---------------------------------------------");
     S1F18 reply =  new S1F18(new ONLACK(1));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S1F17: data not in proper form. Looking for a null");
   }

   return true;
  }


  // This method is test S2F1 only
  public boolean S2F1 (SecsMsg msg) {
   SecsFormat s2f1 =  getData(msg);

   if (s2f1 instanceof SecsFormat00) {
     SecsFormat00 s2f100 =  (SecsFormat00)s2f1;

     if (s2f100.size() == 2) {
       if (s2f100.elementAt(0) instanceof SPID) {
         SPID sd =  (SPID)s2f100.elementAt(0);

         if (s2f100.elementAt(1) instanceof LENGTH) {
           LENGTH lh =  (LENGTH)s2f100.elementAt(1);
           System.out.println("---------------------------------------------");
           System.out.println(" Received a S2F1:");
           System.out.println(" SPID = " + sd);
           System.out.println(" LENGTH = " + lh);
           System.out.println("---------------------------------------------");
           S2F2 reply = new S2F2(new GRANT(new byte[]{0, 1, 3}));
           reply.setPrimaryMessage(msg);

           try {
             reply.sendMessage();
           } catch (SecsException se) {
             se.printStackTrace();
           }
         } else {
           System.out.println("Error in S2F1: data not in proper form.  Looking for a LENGTH in the second location");
         }
       } else {
         System.out.println("Error in S2F1: data not in proper form.  Looking for a SPID in the first location");
       }
     } else {
       System.out.println("Error in S2F1: data not in proper form.  We didnt get enought data.  Only " + s2f100.size() + " bits of data.");
     }
   } else {
     System.out.println("Error in S2F1: data not in proper form.  Looking for a SecsFormat00");
   }

   return true;
  }


  // test S2F3 and reply by S2F4
  public boolean S2F3 (SecsMsg msg) {
   SecsFormat s2f3 =  getData(msg);

   //System.out.println(s2f2);
   if (s2f3 instanceof SPD) {
     SPD sd = (SPD)s2f3;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F3:");
     System.out.println(" SPD = " + sd);
     System.out.println("---------------------------------------------");
     S2F4 reply = new S2F4(new SPAACK(new byte[]{0, 1, 3}));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F3: data not in proper form.  Looking for a SPD in the first location");
   }

   return true;
  }


  // test S2F5 and reply by S2F6
  public boolean S2F5 (SecsMsg msg) {
   SecsFormat s2f5 =  getData(msg);

   //System.out.println(s2f2);
   if (s2f5 instanceof SPID) {
     SPID sd =  (SPID)s2f5;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F5:");
     System.out.println(" SPID = " + sd);
     System.out.println("---------------------------------------------");
     S2F6 reply = new S2F6(new SPD(new byte[]{0, 1, 3}));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F5: data not in proper form.  Looking for a SPID in the first location");
   }

   return true;
  }


  // test S2F7 and reply by S2F8
  public boolean S2F7 (SecsMsg msg) {
   SecsFormat s2f7 =  getData(msg);

   //System.out.println(s2f2);
   if (s2f7 instanceof SPID) {
     SPID sd =  (SPID)s2f7;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F7:");
     System.out.println(" SPID = " + sd);
     System.out.println("---------------------------------------------");
     S2F8 reply = new S2F8(new CSAACK(new byte[]{0, 1, 3}));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F7: data not in proper form.  Looking for a SPID in the first location");
   }

   return true;
  }


  // test S2F9 and reply by S2F10
  public boolean S2F9 (SecsMsg msg) {
   SecsFormat s2f9 =  getData(msg);

   //System.out.println(s2f2);
   if (s2f9 instanceof SPID) {
     SPID sd =  (SPID)s2f9;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F9:");
     System.out.println(" SPID = " + sd);
     System.out.println("---------------------------------------------");
     S2F10 reply =  new S2F10(new SPR(new byte[]{0, 1, 3}));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F9: data not in proper form.  Looking for a SPID in the first location");
   }

   return true;
  }


  // This method is test S2F11 and wait its reply by the S2F12
  public boolean S2F11 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);

   if (temp == null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F11:");
     System.out.println(" S2F11 = " + temp);
     System.out.println("---------------------------------------------");
     S2F12 reply =  new S2F12(new SPID("F12-1"));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F11: data not in proper form. Looking for a null");
   }

   return true;
  }


  // This method is test S2F13 and wait its reply by the S2F14
  public boolean S2F13 (SecsMsg msg) {
   SecsFormat s2f13 = getData(msg);

   if (s2f13 instanceof SecsFormat00) {
     SecsFormat00 s2f1300 = (SecsFormat00)s2f13;

     if (s2f1300.size() == 1) {
       if (s2f1300.elementAt(0) instanceof ECID) {
         ECID sd =  (ECID)s2f1300.elementAt(0);
         /* if (s2f1200.elementAt(1) instanceof SPID) {
           SPID lh = (SPID)s2f1200.elementAt(1);
         */
         System.out.println("---------------------------------------------");
         System.out.println(" Received a S2F13:");
         System.out.println(" ECID = " + sd);
         // System.out.println(" SPID = "+lh);
         System.out.println("---------------------------------------------");
         ECV theECV = new ECV(0);
         theECV.getData().setLength(0);
         S2F14 reply =  new S2F14(theECV);
         //S1F2 reply = new S1F2(PortManager.getActivePortManager().getModelType(),PortManager.getActivePortManager().g etRevision());
         reply.setPrimaryMessage(msg);

         try {
           reply.sendMessage();
         } catch (SecsException se) {
           se.printStackTrace();
         }

         /* } else {
           System.out.println("Error in S2F13: data not in proper form. Looking for a ECID in the second location");
       }
       */
       } else {
         System.out.println("Error in S2F13: data not in proper form. Looking for a ECID in the first location");
       }
     } else {
       System.out.println("Error in S2F13: data not in proper form. We didnt get enought data. Only " + s2f1300.size() + " bits of data.");
     }
   } else {
     System.out.println("Error in S2F13: data not in proper form. Looking for a SecsFormat00");
   }

   return true;
  }


  // test S2F15 and reply by S2F16
  public boolean S2F15 (SecsMsg msg) {
   SecsFormat s2f15 = getData(msg);

   if (s2f15 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F15:");
     System.out.println(" s2f15 = " + s2f15);
     System.out.println("---------------------------------------------");
     S2F16 reply =  new S2F16(new EAC((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F15: Zero-Length message. Looking for a s2f15 in the first location");
   }

   return true;
  }


  // test S2F17 and reply by S2F18
  public boolean S2F17 (SecsMsg msg) {
   SecsFormat s2f17 = getData(msg);

   if (s2f17 == null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F17:");
     System.out.println(" S2F17 = " + s2f17);
     System.out.println("---------------------------------------------");
     S2F18 reply =  new S2F18(new TIME("190102123030"));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F17: data not in proper form. Looking for a null in the first location");
   }

   return true;
  }


  // test S2F19 and reply by S2F20
  public boolean S2F19 (SecsMsg msg) {
   SecsFormat s2f19 = getData(msg);

   //System.out.println(s2f2);
   if (s2f19 instanceof RIC) {
     RIC sd = (RIC)s2f19;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F19:");
     System.out.println(" RIC = " + s2f19);
     System.out.println("---------------------------------------------");
     S2F20 reply =  new S2F20(new RAC((byte)1));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F19: data not in proper form. Looking for a RIC in the first location");
   }

   return true;
  }


  // test S2F21 and reply by S2F22
  public boolean S2F21 (SecsMsg msg) {
   SecsFormat s2f21 = getData(msg);

   //System.out.println(s2f2);
   if (s2f21 instanceof RCMD) {
     RCMD sd =  (RCMD)s2f21;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F21:");
     System.out.println(" RCMD = " + s2f21);
     System.out.println("---------------------------------------------");
     S2F22 reply =  new S2F22(new CMDA((byte)0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F21: data not in proper form. Looking for a RCMD in the first location");
   }

   return true;
  }


  // test S2F23 and reply by S2F24
  public boolean S2F23 (SecsMsg msg) {
   SecsFormat s2f23 = getData(msg);

   if (s2f23 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F23:");
     System.out.println(" s2f23 = " + s2f23);
     System.out.println("---------------------------------------------");
     S2F24 reply =  new S2F24(new TIAACK((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F23: Zero-Length message. Looking for a s2f23 in the first location");
   }

   return true;
  }


  // test S2F25 and reply by S2F26
  public boolean S2F25 (SecsMsg msg) {
   SecsFormat s2f25 = getData(msg);

   //System.out.println(s2f2);
   if (s2f25 instanceof ABS) {
     ABS sd = (ABS)s2f25;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F25:");
     System.out.println(" ABS = " + s2f25);
     System.out.println("---------------------------------------------");
     S2F26 reply =  new S2F26(new ABS(new byte[]{0, 1, 6}));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F25: data not in proper form. Looking for a ABS in the first location");
   }

   return true;
  }


  // test S2F27 and reply by S2F28
  public boolean S2F27 (SecsMsg msg) {
   SecsFormat s2f27 = getData(msg);

   if (s2f27 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F27:");
     System.out.println(" s2f27 = " + s2f27);
     System.out.println("---------------------------------------------");
     S2F28 reply =  new S2F28(new CMDA((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F27: Zero-Length message. Looking for a s2f27 in the first location");
   }

   return true;
  }


  // test S2F29 and reply by S2F30
  public boolean S2F29 (SecsMsg msg) {
   SecsFormat s2f29 = getData(msg);

   if (s2f29 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F29:");
     System.out.println(" s2f29 = " + s2f29);
     System.out.println("---------------------------------------------");
     S2F30 reply =  new S2F30(new ECID((byte)(0)), new ECNAME("Ecname"), new ECMIN(0), new ECMAX(100), new ECDEF("Ecdef"), new UNITS("Units"));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F29: Zero-Length message. Looking for a s2f29 in the first location");
   }

   return true;
  }


  // test S2F31 and reply by S2F32
  public boolean S2F31 (SecsMsg msg) {
   SecsFormat s2f31 = getData(msg);

   //System.out.println(s2f2);
   if (s2f31 instanceof TIME) {
     TIME ss =  (TIME)s2f31;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F31:");
     System.out.println(" TIME = " + ss.getDate());
     System.out.println("---------------------------------------------");
     S2F32 reply =  new S2F32(new TIACK((byte)0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F31: data not in proper form. Looking for a TIME in the first location");
   }

   return true;
  }


  // test S2F33 and reply by S2F34
  public boolean S2F33 (SecsMsg msg) {
   SecsFormat s2f33 = getData(msg);

   if (s2f33 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F33:");
     System.out.println(" s2f33 = " + s2f33);
     System.out.println("---------------------------------------------");
     S2F34 reply =  new S2F34(new DRACK((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F33: Zero-Length message. Looking for a s2f33 in the first location");
   }

   return true;
  }


  // test S2F35 and reply by S2F36
  public boolean S2F35 (SecsMsg msg) {
   SecsFormat s2f35 = getData(msg);

   if (s2f35 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F35:");
     System.out.println(" s2f35 = " + s2f35);
     System.out.println("---------------------------------------------");
     S2F36 reply =  new S2F36(new LRACK((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F35: Zero-Length message. Looking for a s2f35 in the first location");
   }

   return true;
  }


  // test S2F37 and reply by S2F38
  public boolean S2F37 (SecsMsg msg) {
   SecsFormat s2f37 = getData(msg);

   if (s2f37 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F37:");
     System.out.println(" s2f37 = " + s2f37);
     System.out.println("---------------------------------------------");
     S2F38 reply =  new S2F38(new ERACK((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F37: Zero-Length message. Looking for a s2f37 in the first location");
   }

   return true;
  }


  // test S2F39 and reply by S2F40
  public boolean S2F39 (SecsMsg msg) {
   SecsFormat s2f39 = getData(msg);

   if (s2f39 instanceof SecsFormat00) {
     SecsFormat00 s2f3900 = (SecsFormat00)s2f39;

     if (s2f3900.size() == 2) {
       if (s2f3900.elementAt(0) instanceof DATAID) {
         DATAID sd =  (DATAID)s2f3900.elementAt(0);

         if (s2f3900.elementAt(1) instanceof DATALENGTH) {
           DATALENGTH lh =  (DATALENGTH)s2f3900.elementAt(1);
           System.out.println("---------------------------------------------");
           System.out.println(" Received a S2F39:");
           System.out.println(" DATAID = " + sd);
           System.out.println(" DATALENGTH = " + lh);
           System.out.println("---------------------------------------------");
           S2F40 reply =  new S2F40(new GRANT(new byte[]{0, 1, 2}));
           reply.setPrimaryMessage(msg);

           try {
             reply.sendMessage();
           } catch (SecsException se) {
             se.printStackTrace();
           }
         } else {
           System.out.println("Error in S2F39: data not in proper form. Looking for a DATAID in the second location");
         }
       } else {
         System.out.println("Error in S2F39: data not in proper form. Looking for a DATALENGTH in the first location");
       }
     } else {
       System.out.println("Error in S2F39: data not in proper form. We didnt get enought data. Only " + s2f3900.size() + " bits of data.");
     }
   } else {
     System.out.println("Error in S2F39: data not in proper form. Looking for a SecsFormat00");
   }

   return true;
  }


  // test S2F41 and reply by S2F42
  public boolean S2F41 (SecsMsg msg) {
   SecsFormat s2f41 = getData(msg);

   if (s2f41 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F41:");
     System.out.println(" s2f41 = " + s2f41);
     System.out.println("---------------------------------------------");
     S2F42 reply =  new S2F42(new HCACK((byte)(1)), new CPNAME(0), new CPACK((byte)0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F41: Zero-Length message. Looking for a s2f41 in the first location");
   }

   return true;
  }


  // test S2F43 and reply by S2F44
  public boolean S2F43 (SecsMsg msg) {
   SecsFormat s2f43 = getData(msg);

   if (s2f43 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F43:");
     System.out.println(" s2f43 = " + s2f43);
     System.out.println("---------------------------------------------");
     S2F44 reply =  new S2F44(new RSPACK((byte)(0)), new STRID((byte)(0)), new STRACK((byte)(0)), new FCNID((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F43: Zero-Length message. Looking for a s2f43 in the first location");
   }

   return true;
  }


  // test S2F45 and reply by S2F46
  public boolean S2F45 (SecsMsg msg) {
   SecsFormat s2f45 = getData(msg);

   if (s2f45 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F45:");
     System.out.println(" s2f45 = " + s2f45);
     System.out.println("---------------------------------------------");
     S2F46 reply =  new S2F46(new VLAACK((byte)(0)), new VID((byte)(0)), new LVACK((byte)(0)), new LIMITID(new byte[]{0, 1, 2}), new LIMITACK((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F45: Zero-Length message. Looking for a s2f45 in the first location");
   }

   return true;
  }


  // test S2F47 and reply by S2F48
  public boolean S2F47 (SecsMsg msg) {
   SecsFormat s2f47 = getData(msg);

   if (s2f47 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F47:");
     System.out.println(" s2f47 = " + s2f47);
     System.out.println("---------------------------------------------");
     S2F48 reply =  new S2F48(new VID((byte)(0)), new UNITS("Units"), new LIMITMIN((byte)(0)), new LIMITMAX(100), new LIMITID(new byte[]{0, 1, 2}), new UPPERDB((byte)(10)), new LOWERDB(0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F47: Zero-Length message. Looking for a s2f47 in the first location");
   }

   return true;
  }


  // test S2F49 and reply by S2F50
  public boolean S2F49 (SecsMsg msg) {
   SecsFormat s2f49 = getData(msg);

   if (s2f49 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S2F49:");
     System.out.println(" s2f49 = " + s2f49);
     System.out.println("---------------------------------------------");
     S2F50 reply =  new S2F50(new HCACK((byte)(0)), new CPNAME("Cpname"), new CEPACK((byte)(1)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S2F49: Zero-Length message. Looking for a s2f49 in the first location");
   }

   return true;
  }


  // This method is test S2F50
  public boolean S2F50 (SecsMsg msg) {
   SecsFormat temp =  getData(msg);
   System.out.println("----------------------------------------");
   System.out.println(" Received reply message S2F50 to S2F49:");
   System.out.println(" S2F50 = " + temp);
   System.out.println("----------------------------------------");
   return true;
  }


  // test S5F1 and reply by S5F2
  public boolean S5F1 (SecsMsg msg) {
   SecsFormat s5f1 =  getData(msg);

   if (s5f1 instanceof SecsFormat00) {
     SecsFormat00 s5f100 =  (SecsFormat00)s5f1;

     if (s5f100.size() == 3) {
       if (s5f100.elementAt(0) instanceof ALCD) {
         ALCD sd =  (ALCD)s5f100.elementAt(0);

         if (s5f100.elementAt(1) instanceof ALID) {
           ALID lh =  (ALID)s5f100.elementAt(1);

           if (s5f100.elementAt(2) instanceof ALTX) {
             ALTX ax =  (ALTX)s5f100.elementAt(2);
             System.out.println("---------------------------------------------");
             System.out.println(" Received a S5F1:");
             System.out.println(" ALCD = " + sd);
             System.out.println(" ALID = " + lh);
             System.out.println(" ALTX = " + ax);
             System.out.println("---------------------------------------------");
             S5F2 reply = new S5F2(new ACKC5((byte)0));
             reply.setPrimaryMessage(msg);

             try {
               reply.sendMessage();
             } catch (Throwable e) {
               e.printStackTrace();
             }
           } else {
             System.out.println("Error in S5F1: data not in proper form.  Looking for a ALCD in the second location");
           }
         } else {
           System.out.println("Error in S5F1: data not in proper form.  Looking for a ALID in the second location");
         }
       } else {
         System.out.println("Error in S5F1: data not in proper form.  Looking for a ALTX in the first location");
       }
     } else {
       System.out.println("Error in S5F1: data not in proper form.  We didnt get enought data.  Only " + s5f100.size() + " bits of data.");
     }
   } else {
     System.out.println("Error in S5F1: data not in proper form.  Looking for a SecsFormat00");
   }

   return true;
  }


  // test S6F1 and reply by S6F2
  public boolean S6F1 (SecsMsg msg) {
   SecsFormat s6f1 =  getData(msg);

   if (s6f1 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F1:");
     System.out.println(" S6F1 = " + s6f1);
     System.out.println("---------------------------------------------");
     S6F2 reply = new S6F2(new ACKC6((byte)(0)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F1: Zero-Length message.  Looking for a s6f1 in the first location");
   }

   return true;
  }


  // test S6F3 and reply by S6F4
  public boolean S6F3 (SecsMsg msg) {
   SecsFormat s6f3 =  getData(msg);

   if (s6f3 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F3:");
     System.out.println(" S6F3 = " + s6f3);
     System.out.println("---------------------------------------------");
     S6F4 reply = new S6F4(new ACKC6((byte)(1)));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F3: Zero-Length message.  Looking for a s6f3 in the first location");
   }

   return true;
  }


  // test S6F5 and reply by S6F6
  public boolean S6F5 (SecsMsg msg) {
   SecsFormat s6f5 =  getData(msg);

   if (s6f5 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F5:");
     System.out.println(" S6F5 = " + s6f5);
     System.out.println("---------------------------------------------");
     S6F6 reply = new S6F6(new GRANT6(new byte[]{0, 1, 2}));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F5: Zero-Length message.  Looking for a s6f5 in the first location");
   }

   return true;
  }


  // test S6F7 and reply by S6F8
  public boolean S6F7 (SecsMsg msg) {
   SecsFormat s6f7 =  getData(msg);

   if (s6f7 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F7:");
     System.out.println(" S6F7 = " + s6f7);
     System.out.println("---------------------------------------------");
     S6F8 reply = new S6F8(new DATAID(1), new CEID(1), new DSID(1), new DVNAME("DVNAME"), new DVVAL(1));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F7: Zero-Length message.  Looking for a s6f7 in the first location");
   }

   return true;
  }


  // test S6F9 and reply by S6F10
  public boolean S6F9 (SecsMsg msg) {
   SecsFormat s6f9 =  getData(msg);

   if (s6f9 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F9:");
     System.out.println(" S6F9 = " + s6f9);
     System.out.println("---------------------------------------------");
     S6F10 reply =  new S6F10(new ACKC6((byte)0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F9: Zero-Length message.  Looking for a s6f9 in the first location");
   }

   return true;
  }


  // test S6F11 complete with decompose.
  public boolean S6F11 (SecsMsg msg) {
   try {
     // Decompose the Message
     // Since we convert messages lazily, first force the conversion.
     SecsFormat00 s6f11 = (SecsFormat00)getData(msg);
     System.out.println("\nFull Message: " + s6f11);
     // A SecsFormat00 is a Vector - The zero'th element is the DATAID
     DATAID dataId =  (DATAID)s6f11.elementAt(0);
     System.out.println("S6F11:\n\tData ID " + dataId);
     // The first element is the CEID
     CEID ceid =  (CEID)s6f11.elementAt(1);
     System.out.println("\tEvent Id " + ceid);
     // The next element is another SecsFormat00 - the reports
     SecsFormat00 allReports =  (SecsFormat00)s6f11.elementAt(2);

     // Go through each report.
     for (int r = 0; r < allReports.size(); r++) {
       // get this report, it too is a Vector
       SecsFormat00 report =  (SecsFormat00)allReports.elementAt(r);
       // The first element is the report id.
       RPTID rptid =  (RPTID)report.elementAt(0);
       System.out.println("\t\tReport Id: " + rptid);
       // The second element is a Vector of values.
       SecsFormat00 values =  (SecsFormat00)report.elementAt(1);

       for (int v = 0; v < values.size(); v++) {
         V value =  (V)values.elementAt(v);
         System.out.println("\t\t\tValue: " + value);
       }
     }
   } catch (Throwable e) {
     e.printStackTrace();
   }

   // Send the response, we're always happy.
   S6F12 reply =  new S6F12(new ACKC6((byte)0));
   reply.setPrimaryMessage(msg);

   try {
     reply.sendMessage();
   } catch (SecsException se) {
     se.printStackTrace();
   }

   return true;
  }


  /* test S6F12 and reply by S6F12
  */
  public boolean S6F12 (SecsMsg msg) {
   SecsFormat s6f12 = getData(msg);

   if (s6f12 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F12:");
     System.out.println(" S6F12 = " + s6f12);
     System.out.println("---------------------------------------------");
   } else {
     System.out.println("Error in S6F11: Zero-Length message. Looking for a s6f11 in the first location");
   }

   return true;
  }


  // test S6F13 and reply by S6F14
  public boolean S6F13 (SecsMsg msg) {
   SecsFormat s6f13 = getData(msg);

   if (s6f13 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F13:");
     System.out.println(" S6F13 = " + s6f13);
     System.out.println("---------------------------------------------");
     S6F14 reply =  new S6F14(new ACKC6((byte)0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F13: Zero-Length message. Looking for a s6f13 in the first location");
   }

   return true;
  }


  // test S6F15 and reply by S6F16
  public boolean S6F15 (SecsMsg msg) {
   SecsFormat s6f15 = getData(msg);

   if (s6f15 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F15:");
     System.out.println(" S6F15 = " + s6f15);
     System.out.println("---------------------------------------------");
     S6F16 reply =  new S6F16(new DATAID((byte)0), new CEID((byte)1), new RPTID((byte)1), new V(1));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F15: Zero-Length message. Looking for a s6f15 in the first location");
   }

   return true;
  }


  // test S6F17 and reply by S6F18
  public boolean S6F17 (SecsMsg msg) {
   SecsFormat s6f17 = getData(msg);

   if (s6f17 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F17:");
     System.out.println(" S6F17 = " + s6f17);
     System.out.println("---------------------------------------------");
     S6F18 reply =  new S6F18(new DATAID((byte)0), new CEID((byte)1), new RPTID((byte)1), new VID(1), new V(0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F17: Zero-Length message. Looking for a s6f17 in the first location");
   }

   return true;
  }


  // test S6F19 and reply by S6F20
  public boolean S6F19 (SecsMsg msg) {
   SecsFormat s6f19 = getData(msg);

   if (s6f19 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F19:");
     System.out.println(" S6F19 = " + s6f19);
     System.out.println("---------------------------------------------");
     S6F20 reply =  new S6F20(new V(0));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F19: Zero-Length message. Looking for a s6f19 in the first location");
   }

   return true;
  }


  // test S6F21 and reply by S6F22
  public boolean S6F21 (SecsMsg msg) {
   SecsFormat s6f21 = getData(msg);

   if (s6f21 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F21:");
     System.out.println(" S6F21 = " + s6f21);
     System.out.println("---------------------------------------------");
     S6F22 reply =  new S6F22(new VID(1), new V(1));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F21: Zero-Length message. Looking for a s6f21 in the first location");
   }

   return true;
  }


  // test S6F23 and reply by S6F24
  public boolean S6F23 (SecsMsg msg) {
   SecsFormat s6f23 = getData(msg);

   if (s6f23 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F23:");
     System.out.println(" S6F23 = " + s6f23);
     System.out.println("---------------------------------------------");
     S6F24 reply =  new S6F24(new RSDA((byte)1));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F23: Zero-Length message. Looking for a s6f23 in the first location");
   }

   return true;
  }


  // test S6F25 and reply by S6F26
  public boolean S6F25 (SecsMsg msg) {
   SecsFormat s6f25 = getData(msg);

   if (s6f25 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F25:");
     System.out.println(" S6F25 = " + s6f25);
     System.out.println("---------------------------------------------");
     S6F26 reply =  new S6F26(new ACKC6((byte)1));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F25: Zero-Length message. Looking for a s6f25 in the first location");
   }

   return true;
  }


  // test S6F27 and reply by S6F28
  public boolean S6F27 (SecsMsg msg) {
   SecsFormat s6f27 = getData(msg);

   if (s6f27 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F27:");
     System.out.println(" S6F27 = " + s6f27);
     System.out.println("---------------------------------------------");
     S6F28 reply =  new S6F28(new TRID((byte)1));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F27: Zero-Length message. Looking for a s6f27 in the first location");
   }

   return true;
  }


  // test S6F29 and reply by S6F30
  public boolean S6F29 (SecsMsg msg) {
   SecsFormat s6f29 = getData(msg);

   if (s6f29 != null) {
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S6F29:");
     System.out.println(" S6F29 = " + s6f29);
     System.out.println("---------------------------------------------");
     S6F30 reply =  new S6F30(new TRID((byte)1), new RPTID((byte)0), new V(1), new ERRCODE(10));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S6F29: Zero-Length message. Looking for a s6f29 in the first location");
   }

   return true;
  }


  // test S7F1 and reply by S7F2
  public boolean S7F1 (SecsMsg msg) {
   SecsFormat s7f1 =  getData(msg);

   if (s7f1 instanceof SecsFormat00) {
     SecsFormat00 s7f100 =  (SecsFormat00)s7f1;

     if (s7f100.size() == 2) {
       if (s7f100.elementAt(0) instanceof PPID) {
         PPID sd =  (PPID)s7f100.elementAt(0);

         if (s7f100.elementAt(1) instanceof LENGTH) {
           LENGTH lh =  (LENGTH)s7f100.elementAt(1);
           System.out.println("---------------------------------------------");
           System.out.println(" Received a S7F1:");
           System.out.println(" PPID = " + sd);
           System.out.println(" LENGTH = " + lh);
           System.out.println("---------------------------------------------");
           S7F2 reply = new S7F2(new PPGNT(new byte[]{0, 1, 2}));
           reply.setPrimaryMessage(msg);

           try {
             reply.sendMessage();
           } catch (SecsException se) {
             se.printStackTrace();
           }
         } else {
           System.out.println("Error in S7F1: data not in proper form.  Looking for a PPID in the second location");
         }
       } else {
         System.out.println("Error in S7F1: data not in proper form.  Looking for a LENGTH in the first location");
       }
     } else {
       System.out.println("Error in S7F1: data not in proper form.  We didnt get enought data.  Only " + s7f100.size() + " bits of data.");
     }
   } else {
     System.out.println("Error in S7F1: data not in proper form.  Looking for a SecsFormat00");
   }

   return true;
  }


  // test S7F3 and reply by S7F4
  public boolean S7F3 (SecsMsg msg) {
   SecsFormat s7f3 =  getData(msg);

   if (s7f3 instanceof SecsFormat00) {
     SecsFormat00 s7f300 =  (SecsFormat00)s7f3;

     if (s7f300.size() == 2) {
       if (s7f300.elementAt(0) instanceof PPID) {
         PPID sd =  (PPID)s7f300.elementAt(0);

         if (s7f300.elementAt(1) instanceof PPBODY) {
           PPBODY lh =  (PPBODY)s7f300.elementAt(1);
           System.out.println("---------------------------------------------");
           System.out.println(" Received a S7F3:");
           System.out.println(" PPID = " + sd);
           System.out.println(" PPBODY = " + lh);
           System.out.println("---------------------------------------------");
           S7F4 reply = new S7F4(new ACKC7((byte)0));
           reply.setPrimaryMessage(msg);

           try {
             reply.sendMessage();
           } catch (SecsException se) {
             se.printStackTrace();
           }
         } else {
           System.out.println("Error in S7F3: data not in proper form.  Looking for a PPID in the second location");
         }
       } else {
         System.out.println("Error in S7F3: data not in proper form.  Looking for a PPBODY in the first location");
       }
     } else {
       System.out.println("Error in S7F3: data not in proper form.  We didnt get enought data.  Only " + s7f300.size() + " bits of data.");
     }
   } else {
     System.out.println("Error in S7F3: data not in proper form.  Looking for a SecsFormat00");
   }

   return true;
  }


  // test S7F5 and reply by S7F6
  public boolean S7F5 (SecsMsg msg) {
   SecsFormat s7f5 =  getData(msg);

   if (s7f5 instanceof PPID) {
     PPID sd =  (PPID)s7f5;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S7F5:");
     System.out.println(" PPID = " + sd);
     System.out.println("---------------------------------------------");
     S7F6 reply = new S7F6(new PPID("S7F6"), new PPBODY(new byte[]{0, 1, 2}));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S7F5: data not in proper form.  Looking for a PPID in the first location");
   }

   return true;
  }


  // test S7F7 and reply by S7F8
  public boolean S7F7 (SecsMsg msg) {
   SecsFormat s7f7 =  getData(msg);

   if (s7f7 instanceof MID) {
     MID sd = (MID)s7f7;
     System.out.println("---------------------------------------------");
     System.out.println(" Received a S7F7:");
     System.out.println(" MID = " + sd);
     System.out.println("---------------------------------------------");
     S7F8 reply = new S7F8(new PPID("S7F8"), new MID("S7F8-2"));
     reply.setPrimaryMessage(msg);

     try {
       reply.sendMessage();
     } catch (SecsException se) {
       se.printStackTrace();
     }
   } else {
     System.out.println("Error in S7F7: data not in proper form.  Looking for a MID in the first location");
   }

   return true;
  }


  // test receiving S5F2
  public boolean S5F2 (SecsMsg msg) {
   SecsFormat s5f2 =  getData(msg);

   //SecsFormat s5f2B = s5f2.getData();
   if (s5f2 instanceof ACKC5) {
     ACKC5 sd = (ACKC5)s5f2;
     System.out.println("*********************************************");
     System.out.println(" Reply message (S5F2)from Equipment to Host:");
     System.out.println(" ACKC5 = " + sd);
     System.out.println("*********************************************");
   } else {
     System.out.println("Error in S5F2: data not in proper form.  Looking for a ACKC5 in the first location");
   }

   return true;
  }


  // receiving S9F1
  public boolean S9F1 (SecsMsg msg) {
   SecsFormat s9f1 =  getData(msg);

   if (s9f1 instanceof MHEAD) {
     System.out.println("*********************************************");
     System.out.println(msg.longName() + " Message (S9F1): " + s9f1);
     System.out.println("*********************************************");
   } else {
     System.out.println("Error in S9F1: data not in proper form.  Looking for an MHEAD");
   }

   return true;
  }


  // All messages not specified above will come in here.
  public boolean processMessage (SecsTrigger msg) {
   System.out.println("shouldnt have got here.  Message not implemented");
   System.out.println(msg);
   //System.out.println((msg)getData());
   return true;
  }

}

(c) ErgoTech Systems, Inc., 2004