Ejemplo n.º 1
0
        public void BuildReadBoolTest( )
        {
            OperateResult <byte[]> read = FatekProgram.BuildReadCommand(1, "X50", 6, true);

            Assert.IsTrue(read.IsSuccess);

            Assert.IsTrue(SoftBasic.IsTwoBytesEquel(read.Content, new byte[] { 0x02, 0x30, 0x31, 0x34, 0x34, 0x30, 0x36, 0x58, 0x30, 0x30, 0x35, 0x30, 0x34, 0x45, 0x03 }));
        }
Ejemplo n.º 2
0
        public void BuildWriteTest( )
        {
            OperateResult <byte[]> read = FatekProgram.BuildWriteByteCommand(1, "Y8", new byte[] { 0xAA, 0xAA, 0x55, 0x55 });

            Assert.IsTrue(read.IsSuccess);

            Assert.IsTrue(SoftBasic.IsTwoBytesEquel(read.Content, new byte[] { 0x02, 0x30, 0x31, 0x34, 0x37, 0x30, 0x32, 0x57, 0x59, 0x30, 0x30, 0x30, 0x38,
                                                                               0x41, 0x41, 0x41, 0x41, 0x35, 0x35, 0x35, 0x35, 0x38, 0x30, 0x03 }));
        }
Ejemplo n.º 3
0
        public void BuildReadTest( )
        {
            OperateResult <byte[]> read = FatekProgram.BuildReadCommand(1, "R12", 3, false);

            Assert.IsTrue(read.IsSuccess);

            Assert.IsTrue(SoftBasic.IsTwoBytesEquel(read.Content, new byte[] { 0x02, 0x30, 0x31, 0x34, 0x36, 0x30, 0x33, 0x52,
                                                                               0x30, 0x30, 0x30, 0x31, 0x32, 0x37, 0x35, 0x03 }));
        }
Ejemplo n.º 4
0
        public void BuildWriteBoolTest( )
        {
            OperateResult <byte[]> read = FatekProgram.BuildWriteBoolCommand(1, "Y0", new bool[] { true, false, false, true });

            Assert.IsTrue(read.IsSuccess);

            Assert.IsTrue(SoftBasic.IsTwoBytesEquel(read.Content, new byte[] { 0x02, 0x30, 0x31, 0x34, 0x35, 0x30, 0x34, 0x59, 0x30, 0x30, 0x30, 0x30,
                                                                               0x31, 0x30, 0x30, 0x31, 0x30, 0x42, 0x03 }));
        }
Ejemplo n.º 5
0
        public override void DeviceConn(FatekProgramConfig config)
        {
            FatekProgram fatek = new FatekProgram();

            SetPort();
            fatek.SerialPortInni(serialPort.PortName, serialPort.BaudRate, serialPort.DataBits, serialPort.StopBits, serialPort.Parity);
            fatek.Station = config.StationNo;
            fatek.Open();
            NetworkDevice = fatek;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (!int.TryParse(textBox2.Text, out int baudRate))
            {
                MessageBox.Show(DemoUtils.BaudRateInputWrong);
                return;
            }

            if (!int.TryParse(textBox16.Text, out int dataBits))
            {
                MessageBox.Show(DemoUtils.DataBitsInputWrong);
                return;
            }

            if (!int.TryParse(textBox17.Text, out int stopBits))
            {
                MessageBox.Show(DemoUtils.StopBitInputWrong);
                return;
            }


            fatekProgram?.Close( );
            fatekProgram = new FatekProgram( );

            try
            {
                fatekProgram.SerialPortInni(sp =>
                {
                    sp.PortName = textBox1.Text;
                    sp.BaudRate = baudRate;
                    sp.DataBits = dataBits;
                    sp.StopBits = stopBits == 0 ? System.IO.Ports.StopBits.None : (stopBits == 1 ? System.IO.Ports.StopBits.One : System.IO.Ports.StopBits.Two);
                    sp.Parity   = comboBox1.SelectedIndex == 0 ? System.IO.Ports.Parity.None : (comboBox1.SelectedIndex == 1 ? System.IO.Ports.Parity.Odd : System.IO.Ports.Parity.Even);
                });
                fatekProgram.Station = byte.Parse(textBox15.Text);


                fatekProgram.Open( );
                button2.Enabled = true;
                button1.Enabled = false;
                panel2.Enabled  = true;

                userControlCurve1.ReadWriteNet = fatekProgram;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public FormFatekPrograme( )
 {
     InitializeComponent( );
     fatekProgram = new FatekProgram( );
 }