Example #1
0
        public TestMainForm(IApplication application)
        {
            InitializeComponent();

            handle = new HandleIO();
            bios = new BlockConfigurationIO(application, application.GetEpromRW());
        }
Example #2
0
        public MainForm(IApplication application)
        {
            InitializeComponent();

            handle = new HandleIO();
            bios = new BlockConfigurationIO(application, application.GetEpromRW());
            bios.Options.AttemptsToReadWriteEntries = 5;
        }
Example #3
0
        public void SaveToDevice(HandleIO pObject)
        {
            try
            {
                string protectStart = "@JOB#000#" + string.Format("{0:X2}", platformIO.Options.Device) +
                                      platformIO.Options.ProtectionStart + "$";
                platform.SendPacket(new Packet(protectStart, DateTime.Now, null));

                int[] pages = { 0, 1, 2, 3 };

                foreach (int page in pages)
                {
                    for (int line = 0; line < 16; line++)
                    {
                        string data = pObject.Eprom[page].Lines[line].ToString();

                        platformIO.Write(platformIO.Options.Device, page + 1, line * 16, 16, data);
                        switch (platformIO.LastOperation)
                        {
                        case ResultOperation.Succes:

                            if (eSaveCompleteReadEpromLine != null)
                            {
                                eSaveCompleteReadEpromLine(this, new EventArgs());
                            }
                            break;

                        case ResultOperation.Timeout:

                            if (eSaveTimeoutReadEpromLine != null)
                            {
                                eSaveTimeoutReadEpromLine(this, new EventArgs());
                            }
                            return;

                        case ResultOperation.MorePopit:

                            if (eSaveMorePopitReadEpromLine != null)
                            {
                                eSaveMorePopitReadEpromLine(this, new EventArgs());
                            }
                            return;

                        default:

                            return;
                        }
                    }
                }
            }
            finally
            {
                string protectEnd = "@JOB#000#" + string.Format("{0:X2}", platformIO.Options.Device) +
                                    platformIO.Options.ProtectionEnd + "$";
                platform.SendPacket(new Packet(protectEnd, DateTime.Now, null));
            }
        }
Example #4
0
        public void SaveToFile(string filePath, FileFormat format, HandleIO handle)
        {
            IEFSaver svr = null;

            svr = platform.GetEFSaver(FileFormat.EF2XML);

            SaveToEprom(handle);
            svr.Save(filePath, handle.Eprom);
        }
Example #5
0
        public void LoadDefault(HandleIO handle)
        {
            Eprom eprom = new Eprom(0x00);

            for (int by = 0; by < 256; by++)
            {
                eprom[0][by] = 0xff;
            }
            handle.Eprom       = eprom;
            handle.VisionBlock = CreateBlock(eprom);

            handle.ProgrammVersion = new Version(0, 0, 0, 0);
        }
Example #6
0
        public LoadForm(BlockConfigurationIO bios, HandleIO handle)
        {
            InitializeComponent();

            pBios = bios;
            hio = handle;

            pBios.eCompleteReadEpromLine += new EventHandler(pBios_eCompleteReadEpromLine);
            pBios.eMorePopitReadEpromLine += new EventHandler(pBios_eMorePopitReadEpromLine);
            pBios.eTimeoutReadEpromLine += new EventHandler(pBios_eTimeoutReadEpromLine);

            incer = new Incer(IncP);
            initer = new Initer(InitProgressBar);

            mes = new Messeger(ShowMessage);
            obj = new object();
        }
Example #7
0
        public SaveForm(BlockConfigurationIO bios, HandleIO obje)
        {
            InitializeComponent();

            pBios = bios;
            pObject = obje;

            obj = new object();

            incer = new Incer(IncP);
            initer = new Initer(InitProgressBar);

            DialogResult = DialogResult.OK;

            pBios.eSaveCompleteReadEpromLine += new EventHandler(pBios_eSaveCompleteReadEpromLine);
            pBios.eSaveMorePopitReadEpromLine += new EventHandler(pBios_eSaveMorePopitReadEpromLine);
            pBios.eSaveTimeoutReadEpromLine += new EventHandler(pBios_eSaveTimeoutReadEpromLine);
        }
Example #8
0
        public void LoadFromFile(string filePath, HandleIO handle, FileFormat format)
        {
            IEFLoader ldr   = platform.GetEFLoader(format);
            Eprom     eprom = new Eprom();

            eprom = ldr.Load(filePath);
            if (eprom != null)
            {
                handle.Eprom       = eprom;
                handle.VisionBlock = CreateBlock(eprom);

                if (handle.VisionBlock != null)
                {
                    handle.CRC16           = CalculateCRC16(eprom);
                    handle.ProgrammVersion = new Version(0, 0, 0, 0);
                }
            }
        }
