Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 19 of 19

Thread: Able to set, but not get values

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Able to set, but not get values

    Hi guys!

    I have a problem with getting values after I set them.
    Before setting the values, I created 3 send files to send different kinds of messages and 3 receive files to receive the messages that I sent (along with some computation). Basically, I can send the message into the send files and print them out. However I am not able to get the values using the get methods and print them out. Is it because when I set the values and write them into the send files, the values are wiped out from the set methods, therefore I am unable to get the values using the get methods??

    Any help or suggestions are greatly appreciated!


    Regards


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Able to set, but not get values

    Its tough to provide feedback without more specific information - more specifically short snippets of code that reproduce the problem. Is the send/receive over a network? What do you mean by set and get (hash, method, file, etc...)? The more info the better.

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    Whoops, my bad.
    It's more to methods.

    Here are some snippets:
    (this is where i set the values using my GUI)

    else if(cmd.equalsIgnoreCase(NODEQUERY_CMD)){
    			nodeQueryMsg.set_srcMoteId(TOS_GATEWAY_ADDR);
    			nodeQueryMsg.set_moteGroup(CMWAD_MOTEGROUP);
    			nodeQueryMsg.set_sourceAddr(TOS_GATEWAY_ADDR);
    			nodeQueryMsg.set_originAddr(node);//receive input from user (node)
    			nodeQueryMsg.set_hopCounts((short)0);
    			nodeQueryMsg.set_sequenceNo(querySeqNum++);
    			nodeQueryMsg.set_msgType(msg); //recive input from user (command)
    			nodeQueryMsg.set_queryType(query); //receive input from user (argument)
     
                    dataString += cmd + "\nsrcMoteId: " + TOS_GATEWAY_ADDR + " , moteGroup: " + CMWAD_MOTEGROUP
                            + " , sourceAddr: " + TOS_GATEWAY_ADDR + " , originAddr: " + node + " , hopCounts: " + (short)0
                            + " , sequenceNo: " + querySeqNum + " , msgType: " + msg + " , ackType: " + query;
                    try{
                        System.out.println(dataString);
                        fManager.writeString2File(NODEQUERY_FILENAME_SEND, dataString, true);
                        doneSending = true;
                    }
     
                    catch(IOException ioe){
                        System.err.println("Unable to write data into file at CarerEventReceived");
                    }

    Once the doneSending is true, I will try to receive what I sent using the get methods:
    (this is where I use the get methods to get the values of what I sent)

    else if(smtw.getCommand().equalsIgnoreCase(NODEQUERY_CMD)){
                dataString += smtw.getCommand() + "\n moteID: " +  nodeQueryMsg.get_srcMoteId()
                        + " , moteGroup: " + nodeQueryMsg.get_moteGroup()
                        + " , sourceAdd: " + nodeQueryMsg.get_sourceAddr() + " , originAddr: "+ nodeQueryMsg.get_originAddr()
                        + " , hopCounts: " + nodeQueryMsg.get_hopCounts() + " , sequenceNo: " + nodeQueryMsg.get_sequenceNo()
                        + " , msgType: " + nodeQueryMsg.get_msgType() + " , queryType: " + nodeQueryMsg.get_queryType();
     
                System.out.println(dataString);
     
                try{
                    fManager.writeString2File(NODEQUERY_FILENAME_RECEIVE, dataString, true);
                }
     
                catch(IOException ioe){
                    System.err.println("Failed to write received data into DiaperEventMsgReceive file");
                }

    so whenever I send data, I print out correctly and write it into a file.
    however, when I try to receive it using the get methods, all the values are zero.
    Last edited by Json; June 22nd, 2010 at 01:12 AM. Reason: Please use code tags.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Able to set, but not get values

    nodeQueryMsg.set_...
    nodeQueryMsg.get_...
    Where is the code for the class that nodeQueryMsg refers to?
    How does it save the values that are set?
    What is the life span of that object? Is a new one created before the calls to the get methods?

  5. #5
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    Its basically just a get and set method:
     
    }
     
        /**
         * Return the value (as a short) of the field 'srcMoteId'
         */
        public short get_srcMoteId() {
            return (short)getUIntElement(offsetBits_srcMoteId(), 8);
        }
     
        /**
         * Set the value of the field 'srcMoteId'
         */
        public void set_srcMoteId(short value) {
            setUIntElement(offsetBits_srcMoteId(), 8, value);
        }

    is it because of this that I am unable to get the get once they are set?
    should i create arrays to store the data??

    Regards

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Able to set, but not get values

    setUIntElement(offsetBits_srcMoteId(), 8, value);
    Where is the code for this?
    His is related to: getUIntElement(

  7. #7
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    That's for the use of a hardware device.
    But the main question is, is there any way, by using get and set methods, after sending the values using the set methods, I am able to receive values that I set using the get methods?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Able to set, but not get values

    is there any way, by using get and set methods, after sending the values using the set methods, I am able to receive values that I set using the get methods
    Yes. In the object that has the set and get methods, the set method saves the value in a variable.
    The get method returns what's in that variable.
    Change your class to have variables for all the set and get methods to use.

  9. #9
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    Quote Originally Posted by Norm View Post
    Yes. In the object that has the set and get methods, the set method saves the value in a variable.
    The get method returns what's in that variable.
    Change your class to have variables for all the set and get methods to use.
    Could I ask, if writing into a file, will it clear the values being set in the variables?

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Able to set, but not get values

    if writing into a file, will it clear the values being set in the variables
    Are you a programmer? Funny question. I assume that the variables are program variables and not the contents of a file or DB.
    Writing into a file does not change any of a class's variables.
    The clearing of variables has to be done by the program itself.

  11. #11
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    Quote Originally Posted by Norm View Post
    Are you a programmer? Funny question. I assume that the variables are program variables and not the contents of a file or DB.
    Writing into a file does not change any of a class's variables.
    The clearing of variables has to be done by the program itself.
    yea I am, but not a strong one. I was just wondering though.
    I will see what I can change to get the values via the get methods.

    Thanks.

    Regards

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Able to set, but not get values

    what I can change
    1) define a variable to save the value in the class object
    2) in set() save the value
    3) in get() return the value

  13. #13
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    Hey Norm!

    Thanks a lot for your suggestion!
    Now that I am able to receive what I sent, I have a problem displaying it onto my main GUI
    to show what I have received.

    In my GUI class, I have this method:
        public void setJTextAreaData(String str){
            message = str + "\n";
            jTextArea1.append(message);
            jTextArea1.setCaretPosition(jTextArea1.getDocument().getLength());
        }

    and when I receive the values of the messages I sent, I did this:
    public void receivingMsg(){
            mf = new icmsv3MainFrame();
     
            ackDataString = new String();
            ctrlDataString = new String();
            queryDataString = new String();
     
            ackDataString = "(Receiving) ";
            ctrlDataString = "(Receiving) ";
            queryDataString = "(Receiving) ";
     
            if(smtw.getCommand().equalsIgnoreCase(ACKREPLY_CMD)){
                ackDataString += smtw.getCommand() + "\nsrcMoteID: " +  smtw.getAckSrcMoteId()
                        + " , moteGroup: " + smtw.getAckMoteGroup()
                        + " , sourceAddr: " + smtw.getAckSourceAddr() + " , originAddr: " + smtw.getAckOriginAddr()
                        + " , hopCounts: " + smtw.getAckHopCounts() + " , sequenceNo: " + smtw.getAckSeqNo()
                        + " , msgType: " + smtw.getAckMsgType() + " , ackType: " + smtw.getAckType();
     
                System.out.println(ackDataString);
                setReceivedData(ackDataString);
     
                try{
                    fManager.writeString2File(ACKREPLY_FILENAME_RECEIVE, ackDataString, true);
                    //icmsv3MainFrame imf = new icmsv3MainFrame();
     
                }
     
                catch(IOException ioe){
                    System.err.println("Failed to write received data into DiaperEventMsgReceive file");
                }
     
                ackMessageRxCount++;
                System.out.println("Ack Message Count: " + getAckMsgRxCount());
                mf.setJTextAreaData(getReceivedData());
            }

    I am not sure why but it either returns nothing or a null value.

    Regards

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Able to set, but not get values

    it either returns nothing or a null value
    What is the "it"? The method you posted is void.

  15. #15
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    The method receivingMsg() is in another class file.

    Basically, what I'm trying to do is receive the data via the receivingMsg method and store the variable
    'ackDataString' into the set method. After setting the values via the set method, I place it into my
    icmsv3MainFram class method called setJTextAreaData(String str).

    the setJTextAreaData would then contain the values I received and display on the jTextArea.

    The "it" refers to the method of mf.setJTextAreaData().

    I does not contain the values that I stored, which is the String data of ackDataString.

    Regards

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Able to set, but not get values

    Its hard to imagine what you are doing without seeing the code.

    Can you show the code for the "it" that either returns nothing or a null value

    What is a "nothing"?

  17. #17
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    Ok this is my GUI file:
     
    public class icmsv3MainFrame extends javax.swing.JFrame implements ConstantsIfc{
     
        /** Creates new form icmsv3MainFrame */
     
        public static final Color red = new Color(242, 49, 38);
        public static final Color lightGray = new Color(200, 200, 200);
        String command = "", message = "", data = "";
        short eventMsg = 0, ack = 0, ctrl = 0, query = 0;
        int node = 0;
     
        SendMsgToWsn smtw = new SendMsgToWsn();
        ButtonGroup nodeselectGroup = new ButtonGroup();
        ReceiveMsgFromWsn rmfw = new ReceiveMsgFromWsn();
     
        public icmsv3MainFrame(){
     
            initComponents();
     
            setTitle("icmsv3MainFrame");
     
            nodeselectGroup.add(jRadioButton12);
            nodeselectGroup.add(jRadioButton13);
            nodeselectGroup.add(jRadioButton14);
            nodeselectGroup.add(jRadioButton15);
            nodeselectGroup.add(jRadioButton16);
            nodeselectGroup.add(jRadioButton17);
            nodeselectGroup.add(jRadioButton18);
     
            jButton2.setBackground(lightGray);
            jButton3.setBackground(lightGray);
            jButton4.setBackground(lightGray);
            jButton5.setBackground(lightGray);
            jButton6.setBackground(lightGray);
            jButton7.setBackground(lightGray);
            jButton8.setBackground(lightGray);
            jButton9.setBackground(lightGray);
            jButton10.setBackground(lightGray);
            jButton11.setBackground(lightGray);
            jButton12.setBackground(lightGray);
     
            jButton2.setEnabled(false);
            jButton3.setEnabled(false);
            jButton4.setEnabled(false);
            jButton5.setEnabled(false);
            jButton6.setEnabled(false);
            jButton7.setEnabled(false);
            jButton8.setEnabled(false);
            jButton9.setEnabled(false);
            jButton10.setEnabled(false);
            jButton11.setEnabled(false);
            jButton12.setEnabled(false);
        }
     
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
     
            jPanel1 = new javax.swing.JPanel();
            jPanel2 = new javax.swing.JPanel();
            jPanel7 = new javax.swing.JPanel();
            jPanel8 = new javax.swing.JPanel();
            jComboBox1 = new javax.swing.JComboBox();
            jPanel9 = new javax.swing.JPanel();
            jButton1 = new javax.swing.JButton();
            jPanel10 = new javax.swing.JPanel();
            jRadioButton12 = new javax.swing.JRadioButton();
            jRadioButton13 = new javax.swing.JRadioButton();
            jRadioButton14 = new javax.swing.JRadioButton();
            jRadioButton15 = new javax.swing.JRadioButton();
            jRadioButton16 = new javax.swing.JRadioButton();
            jRadioButton17 = new javax.swing.JRadioButton();
            jRadioButton18 = new javax.swing.JRadioButton();
            jPanel12 = new javax.swing.JPanel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            jPanel3 = new javax.swing.JPanel();
            jPanel4 = new javax.swing.JPanel();
            jButton2 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jButton4 = new javax.swing.JButton();
            jPanel5 = new javax.swing.JPanel();
            jButton5 = new javax.swing.JButton();
            jButton6 = new javax.swing.JButton();
            jButton7 = new javax.swing.JButton();
            jPanel6 = new javax.swing.JPanel();
            jButton8 = new javax.swing.JButton();
            jButton9 = new javax.swing.JButton();
            jButton10 = new javax.swing.JButton();
            jButton11 = new javax.swing.JButton();
            jButton12 = new javax.swing.JButton();
            jPanel11 = new javax.swing.JPanel();
            jPanel13 = new javax.swing.JPanel();
            jPanel16 = new javax.swing.JPanel();
            jLabel1 = new javax.swing.JLabel();
            jTextField1 = new javax.swing.JTextField();
            jPanel17 = new javax.swing.JPanel();
            jLabel4 = new javax.swing.JLabel();
            jTextField4 = new javax.swing.JTextField();
            jPanel18 = new javax.swing.JPanel();
            jLabel7 = new javax.swing.JLabel();
            jTextField7 = new javax.swing.JTextField();
            jLabel8 = new javax.swing.JLabel();
            jPanel14 = new javax.swing.JPanel();
            jPanel19 = new javax.swing.JPanel();
            jLabel2 = new javax.swing.JLabel();
            jTextField2 = new javax.swing.JTextField();
            jPanel20 = new javax.swing.JPanel();
            jLabel5 = new javax.swing.JLabel();
            jTextField5 = new javax.swing.JTextField();
            jPanel21 = new javax.swing.JPanel();
            jLabel9 = new javax.swing.JLabel();
            jTextField8 = new javax.swing.JTextField();
            jLabel10 = new javax.swing.JLabel();
            jPanel15 = new javax.swing.JPanel();
            jPanel22 = new javax.swing.JPanel();
            jLabel3 = new javax.swing.JLabel();
            jTextField3 = new javax.swing.JTextField();
            jPanel23 = new javax.swing.JPanel();
            jLabel6 = new javax.swing.JLabel();
            jTextField6 = new javax.swing.JTextField();
            jPanel24 = new javax.swing.JPanel();
            jLabel11 = new javax.swing.JLabel();
            jTextField9 = new javax.swing.JTextField();
            jLabel12 = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            jPanel1.setLayout(new java.awt.GridLayout(2, 2));
     
            jPanel2.setLayout(new java.awt.GridLayout(1, 2));
     
            jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Select Event Msg"));
            jPanel7.setLayout(new java.awt.GridLayout(2, 2));
     
            jPanel8.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 20));
     
            jComboBox1.setMaximumRowCount(20);
            jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "---- Select Event Msg ----", "ACKREPLY", "NODECTRL", "NODEQUERY" }));
            jComboBox1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox1ActionPerformed(evt);
                }
            });
            jPanel8.add(jComboBox1);
     
            jPanel7.add(jPanel8);
     
            jButton1.setText("Send Msg");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
            jPanel9.add(jButton1);
     
            jPanel7.add(jPanel9);
     
            jPanel2.add(jPanel7);
     
            jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder("Select Node"));
            jPanel10.setLayout(new java.awt.GridLayout(7, 1));
     
            jRadioButton12.setText("1");
            jPanel10.add(jRadioButton12);
     
            jRadioButton13.setText("3");
            jPanel10.add(jRadioButton13);
     
            jRadioButton14.setText("5");
            jPanel10.add(jRadioButton14);
     
            jRadioButton15.setText("102");
            jPanel10.add(jRadioButton15);
     
            jRadioButton16.setText("104");
            jPanel10.add(jRadioButton16);
     
            jRadioButton17.setText("106");
            jPanel10.add(jRadioButton17);
     
            jRadioButton18.setText("255");
            jPanel10.add(jRadioButton18);
     
            jPanel2.add(jPanel10);
     
            jPanel1.add(jPanel2);
     
            jPanel12.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            jPanel12.setLayout(new java.awt.BorderLayout());
     
            jTextArea1.setColumns(20);
            jTextArea1.setEditable(false);
            jTextArea1.setRows(5);
            jTextArea1.setBorder(javax.swing.BorderFactory.createTitledBorder("Received Data"));
            jScrollPane1.setViewportView(jTextArea1);
     
            jPanel12.add(jScrollPane1, java.awt.BorderLayout.CENTER);
     
            jPanel1.add(jPanel12);
     
            jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Operation"));
            jPanel3.setLayout(new java.awt.GridLayout(1, 3));
     
            jPanel4.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            jPanel4.setLayout(new java.awt.GridLayout(3, 1));
     
            jButton2.setText("Diaper Event");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
                }
            });
            jPanel4.add(jButton2);
     
            jButton3.setText("Attention Event");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
                }
            });
            jPanel4.add(jButton3);
     
            jButton4.setText("Carer Event");
            jButton4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton4ActionPerformed(evt);
                }
            });
            jPanel4.add(jButton4);
     
            jPanel3.add(jPanel4);
     
            jPanel5.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            jPanel5.setLayout(new java.awt.GridLayout(3, 1));
     
            jButton5.setText("On");
            jButton5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton5ActionPerformed(evt);
                }
            });
            jPanel5.add(jButton5);
     
            jButton6.setText("Off");
            jButton6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton6ActionPerformed(evt);
                }
            });
            jPanel5.add(jButton6);
     
            jButton7.setText("Reset");
            jButton7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton7ActionPerformed(evt);
                }
            });
            jPanel5.add(jButton7);
     
            jPanel3.add(jPanel5);
     
            jPanel6.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            jPanel6.setLayout(new java.awt.GridLayout(5, 1));
     
            jButton8.setText("Wetness");
            jButton8.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton8ActionPerformed(evt);
                }
            });
            jPanel6.add(jButton8);
     
            jButton9.setText("Switch");
            jButton9.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton9ActionPerformed(evt);
                }
            });
            jPanel6.add(jButton9);
     
            jButton10.setText("Occupancy");
            jButton10.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton10ActionPerformed(evt);
                }
            });
            jPanel6.add(jButton10);
     
            jButton11.setText("Alert");
            jButton11.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton11ActionPerformed(evt);
                }
            });
            jPanel6.add(jButton11);
     
            jButton12.setText("Nothing");
            jButton12.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton12ActionPerformed(evt);
                }
            });
            jPanel6.add(jButton12);
     
            jPanel3.add(jPanel6);
     
            jPanel1.add(jPanel3);
     
            jPanel11.setLayout(new java.awt.GridLayout(3, 1));
     
            jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder("Ack Reply"));
            jPanel13.setLayout(new java.awt.GridLayout(1, 3));
     
            jLabel1.setText("msgRx:");
            jPanel16.add(jLabel1);
     
            jTextField1.setText("jTextField1");
            jPanel16.add(jTextField1);
     
            jPanel13.add(jPanel16);
     
            jLabel4.setText("seqNo.:");
            jPanel17.add(jLabel4);
     
            jTextField4.setText("jTextField4");
            jPanel17.add(jTextField4);
     
            jPanel13.add(jPanel17);
     
            jLabel7.setText("rxRate:");
            jPanel18.add(jLabel7);
     
            jTextField7.setText("jTextField7");
            jPanel18.add(jTextField7);
     
            jLabel8.setText("%");
            jPanel18.add(jLabel8);
     
            jPanel13.add(jPanel18);
     
            jPanel11.add(jPanel13);
     
            jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder("Node Ctrl"));
            jPanel14.setLayout(new java.awt.GridLayout(1, 3));
     
            jLabel2.setText("msgRx:");
            jPanel19.add(jLabel2);
     
            jTextField2.setText("jTextField2");
            jPanel19.add(jTextField2);
     
            jPanel14.add(jPanel19);
     
            jLabel5.setText("seqNo.:");
            jPanel20.add(jLabel5);
     
            jTextField5.setText("jTextField5");
            jPanel20.add(jTextField5);
     
            jPanel14.add(jPanel20);
     
            jLabel9.setText("rxRate");
            jPanel21.add(jLabel9);
     
            jTextField8.setText("jTextField8");
            jPanel21.add(jTextField8);
     
            jLabel10.setText("%");
            jPanel21.add(jLabel10);
     
            jPanel14.add(jPanel21);
     
            jPanel11.add(jPanel14);
     
            jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder("Node Query"));
            jPanel15.setLayout(new java.awt.GridLayout(1, 3));
     
            jLabel3.setText("msgRx:");
            jPanel22.add(jLabel3);
     
            jTextField3.setText("jTextField3");
            jPanel22.add(jTextField3);
     
            jPanel15.add(jPanel22);
     
            jLabel6.setText("seqNo.:");
            jPanel23.add(jLabel6);
     
            jTextField6.setText("jTextField6");
            jPanel23.add(jTextField6);
     
            jPanel15.add(jPanel23);
     
            jLabel11.setText("rxRate");
            jPanel24.add(jLabel11);
     
            jTextField9.setText("jTextField9");
            jPanel24.add(jTextField9);
     
            jLabel12.setText("%");
            jPanel24.add(jLabel12);
     
            jPanel15.add(jPanel24);
     
            jPanel11.add(jPanel15);
     
            jPanel1.add(jPanel11);
     
            getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
     
            pack();
        }// </editor-fold>                        
     
        private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            if(jComboBox1.getSelectedIndex()==0){
                JOptionPane.showMessageDialog(null, "Select an event msg!");
     
                ack = 0;
                ctrl = 0;
                query = 0;
     
                jButton2.setBackground(lightGray);
                jButton2.repaint();
                jButton3.setBackground(lightGray);
                jButton3.repaint();
                jButton4.setBackground(lightGray);
                jButton4.repaint();
                jButton5.setBackground(lightGray);
                jButton5.repaint();
                jButton6.setBackground(lightGray);
                jButton6.repaint();
                jButton7.setBackground(lightGray);
                jButton7.repaint();
                jButton8.setBackground(lightGray);
                jButton8.repaint();
                jButton9.setBackground(lightGray);
                jButton9.repaint();
                jButton10.setBackground(lightGray);
                jButton10.repaint();
                jButton1.setBackground(lightGray);
                jButton11.repaint();
                jButton12.setBackground(lightGray);
                jButton12.repaint();
     
                jButton2.setEnabled(false);
                jButton3.setEnabled(false);
                jButton4.setEnabled(false);
                jButton5.setEnabled(false);
                jButton6.setEnabled(false);
                jButton7.setEnabled(false);
                jButton8.setEnabled(false);
                jButton9.setEnabled(false);
                jButton10.setEnabled(false);
                jButton11.setEnabled(false);
                jButton12.setEnabled(false);
            }
     
            else if(jComboBox1.getSelectedIndex()==1){
     
                ctrl = 0;
                query = 0;
     
                jButton5.setBackground(lightGray);
                jButton5.repaint();
                jButton6.setBackground(lightGray);
                jButton6.repaint();
                jButton7.setBackground(lightGray);
                jButton7.repaint();
                jButton8.setBackground(lightGray);
                jButton8.repaint();
                jButton9.setBackground(lightGray);
                jButton9.repaint();
                jButton10.setBackground(lightGray);
                jButton10.repaint();
                jButton11.setBackground(lightGray);
                jButton11.repaint();
                jButton12.setBackground(lightGray);
                jButton12.repaint();
     
                jButton2.setEnabled(true);
                jButton3.setEnabled(true);
                jButton4.setEnabled(true);
                jButton5.setEnabled(false);
                jButton6.setEnabled(false);
                jButton7.setEnabled(false);
                jButton8.setEnabled(false);
                jButton9.setEnabled(false);
                jButton10.setEnabled(false);
                jButton11.setEnabled(false);
                jButton12.setEnabled(false);
            }
     
            else if(jComboBox1.getSelectedIndex()==2){
     
                ack = 0;
                query = 0;
     
                jButton2.setBackground(lightGray);
                jButton2.repaint();
                jButton3.setBackground(lightGray);
                jButton3.repaint();
                jButton4.setBackground(lightGray);
                jButton4.repaint();
                jButton8.setBackground(lightGray);
                jButton8.repaint();
                jButton9.setBackground(lightGray);
                jButton9.repaint();
                jButton10.setBackground(lightGray);
                jButton10.repaint();
                jButton11.setBackground(lightGray);
                jButton11.repaint();
                jButton12.setBackground(lightGray);
                jButton12.repaint();
     
                jButton2.setEnabled(false);
                jButton3.setEnabled(false);
                jButton4.setEnabled(false);
                jButton5.setEnabled(true);
                jButton6.setEnabled(true);
                jButton7.setEnabled(true);
                jButton8.setEnabled(false);
                jButton9.setEnabled(false);
                jButton10.setEnabled(false);
                jButton11.setEnabled(false);
                jButton12.setEnabled(false);
            }
     
            else if(jComboBox1.getSelectedIndex()==3){
     
                ack = 0;
                ctrl = 0;
     
                jButton2.setBackground(lightGray);
                jButton2.repaint();
                jButton3.setBackground(lightGray);
                jButton3.repaint();
                jButton4.setBackground(lightGray);
                jButton4.repaint();
                jButton5.setBackground(lightGray);
                jButton5.repaint();
                jButton6.setBackground(lightGray);
                jButton6.repaint();
                jButton7.setBackground(lightGray);
                jButton8.repaint();
     
                jButton2.setEnabled(false);
                jButton3.setEnabled(false);
                jButton4.setEnabled(false);
                jButton5.setEnabled(false);
                jButton6.setEnabled(false);
                jButton7.setEnabled(false);
                jButton8.setEnabled(true);
                jButton9.setEnabled(true);
                jButton10.setEnabled(true);
                jButton11.setEnabled(true);
                jButton12.setEnabled(true);
            }
     
        }                                          
     
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            if(jComboBox1.getSelectedIndex()==0)
            {
                JOptionPane.showMessageDialog(null, "Select an event msg!");
            }
     
            if(jComboBox1.getSelectedIndex()==1)
            {
                command = "ACKREPLY";
                eventMsg = ACKREPLY;
            }
     
            if(jComboBox1.getSelectedIndex()==2)
            {
                command = "NODECTRL";
                eventMsg = NODECTRL;
            }
     
            if(jComboBox1.getSelectedIndex()==3)
            {
                command = "NODEQUERY";
                eventMsg = NODEQUERY;
            }
     
            if(jRadioButton12.isSelected()){
                node = FIXED_NODE_1;
            }
     
            if(jRadioButton13.isSelected()){
                node = FIXED_NODE_2;
            }
     
            if(jRadioButton14.isSelected()){
                node = FIXED_NODE_3;
            }
     
            if(jRadioButton15.isSelected()){
                node = RELAY_NODE_1;
     
            }
     
            if(jRadioButton16.isSelected()){
                node = RELAY_NODE_2;
            }
     
            if(jRadioButton17.isSelected()){
                node = RELAY_NODE_3;
            }
     
            if(jRadioButton18.isSelected()){
                node = DEFAULT_NODE;
            }
     
            smtw.sendMsg();
     
        }                                        
     
        private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            ack = ACKREPLY_ATTENTIONEVENT;
            jButton2.setBackground(lightGray);
            jButton3.setBackground(red);
            jButton4.setBackground(lightGray);
        }                                        
     
        private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            ack = ACKREPLY_CAREREVENT;
            jButton2.setBackground(lightGray);
            jButton3.setBackground(lightGray);
            jButton4.setBackground(red);
        }                                        
     
        private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            ctrl = NODECTRL_IS_ON;
            jButton5.setBackground(red);
            jButton6.setBackground(lightGray);
            jButton7.setBackground(lightGray);        
        }                                        
     
        private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            ctrl = NODECTRL_IS_OFF;
            jButton5.setBackground(lightGray);
            jButton6.setBackground(red);
            jButton7.setBackground(lightGray);
        }                                        
     
        private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            ctrl = NODECTRL_IS_RESET;
            jButton5.setBackground(lightGray);
            jButton6.setBackground(lightGray);
            jButton7.setBackground(red);
        }                                        
     
        private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            query = NODEQUERY_Q_WETNESS;
            jButton8.setBackground(red);
            jButton9.setBackground(lightGray);
            jButton10.setBackground(lightGray);
            jButton11.setBackground(lightGray);
            jButton12.setBackground(lightGray);
        }                                        
     
        private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            query = NODEQUERY_Q_SWITCH;
            jButton8.setBackground(lightGray);
            jButton9.setBackground(red);
            jButton10.setBackground(lightGray);
            jButton11.setBackground(lightGray);
            jButton12.setBackground(lightGray);
        }                                        
     
        private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            query = NODEQUERY_Q_OCCUPANCY;
            jButton8.setBackground(lightGray);
            jButton9.setBackground(lightGray);
            jButton10.setBackground(red);
            jButton11.setBackground(lightGray);
            jButton12.setBackground(lightGray);
     
        }                                         
     
        private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            query = NODEQUERY_Q_ALERT;
            jButton8.setBackground(lightGray);
            jButton9.setBackground(lightGray);
            jButton10.setBackground(lightGray);
            jButton11.setBackground(red);
            jButton12.setBackground(lightGray);
        }                                         
     
        private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            query = NODEQUERY_Q_NOTHING;
            jButton8.setBackground(lightGray);
            jButton9.setBackground(lightGray);
            jButton10.setBackground(lightGray);
            jButton11.setBackground(lightGray);
            jButton12.setBackground(red);
        }                                         
     
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            ack = ACKREPLY_DIAPEREVENT;
            jButton2.setBackground(red);
            jButton3.setBackground(lightGray);
            jButton4.setBackground(lightGray);
        }                                        
     
        public void setJTextAreaData(String str){
            message = str + "\n";
            jTextArea1.append(message);
            jTextArea1.setCaretPosition(jTextArea1.getDocument().getLength());
        }
     
        public void setAckMsgRx(int rx){
     
        }
     
        public String getCommand(){
            return command;
        }
     
        public int getNode(){
            return node;
        }
     
        public short getMsgType(){
            return eventMsg;
        }
     
        public short getAck(){
            return ack;
        }
     
        public short getQuery(){
            return query;
        }
     
        public short getCtrl(){
            return ctrl;
        }

    This is the code where I send values using the set methods:
    public class SendMsgToWsn implements MessageListener, ConstantsIfc{
     
    	Date daqTimestamp;
    	MoteIF mote;
    	FilesManager fManager = new FilesManager();
    	BufferedWriter wadOutput;
    	AckReplyMsg ackReplyMsg;
    	NodeCtrlMsg nodeCtrlMsg;
    	NodeQueryMsg nodeQueryMsg;
            ReceiveMsgFromWsn rmfw;
    	long ackSeqNum;
    	long ctrlSeqNum;
    	long querySeqNum;
            String dataString;
            static icmsv3MainFrame mf = new icmsv3MainFrame();
            boolean doneSending = false;
            static short ackSrcMoteId, ackMoteGroup, ackHopCounts, ackType, ackMsgType;
            static short nodeCSrcMoteId, nodeCMoteGroup, nodeCHopCounts, nodeCType, nodeCMsgType;
            static short nodeQSrcMoteId, nodeQMoteGroup, nodeQHopCounts, nodeQType, nodeQMsgType;
            static long ackSeqNo, nodeCSeqNo, nodeQSeqNo;
            static int ackSourceAddr, ackOriginAddr, nodeCSourceAddr, nodeCOriginAddr, nodeQSourceAddr, nodeQOriginAddr;
     
    	public SendMsgToWsn(){
    		ackReplyMsg = new AckReplyMsg();
    		nodeCtrlMsg = new NodeCtrlMsg();
    		nodeQueryMsg = new NodeQueryMsg();
    		mote = new MoteIF(PrintStreamMessenger.err, -1);
     
                    try{
                        fManager.createWritableFile(ACKREPLY_FILENAME_SEND);
                        fManager.createWritableFile(NODECTRL_FILENAME_SEND);
                        fManager.createWritableFile(NODEQUERY_FILENAME_SEND);
     
                        fManager.createWritableFile(ACKREPLY_FILENAME_RECEIVE);
                        fManager.createWritableFile(NODECTRL_FILENAME_RECEIVE);
                        fManager.createWritableFile(NODEQUERY_FILENAME_RECEIVE);
                    }
     
                    catch(IOException ioe){
                        System.err.println("Unable to create files on startup. Error: " + ioe);
                    }   
    	}
     
            public void messageReceived(int dest_addr,Message msg){
    		if(msg.amType() == AM_DIAPEREVENTMSG){ //read switch readings
    			DiaperEventReceived(dest_addr, (DiaperEventMsg)msg);
                    }
     
                    else if(msg.amType() == AM_ATTENTIONEVENTMSG){
    			AttentionEventReceived(dest_addr, (AttentionEventMsg)msg);
                    }
     
                    else if(msg.amType() == AM_CAREREVENTMSG){
    			CarerEventReceived(dest_addr, (CarerEventMsg)msg);
                    }	
    	}	
     
    ...
     
    	public void sendMsg(){
    		String cmd = mf.getCommand();
    		int node = mf.getNode();
                    short msg = mf.getMsgType();
                    short ack = mf.getAck();
                    short query = mf.getQuery();
                    short ctrl = mf.getCtrl();
    		dataString = new String();
                    dataString = "(Sending) ";
     
    		if(cmd.equalsIgnoreCase(ACKREPLY_CMD)){
    			ackReplyMsg.set_srcMoteId(TOS_GATEWAY_ADDR);
                            ackSrcMoteId = ackReplyMsg.get_srcMoteId();
    			ackReplyMsg.set_moteGroup(CMWAD_MOTEGROUP);
                            ackMoteGroup = ackReplyMsg.get_moteGroup();
    			ackReplyMsg.set_sourceAddr(TOS_GATEWAY_ADDR);
                            ackSourceAddr = ackReplyMsg.get_sourceAddr();
    			ackReplyMsg.set_originAddr(node);//receive input from user (Node)
                            ackOriginAddr = ackReplyMsg.get_originAddr();
    			ackReplyMsg.set_hopCounts((short)0);
                            ackHopCounts = ackReplyMsg.get_hopCounts();
    			ackReplyMsg.set_sequenceNo(ackSeqNum++);
                            ackSeqNo = ackReplyMsg.get_sequenceNo();
    			ackReplyMsg.set_msgType(msg); //receive input from user (Command)
                            ackMsgType = ackReplyMsg.get_msgType();
    			ackReplyMsg.set_ackType(ack); //receive input from user (Argument)
                            ackType = ackReplyMsg.get_ackType();
     
                    dataString += cmd + "\nsrcMoteId: " + TOS_GATEWAY_ADDR + " , moteGroup: " + CMWAD_MOTEGROUP
                            + " , sourceAddr: " + TOS_GATEWAY_ADDR + " , originAddr: " + node + " , hopCounts: " + (short)0
                            + " , sequenceNo: " + ackSeqNum + " , msgType: " + msg + " , ackType: " + ack;
     
                    try{
                        System.out.println(dataString);
                        fManager.writeString2File(ACKREPLY_FILENAME_SEND, dataString, true);
                        doneSending = true;
     
                        rmfw = new ReceiveMsgFromWsn();
                        rmfw.receivingMsg();
                    }
     
                    catch(IOException ioe){
                        System.err.println("Unable to write data into file at DiaperEventReceived");
                    }
     
                            try{
                                mote.send(node, ackReplyMsg);
    			}
     
                            catch (IOException e) {
    			}
    		}
     
                    else if(cmd.equalsIgnoreCase(NODECTRL_CMD)){
    			nodeCtrlMsg.set_srcMoteId(TOS_GATEWAY_ADDR);
                            nodeCSrcMoteId = nodeCtrlMsg.get_srcMoteId();
    			nodeCtrlMsg.set_moteGroup(CMWAD_MOTEGROUP);
                            nodeCMoteGroup = nodeCtrlMsg.get_moteGroup();
    			nodeCtrlMsg.set_sourceAddr(TOS_GATEWAY_ADDR);
                            nodeCSourceAddr = nodeCtrlMsg.get_sourceAddr();
    			nodeCtrlMsg.set_originAddr(node);//receive input from user (node)
                            nodeCOriginAddr = nodeCtrlMsg.get_originAddr();
    			nodeCtrlMsg.set_hopCounts((short)0);
                            nodeCHopCounts = nodeCtrlMsg.get_hopCounts();
    			nodeCtrlMsg.set_sequenceNo(ctrlSeqNum++);
                            nodeCSeqNo = nodeCtrlMsg.get_sequenceNo();
    			nodeCtrlMsg.set_msgType(msg); //receive input from user (command)
                            nodeCMsgType = nodeCtrlMsg.get_msgType();
    			nodeCtrlMsg.set_ctrlType(ctrl); //receive input from user (argument)
                            nodeCType = nodeCtrlMsg.get_ctrlType();
     
                    dataString += cmd + "\nsrcMoteId: " + TOS_GATEWAY_ADDR + " , moteGroup: " + CMWAD_MOTEGROUP
                            + " , sourceAddr: " + TOS_GATEWAY_ADDR + " , originAddr: " + node + " , hopCounts: " + (short)0
                            + " , sequenceNo: " + ctrlSeqNum + " , msgType: " + msg + " , ctrlType: " + ctrl;
     
                    try{
                        System.out.println(dataString);
                        fManager.writeString2File(NODECTRL_FILENAME_SEND, dataString, true);
                        doneSending = true;
     
                        rmfw = new ReceiveMsgFromWsn();
                        rmfw.receivingMsg();
                    }
     
                    catch(IOException ioe){
                        System.err.println("Unable to write data into file at AttentionEventReceived");
                    }
     
                            try{
                                mote.send(node, nodeCtrlMsg);
     
    			}
     
                            catch (IOException e) {
    			}
    		}
     
                    else if(cmd.equalsIgnoreCase(NODEQUERY_CMD)){
    			nodeQueryMsg.set_srcMoteId(TOS_GATEWAY_ADDR);
                            nodeQSrcMoteId = nodeQueryMsg.get_srcMoteId();
    			nodeQueryMsg.set_moteGroup(CMWAD_MOTEGROUP);
    			nodeQMoteGroup = nodeQueryMsg.get_moteGroup();
                            nodeQueryMsg.set_sourceAddr(TOS_GATEWAY_ADDR);
                            nodeQSourceAddr = nodeQueryMsg.get_sourceAddr();
    			nodeQueryMsg.set_originAddr(node);//receive input from user (node)
                            nodeQOriginAddr = nodeQueryMsg.get_originAddr();
    			nodeQueryMsg.set_hopCounts((short)0);
                            nodeQHopCounts = nodeQueryMsg.get_hopCounts();
    			nodeQueryMsg.set_sequenceNo(querySeqNum++);
                            nodeQSeqNo = nodeQueryMsg.get_sequenceNo();
    			nodeQueryMsg.set_msgType(msg); //recive input from user (command)
                            nodeQMsgType = nodeQueryMsg.get_msgType();
    			nodeQueryMsg.set_queryType(query); //receive input from user (argument)
                            nodeQType = nodeQueryMsg.get_queryType();
     
                    dataString += cmd + "\nsrcMoteId: " + TOS_GATEWAY_ADDR + " , moteGroup: " + CMWAD_MOTEGROUP
                            + " , sourceAddr: " + TOS_GATEWAY_ADDR + " , originAddr: " + node + " , hopCounts: " + (short)0
                            + " , sequenceNo: " + querySeqNum + " , msgType: " + msg + " , queryType: " + query;
     
                    try{
                        System.out.println(dataString);
                        fManager.writeString2File(NODEQUERY_FILENAME_SEND, dataString, true);
                        doneSending = true;
     
                        rmfw = new ReceiveMsgFromWsn();
                        rmfw.receivingMsg();
                    }
     
                    catch(IOException ioe){
                        System.err.println("Unable to write data into file at CarerEventReceived");
                    }
     
                            try{
                                mote.send(node, nodeQueryMsg);
     
    			}
     
                            catch (IOException e) {}
    		}
    	}
     
    	public static void main(String[] args){
    	    SendMsgToWsn apps = new SendMsgToWsn();
                mf.setVisible(true);
            }
     
            public String getCommand(){
                return mf.getCommand();
            }
     
    //------------------------------------------------------
     
            public short getAckSrcMoteId(){
                return ackSrcMoteId;
            }
     
            public short getAckMoteGroup(){
                return ackMoteGroup;
            }
     
            public int getAckSourceAddr(){
                return ackSourceAddr;
            }
     
            public int getAckOriginAddr(){
                return ackOriginAddr;
            }
     
            public short getAckHopCounts(){
                return ackHopCounts;
            }
     
            public long getAckSeqNo(){
                return ackSeqNo;
            }
     
            public short getAckType(){
                return ackType;
            }
     
            public short getAckMsgType(){
                return ackMsgType;
            }
     
    //------------------------------------------------------
     
            public short getNodeCSrcMoteId(){
                return nodeCSrcMoteId;
            }
     
            public short getNodeCMoteGroup(){
                return nodeCMoteGroup;
            }
     
            public int getNodeCSourceAddr(){
                return nodeCSourceAddr;
            }
         public int getNodeCOriginAddr(){
                return nodeCOriginAddr;
            }
     
            public short getNodeCHopCounts(){
                return nodeCHopCounts;
            }
     
            public long getNodeCSeqNo(){
                return nodeCSeqNo;
            }
     
            public short getNodeCType(){
                return nodeCType;
            }
     
            public short getNodeCMsgType(){
                return nodeCMsgType;
            }
     
    //------------------------------------------------------
     
            public short getNodeQSrcMoteId(){
                return nodeQSrcMoteId;
            }
     
            public short getNodeQMoteGroup(){
                return nodeQMoteGroup;
            }
     
            public int getNodeQSourceAddr(){
                return nodeQSourceAddr;
            }
     
            public int getNodeQOriginAddr(){
                return nodeQOriginAddr;
            }
     
            public short getNodeQHopCounts(){
                return nodeQHopCounts;
            }
     
            public long getNodeQSeqNo(){
                return nodeQSeqNo;
            }
     
            public short getNodeQType(){
                return nodeQType;
            }
     
            public short getNodeQMsgType(){
                return nodeQMsgType;
            }
     
    //------------------------------------------------------
     
            public boolean doneSending(){
                return doneSending;
            }     
    }

  18. #18
    Junior Member
    Join Date
    May 2010
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Able to set, but not get values

    This is the code where I receive what I sent:
    public class ReceiveMsgFromWsn implements ConstantsIfc{
     
        AckReplyMsg ackReplyMsg;
        NodeCtrlMsg nodeCtrlMsg;
        NodeQueryMsg nodeQueryMsg;
        FilesManager fManager;
        SendMsgToWsn smtw;
        boolean done = false;
        long ackSeqNo, nodeCtrlSeqNo, nodeQuerySeqNo;
        static short ackReplyMessageLost, nodeCtrlMessageLost, nodeQueryMessageLost;
        String ackDataString, ctrlDataString, queryDataString;
        String receivedData;
        String cmd = "";
        static int ackMessageRxCount, nodeCtrlMessageRxCount, nodeQueryMessageRxCount;
        icmsv3MainFrame mf;
     
        public ReceiveMsgFromWsn(){
            ackReplyMsg = new AckReplyMsg();
            nodeCtrlMsg = new NodeCtrlMsg();
    	nodeQueryMsg = new NodeQueryMsg();
            smtw = new SendMsgToWsn();
            fManager = new FilesManager();    
        }
     
        public void receivingMsg(){
            mf = new icmsv3MainFrame();
     
            ackDataString = new String();
            ctrlDataString = new String();
            queryDataString = new String();
     
            ackDataString = "(Receiving) ";
            ctrlDataString = "(Receiving) ";
            queryDataString = "(Receiving) ";
     
            if(smtw.getCommand().equalsIgnoreCase(ACKREPLY_CMD)){
                ackDataString += smtw.getCommand() + "\nsrcMoteID: " +  smtw.getAckSrcMoteId()
                        + " , moteGroup: " + smtw.getAckMoteGroup()
                        + " , sourceAddr: " + smtw.getAckSourceAddr() + " , originAddr: " + smtw.getAckOriginAddr()
                        + " , hopCounts: " + smtw.getAckHopCounts() + " , sequenceNo: " + smtw.getAckSeqNo()
                        + " , msgType: " + smtw.getAckMsgType() + " , ackType: " + smtw.getAckType();
     
                System.out.println(ackDataString);
                setReceivedData(ackDataString);
     
                try{
                    fManager.writeString2File(ACKREPLY_FILENAME_RECEIVE, ackDataString, true);
                    //icmsv3MainFrame imf = new icmsv3MainFrame();
     
                }
     
                catch(IOException ioe){
                    System.err.println("Failed to write received data into DiaperEventMsgReceive file");
                }
     
                ackMessageRxCount++;
                System.out.println("Ack Message Count: " + getAckMsgRxCount());
                mf.setJTextAreaData(getReceivedData());
            }
     
            else if(smtw.getCommand().equalsIgnoreCase(NODECTRL_CMD)){
                ctrlDataString += smtw.getCommand() + "\nsrcMoteID: " +  smtw.getNodeCSrcMoteId()
                        + " , moteGroup: " + smtw.getNodeCMoteGroup()
                        + " , sourceAddr: " + smtw.getNodeCSourceAddr() + " , originAddr: "+ smtw.getNodeCOriginAddr()
                        + " , hopCounts: " + smtw.getNodeCHopCounts() + " , sequenceNo: " + smtw.getNodeCSeqNo()
                        + " , msgType: " + smtw.getNodeCMsgType() + " , ctrlType: " + smtw.getNodeCType();
     
                System.out.println(ctrlDataString);
                setReceivedData(ctrlDataString);
     
                try{
                    fManager.writeString2File(NODECTRL_FILENAME_RECEIVE, ctrlDataString, true);
                }
     
                catch(IOException ioe){
                    System.err.println("Failed to write received data into DiaperEventMsgReceive file");
                }
     
                nodeCtrlMessageRxCount++;
                System.out.println("Node Ctrl Message Count: " + getNodeCtrlMsgRxCount());
                mf.setJTextAreaData(getReceivedData());
            }
     
            else if(smtw.getCommand().equalsIgnoreCase(NODEQUERY_CMD)){
                queryDataString += smtw.getCommand() + "\nsrcMoteID: " +  nodeQueryMsg.get_srcMoteId()
                        + " , moteGroup: " + smtw.getNodeQMoteGroup()
                        + " , sourceAddr: " + smtw.getNodeQSourceAddr() + " , originAddr: " + smtw.getNodeQOriginAddr()
                        + " , hopCounts: " + smtw.getNodeQHopCounts() + " , sequenceNo: " + smtw.getNodeQSeqNo()
                        + " , msgType: " + smtw.getNodeQMsgType() + " , queryType: " + smtw.getNodeQType();
     
                System.out.println(queryDataString);
                setReceivedData(queryDataString);
     
                try{
                    fManager.writeString2File(NODEQUERY_FILENAME_RECEIVE, queryDataString, true);
                }
     
                catch(IOException ioe){
                    System.err.println("Failed to write received data into DiaperEventMsgReceive file");
                }
     
                nodeQueryMessageRxCount++;
                System.out.println("Node Query Message Count: " + getNodeQueryMsgRxCount());
                mf.setJTextAreaData(getReceivedData());
            }
                smtw.doneSending = false;
        }
     
        private void calculateNodeCtrlMessageLost(){
           nodeCtrlMessageLost = (short) (smtw.getNodeCSeqNo() - nodeCtrlMessageRxCount);
        }
     
        public short getNodeCtrlMessageLost(){
            return nodeCtrlMessageLost;
        }
     
        public int getAckMsgRxCount(){
            return ackMessageRxCount;
        }
     
        public long getAckSeqNo(){
            return ackSeqNo;
        }
     
        public int getNodeCtrlMsgRxCount(){
            return nodeCtrlMessageRxCount;
        }
     
        public long getNodeCtrlSeqNo(){
            return nodeCtrlSeqNo;
        }
     
        public int getNodeQueryMsgRxCount(){
            return nodeQueryMessageRxCount;
        }
     
        public long getNodeQuerySeqNo(){
            return nodeQuerySeqNo;
        }
     
        public void setReceivedData(String str){
            receivedData = str;
        }
     
        public String getReceivedData(){
            return receivedData;
        }
    }

    The part "mf.setJTextAreaData(getReceivedData());" is where the problem lies.
    I cannot write the data onto the jTextArea but I can print it out.

    Nothing means that when i tried doing System.out.println("HERE " + getReceivedData());
    the output would be:
    HERE

    There's basically nothing.

    Regards

  19. #19
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Able to set, but not get values

    An empty String is still a String. I'd think that null could be closer to nothing.
    So the method is returning an empty String or null.
    You've posted a lot of code.

    Let me restate the problem:
    Some where you have a String value.
    You call a setxxxxx() method in a class that you want to save the value.
    Later you call a getxxxxx() method to retrieve the value that was saved earlier.
    Some how that value is GONE and the getxxxxx() method either returns an empty String or null

    Is that the problem?
    If so, look thru your code of class that is saving the value for ANY code that changes where the variable where the value is saved in is changed.
    Add a println() statement next to the statement that is changing the value that prints out what the new value is.

    Then when you execute the program you should see a println() output with either an Empty String or null.

Similar Threads

  1. how to compare two set values
    By humdinger in forum Collections and Generics
    Replies: 1
    Last Post: March 13th, 2010, 11:46 AM
  2. Get <SELECT> tag values on other jsp page
    By nehakuls in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: November 18th, 2009, 02:29 AM
  3. Eliminating duplicate values
    By Harry_ in forum Collections and Generics
    Replies: 7
    Last Post: November 9th, 2009, 06:35 AM
  4. Values of Input
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 8th, 2009, 03:46 AM
  5. Substitution of Values in Array
    By nyeung in forum Collections and Generics
    Replies: 2
    Last Post: October 26th, 2009, 08:02 PM