Subversion Repositories group.electronics

Rev

Rev 153 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 153 Rev 155
Line 10... Line 10...
10
 
10
 
11
namespace NITNavComm {
11
namespace NITNavComm {
12
    public partial class NITCommNavForm : Form {
12
    public partial class NITCommNavForm : Form {
13
 
13
 
14
        private NITNavCommDevice navcomm = null;
14
        private NITNavCommDevice navcomm = null;
15
        //private IntPtr navcomm;
-
 
16
        
15
        
17
        public NITCommNavForm() {
16
        public NITCommNavForm() {
18
            InitializeComponent();
17
            InitializeComponent();
19
 
18
 
20
            this.controlStatus(false);
19
            this.controlStatus(false);
Line 97... Line 96...
97
 
96
 
98
        private void cmdSend0_Click(object sender, EventArgs e) {          
97
        private void cmdSend0_Click(object sender, EventArgs e) {          
99
            char[] data = txtSend0.Text.ToArray();
98
            char[] data = txtSend0.Text.ToArray();
100
            byte[] bytes = new byte[5];
99
            byte[] bytes = new byte[5];
101
            for (byte i = 0; i < 5; i++) {
100
            for (byte i = 0; i < 5; i++) {
-
 
101
                if (data.Length <= i)                           // Check if there was enough data to fill all chars
102
                if (data[i] == 'a' || data[i] == ' ')
102
                    bytes[i] = (byte)0x0a;
-
 
103
                else if (data[i] == 'a' || data[i] == ' ')      // Is its an 'a' or space, send a blank digit (0x0a)
103
                    bytes[i] = (byte)0x0a;
104
                    bytes[i] = (byte)0x0a;
104
                else
105
                else
105
                    bytes[i] = (byte)(data[i] - '0');
106
                    bytes[i] = (byte)(data[i] - '0');           // Other wise, send the non-ascii digit (char - '0')
106
            }
107
            }
107
            navcomm.setFreq(1, ref bytes);
108
            navcomm.setFreq(1, ref bytes);                      // Send all the bytes to the display board
108
            this.UpdateDisplay(0);
109
            this.UpdateDisplay(0);
109
        }
110
        }
110
 
111
 
111
        private void cmdSend1_Click(object sender, EventArgs e) {
112
        private void cmdSend1_Click(object sender, EventArgs e) {
112
            char[] data = txtSend1.Text.ToArray();
113
            char[] data = txtSend1.Text.ToArray();
113
            byte[] bytes = new byte[5];
114
            byte[] bytes = new byte[5];
114
            for (byte i = 0; i < 5; i++) {
115
            for (byte i = 0; i < 5; i++) {
-
 
116
                if (data.Length <= i)
-
 
117
                    bytes[i] = (byte)0x0a;
115
                if (data[i] == 'a' || data[i] == ' ')
118
                else if (data[i] == 'a' || data[i] == ' ')
116
                    bytes[i] = (byte)0x0a;
119
                    bytes[i] = (byte)0x0a;
117
                else
120
                else
118
                    bytes[i] = (byte)(data[i] - '0');
121
                    bytes[i] = (byte)(data[i] - '0');
119
            }
122
            }
120
            navcomm.setFreq(3, ref bytes);
123
            navcomm.setFreq(3, ref bytes);
121
            this.UpdateDisplay(1);
124
            this.UpdateDisplay(1);
122
        }
125
        }
123
 
126
 
124
        private void cmdClose_Click(object sender, EventArgs e) {
127
        private void cmdClose_Click(object sender, EventArgs e) {
125
            if (this.navcomm != null && this.navcomm.isOpen())
-
 
126
                navcomm.Close();
-
 
127
            this.Close();
128
            this.Close();
128
        }
129
        }
129
 
130
 
130
        private void cmdUpdate_Click(object sender, EventArgs e) {
131
        private void cmdUpdate_Click(object sender, EventArgs e) {
131
            this.UpdateDevice();
132
            this.UpdateDevice();