예제 #1
0
        public string SendResultTest()
        {
            int size = 1024;

            byte[] data = new byte[size];
            RByteConverter.IntToByte(IsLittleEndian, 123456, data, 0, 3);
            int x = 3;

            data[x++] = Convert.ToByte(Classer.ToIntACS(EClass.Class1));
            data[x++] = 0;
            data[x++] = Convert.ToByte(10);
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = Convert.ToByte(50);
            data[x++] = Convert.ToByte(60);
            data[x++] = Convert.ToByte(51);
            data[x++] = Convert.ToByte(61);
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = Convert.ToByte(75);
            data[x++] = Convert.ToByte(70);
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = Convert.ToByte(1);
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = 0;
            for (int i = 0; i < 130; i++)
            {
                data[x++] = (i >= 10) ? Convert.ToByte(128) : Convert.ToByte(80);
            }
            for (int i = 0; i < 130; i++)
            {
                data[x++] = (i >= 10) ? Convert.ToByte(128) : Convert.ToByte(15);
            }
            for (int i = 0; i < 130; i++)
            {
                data[x++] = (i >= 10) ? Convert.ToByte(128) : Convert.ToByte(17);
            }
            for (int i = 0; i < 130; i++)
            {
                data[x++] = 128;
            }
            Array.Resize(ref data, x);
            PacketOut pOut = new PacketOut(IsLittleEndian)
            {
                command = 5
            };

            pOut.data = data;
            if (!comPort.Write(pOut.Serial))
            {
                return("Не смогли записать");
            }
            return("Ok");
        }
예제 #2
0
        public string SendResult(Result _Result)
        {
            if (_Result == null)
            {
                return(SendResultTest());
            }
            int size = 1024;

            byte[] data = new byte[size];
            RByteConverter.IntToByte(IsLittleEndian, _Result.IdTube, data, 0, 3);
            int x = 3;

            data[x++] = Convert.ToByte(Classer.ToIntACS(_Result.Sum.RClass));
            data[x++] = 0;
            data[x++] = Convert.ToByte(_Result.Sum.MClass.Count);
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = Convert.ToByte(Math.Round(ParAll.CTS.Cross.Border1));
            data[x++] = Convert.ToByte(Math.Round(ParAll.CTS.Cross.Border2));
            data[x++] = Convert.ToByte(Math.Round(ParAll.CTS.Line.Border1));
            data[x++] = Convert.ToByte(Math.Round(ParAll.CTS.Line.Border2));
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = Convert.ToByte(Math.Round(_Result.Thick.Border1 * 10));
            data[x++] = Convert.ToByte(Math.Round(_Result.Thick.Border2 * 10));
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = Convert.ToByte(SGToInt(_Result.SG.sgState.Group));
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = 0;
            data[x++] = 0;
            for (int i = 0; i < 130; i++)
            {
                data[x++] = (i >= _Result.Thick.MZone.Count) ? Convert.ToByte(128) : GetLevel(_Result.Thick.MZone[i].RClass, _Result.Thick.MZone[i].Level);
            }
            for (int i = 0; i < 130; i++)
            {
                data[x++] = (i >= _Result.Cross.MZone.Count) ? Convert.ToByte(128) : GetLevel(_Result.Cross.MZone[i].Class, _Result.Cross.MZone[i].GetMaxLevel());
            }
            for (int i = 0; i < 130; i++)
            {
                data[x++] = (i >= _Result.Line.MZone.Count) ? Convert.ToByte(128) : GetLevel(_Result.Line.MZone[i].Class, _Result.Line.MZone[i].GetMaxLevel());
            }
            for (int i = 0; i < 130; i++)
            {
                data[x++] = 128;
            }
            Array.Resize(ref data, x);
            PacketOut pOut = new PacketOut(IsLittleEndian)
            {
                command = 5
            };

            pOut.data = data;
            if (!comPort.Write(pOut.Serial))
            {
                return("Не смогли записать");
            }
            return("Ok");
        }