Example #9
0
        /// <summary>
        /// Сохранить конфигурацию устройства в Eprom
        /// </summary>
        /// <param name="handle">Описатель</param>
        public void SaveToEprom(HandleIO handle)
        {
            for (int i = 0; i < 16; i++)
            {
                if (handle.VisionBlock.Indicators[i].IndicatorType != IndicatorType.Default)
                {
                    handle.Eprom[1][i * 16 + 0] = handle.VisionBlock.Indicators[i].Con;
                    handle.Eprom[1][i * 16 + 1] = handle.VisionBlock.Indicators[i].Address;

                    handle.Eprom[1][i * 16 + 2] = handle.VisionBlock.Indicators[i].Offset;
                    handle.Eprom[1][i * 16 + 3] = handle.VisionBlock.Indicators[i].OffsetThr.TotalOffset;

                    handle.Eprom[1][i * 16 + 5] = handle.VisionBlock.Indicators[i].OffsetPp.TotalOffset;
                    handle.Eprom[1][i * 16 + 6] = handle.VisionBlock.Indicators[i].PointPosition;
                }

                switch (handle.VisionBlock.Indicators[i].IndicatorType)
                {
                case IndicatorType.Column32: handle.Eprom[1][i * 16 + 7] = 1; break;

                case IndicatorType.Column32Bipolar: handle.Eprom[1][i * 16 + 7] = 2; break;

                case IndicatorType.ThreeDigit: handle.Eprom[1][i * 16 + 7] = 3; break;

                case IndicatorType.FourDigit: handle.Eprom[1][i * 16 + 7] = 4; break;

                case IndicatorType.FiveDigit: handle.Eprom[1][i * 16 + 7] = 5; break;

                case IndicatorType.Clock: handle.Eprom[1][i * 16 + 7] = 6; break;
                }

                byte[] factArray = BitConverter.GetBytes(handle.VisionBlock.Indicators[i].Fact);
                ReverseBytes(factArray);

                byte[] CorrectoffsetArray = BitConverter.GetBytes(handle.VisionBlock.Indicators[i].CorrectOffset);
                ReverseBytes(CorrectoffsetArray);

                byte[] minArray = BitConverter.GetBytes(handle.VisionBlock.Indicators[i].Thr_MIN);
                ReverseBytes(minArray);

                byte[] maxArray = BitConverter.GetBytes(handle.VisionBlock.Indicators[i].Thr_MAX);
                ReverseBytes(maxArray);

                for (int ind = 0; ind < 4; ind++)
                {
                    handle.Eprom[2][i * 16 + ind]         = factArray[ind];
                    handle.Eprom[2][(i * 16) + (ind + 4)] = CorrectoffsetArray[ind];

                    handle.Eprom[2][(i * 16) + (ind + 8)]  = minArray[ind];
                    handle.Eprom[2][(i * 16) + (ind + 12)] = maxArray[ind];
                }

                handle.Eprom[0][0x18] = handle.VisionBlock.Address;
                handle.Eprom[0][0x10] = handle.VisionBlock.Speed;
                handle.Eprom[0][0x11] = handle.VisionBlock.TypeCRC;
                handle.Eprom[0][0xe0] = handle.VisionBlock.SpeedOpros;
                handle.Eprom[0][0xd0] = handle.VisionBlock.NumbersOfIndicators;

                for (int j = 0; j < 8; j++)
                {
                    handle.Eprom[0][0xf0 + j * 2]         = handle.VisionBlock.Cmds[j].Address;
                    handle.Eprom[0][0xf0 + ((j * 2) + 1)] = handle.VisionBlock.Cmds[j].SizeBuffer;
                }

                ushort crc16 = CalculateCRC16(handle.Eprom);

                handle.Eprom[3][0] = (byte)crc16;
                handle.Eprom[3][1] = (byte)(crc16 >> 8);
            }
        }
Example #10
0
        public void SaveToFile(string filePath, FileFormat format, HandleIO handle)
        {
            IEFSaver svr = null;
            svr = platform.GetEFSaver(FileFormat.EF2XML);

            SaveToEprom(handle);
            svr.Save(filePath, handle.Eprom);
        }
