Пример #1
0
            private void ButtonOK_click(object source, EventArgs e)
            {
                object localValue = _value;

                _editor.ConvertToValue(_byteViewer.GetBytes(), ref localValue);
                _value = localValue;
            }
Пример #2
0
        private void btnWrite_Click(object sender, EventArgs e)
        {
            ConvertHextoBytes();
            //if (textBoxString.Text == "")
            if (byteviewer.GetBytes().Length < 1)
            {
                MessageBox.Show("File belum dibuka");
                return;
            }

            if (cmbPort.SelectedItem.ToString() == null)
            {
                MessageBox.Show("Port belum dipilih");
                return;
            }
            selectedPorts = cmbPort.SelectedItem.ToString();

            if (cmbIC.SelectedItem.ToString() == null)
            {
                MessageBox.Show("IC belum dipilih");
                return;
            }

            selectedIC = cmbIC.SelectedItem.ToString();
            portName   = txtAlamat.Text;
            int.TryParse(txtAlamat.Text, out portAddress);
            if (portAddress <= 0)
            {
                portAddress = 888;
            }
            Double.TryParse(txtSpeed.Text, out kecepatan);
            if (kecepatan <= 0)
            {
                kecepatan = 1;
            }
            int interval = (int)(1000 / kecepatan);

            if (interval <= 0)
            {
                interval = 1;
            }
            timer1.Interval = interval;


            if (cmbPort.SelectedItem.ToString() == Ports[0]) //Par
            {
                ReadWriteThread = new Thread(KirimParalel);
            }
            else if (cmbPort.SelectedItem.ToString() == Ports[1] || //Par-SPI
                     cmbPort.SelectedItem.ToString() == Ports[2]) //Ser-SPI
            {
                ReadWriteThread = new Thread(KirimSPI);
            }
            else if (cmbPort.SelectedItem.ToString() == Ports[3]) //Serial
            {
                ReadWriteThread = new Thread(KirimSerial);
            }
            button2.Enabled = false;
            progress        = 0; timer1.Enabled = true;
            ReadWriteThread.Start();
        }