//************************************************************************** // Create a new message based on a message type public override Ris.ByteContent createMsg(int aMessageType) { Ris.ByteContent tMsg = null; switch (aMessageType) { case MsgIdT.cTestMsg: tMsg = new TestMsg(); break; case MsgIdT.cFirstMessageMsg: tMsg = new FirstMessageMsg(); break; case MsgIdT.cStatusRequestMsg: tMsg = new StatusRequestMsg(); break; case MsgIdT.cStatusResponseMsg: tMsg = new StatusResponseMsg(); break; case MsgIdT.cDataMsg: tMsg = new DataMsg(); break; default: break; } return(tMsg); }
//****************************************************************************** //****************************************************************************** //****************************************************************************** // StatusResponseMsg public static void initialize(StatusResponseMsg aMsg) { aMsg.mCode1 = 1201; aMsg.mCode2 = 1202; aMsg.mCode3 = 1203; aMsg.mCode4 = 1204; aMsg.mNumOfWords = 4; for (int i = 0; i < aMsg.mNumOfWords; i++) { aMsg.mWords[i] = 101 + i; } }
public static void show(StatusResponseMsg aMsg) { Prn.print(Prn.ThreadRun1, "ProtoCommMsg.StatusMsg"); Prn.print(Prn.ThreadRun1, "Code1 {0}", aMsg.mCode1); Prn.print(Prn.ThreadRun1, "Code2 {0}", aMsg.mCode2); Prn.print(Prn.ThreadRun1, "Code3 {0}", aMsg.mCode3); Prn.print(Prn.ThreadRun1, "Code4 {0}", aMsg.mCode4); for (int i = 0; i < aMsg.mNumOfWords; i++) { Prn.print(Prn.ThreadRun1, "Words {0} {1}", 1, aMsg.mWords[i]); aMsg.mWords[i] = 101 + i; } }
//****************************************************************************** // Rx message handler - StatusResponseMsg void processRxMsg(StatusResponseMsg aMsg) { Prn.print(Prn.ThreadRun1, "NetworkThread.processRxMsg_StatusResponseMsg"); Helper.show(aMsg); }