public void BuildWriteWordCommandTest( )
        {
            byte[] right = new byte[] { 0x05, 0x30, 0x30, 0x46, 0x46, 0x57, 0x57, 0x30, 0x4D, 0x30, 0x36, 0x34, 0x30, 0x30, 0x32, 0x32, 0x33, 0x34, 0x37, 0x41, 0x42, 0x39, 0x36, 0x30, 0x35 };
            OperateResult <byte[]> command = MelsecFxLinks.BuildWriteByteCommand(0, "M640", new byte[] { 0x47, 0x23, 0x96, 0xAB }, true, 0);

            Assert.IsTrue(HslCommunication.BasicFramework.SoftBasic.IsTwoBytesEquel(command.Content, right), HslCommunication.BasicFramework.SoftBasic.ByteToHexString(command.Content, ' '));
        }
        public void BuildStopCommandTest( )
        {
            byte[] right = new byte[] { 0x05, 0x30, 0x30, 0x46, 0x46, 0x52, 0x53, 0x30, 0x43, 0x31 };
            OperateResult <byte[]> command = MelsecFxLinks.BuildStop(0, true, 0);

            Assert.IsTrue(HslCommunication.BasicFramework.SoftBasic.IsTwoBytesEquel(command.Content, right), HslCommunication.BasicFramework.SoftBasic.ByteToHexString(command.Content, ' '));
        }
        public void BuildWriteBoolCommandTest( )
        {
            byte[] right = new byte[] { 0x05, 0x30, 0x30, 0x46, 0x46, 0x42, 0x57, 0x30, 0x4D, 0x30, 0x39, 0x30, 0x33, 0x30, 0x35, 0x30, 0x31, 0x31, 0x30, 0x31, 0x32, 0x36 };
            OperateResult <byte[]> command = MelsecFxLinks.BuildWriteBoolCommand(0, "M903", new bool[] { false, true, true, false, true }, true, 0);

            Assert.IsTrue(HslCommunication.BasicFramework.SoftBasic.IsTwoBytesEquel(command.Content, right), HslCommunication.BasicFramework.SoftBasic.ByteToHexString(command.Content, ' '));
        }
        public void buildCommandTest( )
        {
            byte[] right = new byte[] { 0x05, 0x30, 0x35, 0x46, 0x46, 0x42, 0x52, 0x41, 0x58, 0x30, 0x30, 0x34, 0x30, 0x30, 0x35, 0x34, 0x37 };

            OperateResult <byte[]> command = MelsecFxLinks.BuildReadCommand(5, "X40", 5, true, true, 10);

            Assert.IsTrue(HslCommunication.BasicFramework.SoftBasic.IsTwoBytesEquel(command.Content, right), HslCommunication.BasicFramework.SoftBasic.ByteToHexString(command.Content, ' '));
        }
        public void AccTest( )
        {
            string msg  = "00FFBR3ABCD";
            string msg2 = "00FFBR3ABCDBD";

            string cal = MelsecFxLinks.CalculateAcc(msg);

            Assert.IsTrue(msg2 == cal);
        }
Ejemplo n.º 6
0
        public override void DeviceConn(MelsecLinksConfig config)
        {
            MelsecFxLinks melsecFx = new MelsecFxLinks();

            SetPort();
            melsecFx.SerialPortInni(serialPort.PortName, serialPort.BaudRate, serialPort.DataBits, serialPort.StopBits, serialPort.Parity);
            melsecFx.Station      = config.StationNo;
            melsecFx.Station      = config.StationNo;
            melsecFx.WaittingTime = config.WaittingTime;
            melsecFx.SumCheck     = config.SumCheck;
            melsecFx.Open();
            NetworkDevice = melsecFx;
        }
Ejemplo n.º 7
0
        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;
            }


            melsecSerial?.Close( );
            melsecSerial = new MelsecFxLinks( );

            try
            {
                melsecSerial.SerialPortInni(sp =>
                {
                    sp.PortName = comboBox3.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);
                });
                melsecSerial.Station      = byte.Parse(textBox15.Text);
                melsecSerial.WaittingTime = byte.Parse(textBox18.Text);
                melsecSerial.SumCheck     = checkBox1.Checked;


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

                userControlReadWriteOp1.SetReadWriteNet(melsecSerial, "D100", false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 8
0
 public FormMelsecLinks( )
 {
     InitializeComponent( );
     melsecSerial = new MelsecFxLinks( );
 }