Example #11
0
        /// <summary>
        /// Сохранить конфигурацию устройства в Eprom
        /// </summary>
        /// <param name="handle">Описатель</param>
        public void SaveToEprom(HandleIO handle)
        {
            for (int i = 0; i < 16; i++)
            {
                if (handle.VisionBlock.Indicators[i].IndicatorType != IndicatorType.Default)
                {
                    handle.Eprom[1][i * 16 + 0] = handle.VisionBlock.Indicators[i].Con;
                    handle.Eprom[1][i * 16 + 1] = handle.VisionBlock.Indicators[i].Address;

                    handle.Eprom[1][i * 16 + 2] = handle.VisionBlock.Indicators[i].Offset;
                    handle.Eprom[1][i * 16 + 3] = handle.VisionBlock.Indicators[i].OffsetThr.TotalOffset;

                    handle.Eprom[1][i * 16 + 5] = handle.VisionBlock.Indicators[i].OffsetPp.TotalOffset;
                    handle.Eprom[1][i * 16 + 6] = handle.VisionBlock.Indicators[i].PointPosition;
                }

                switch (handle.VisionBlock.Indicators[i].IndicatorType)
                {
                    case IndicatorType.Column32: handle.Eprom[1][i * 16 + 7] = 1; break;
                    case IndicatorType.Column32Bipolar: handle.Eprom[1][i * 16 + 7] = 2; break;
                    case IndicatorType.ThreeDigit: handle.Eprom[1][i * 16 + 7] = 3; break;
                    case IndicatorType.FourDigit: handle.Eprom[1][i * 16 + 7] = 4; break;
                    case IndicatorType.FiveDigit: handle.Eprom[1][i * 16 + 7] = 5; break;
                    case IndicatorType.Clock: handle.Eprom[1][i * 16 + 7] = 6; break;
                }

                byte[] factArray = BitConverter.GetBytes(handle.VisionBlock.Indicators[i].Fact);
                byte[] CorrectoffsetArray = BitConverter.GetBytes(handle.VisionBlock.Indicators[i].CorrectOffset);

                byte[] minArray = BitConverter.GetBytes(handle.VisionBlock.Indicators[i].Thr_MIN);
                byte[] maxArray = BitConverter.GetBytes(handle.VisionBlock.Indicators[i].Thr_MAX);

                for (int ind = 0; ind < 4; ind++)
                {
                    handle.Eprom[2][i * 16 + ind] = factArray[ind];
                    handle.Eprom[2][(i * 16) + (ind + 4)] = CorrectoffsetArray[ind];

                    handle.Eprom[2][(i * 16) + (ind + 8)] = minArray[ind];
                    handle.Eprom[2][(i * 16) + (ind + 12)] = minArray[ind];
                }

                handle.Eprom[0][0x18] = handle.VisionBlock.Address;
                handle.Eprom[0][0x10] = handle.VisionBlock.Speed;
                handle.Eprom[0][0x11] = handle.VisionBlock.TypeCRC;
                handle.Eprom[0][0xe0] = handle.VisionBlock.SpeedOpros;

                for (int j = 0; j < 8; j++)
                {
                    handle.Eprom[0][0xf0 + j * 2] = handle.VisionBlock.Cmds[j].Address;
                    handle.Eprom[0][0xf0 + ((j * 2) + 1)] = handle.VisionBlock.Cmds[j].SizeBuffer;
                }

                ushort crc16 = CalculateCRC16(handle.Eprom);

                handle.Eprom[3][0] = (byte)crc16;
                handle.Eprom[3][1] = (byte)(crc16 >> 8);
            }
        }
Example #12
0
        public void SaveToDevice(HandleIO pObject)
        {
            try
            {
                string protectStart = "@JOB#000#" + string.Format("{0:X2}", platformIO.Options.Device) +
                    platformIO.Options.ProtectionStart + "$";
                platform.SendPacket(new Packet(protectStart, DateTime.Now, null));

                int[] pages = { 0, 1, 2, 3 };

                foreach (int page in pages)
                {
                    for (int line = 0; line < 16; line++)
                    {

                        string data = pObject.Eprom[page].Lines[line].ToString();

                        platformIO.Write(platformIO.Options.Device, page + 1, line * 16, 16, data);
                        switch (platformIO.LastOperation)
                        {
                            case ResultOperation.Succes:

                                if (eSaveCompleteReadEpromLine != null) eSaveCompleteReadEpromLine(this, new EventArgs());
                                break;

                            case ResultOperation.Timeout:

                                if (eSaveTimeoutReadEpromLine != null) eSaveTimeoutReadEpromLine(this, new EventArgs());
                                return;

                            case ResultOperation.MorePopit:

                                if (eSaveMorePopitReadEpromLine != null) eSaveMorePopitReadEpromLine(this, new EventArgs());
                                return;

                            default:

                                return;
                        }
                    }
                }
            }
            finally
            {
                string protectEnd = "@JOB#000#" + string.Format("{0:X2}", platformIO.Options.Device) +
                    platformIO.Options.ProtectionEnd + "$";
                platform.SendPacket(new Packet(protectEnd, DateTime.Now, null));
            }
        }
Example #13
0
        public void LoadFromFile(string filePath, HandleIO handle, FileFormat format)
        {
            IEFLoader ldr = platform.GetEFLoader(format);
            Eprom eprom = new Eprom();

            eprom = ldr.Load(filePath);
            if (eprom != null)
            {
                handle.Eprom = eprom;
                handle.VisionBlock = CreateBlock(eprom);

                if (handle.VisionBlock != null)
                {
                    handle.CRC16 = CalculateCRC16(eprom);
                    handle.ProgrammVersion = new Version(0, 0, 0, 0);
                }
            }
        }
Example #14
0
        public void LoadDefault(HandleIO handle)
        {
            Eprom eprom = new Eprom(0x00);

            for (int by = 0; by < 256; by++)
            {
                eprom[0][by] = 0xff;
            }
            handle.Eprom = eprom;
            handle.VisionBlock = CreateBlock(eprom);

            handle.ProgrammVersion = new Version(0,0,0,0);
        }