Beispiel #1
0
        private void readStatusSystem(byte[] array)
        {
            Structures.FlashResult buffer = new Structures.FlashResult();
            object obj = new Structures.FlashResult();

            StructConvert.ByteArrayToStructure(array, ref obj);
            buffer = (Structures.FlashResult)obj;

            Enums.Status status;

/*			if (commandOut != Enums.Commands.StatusSystem)
 *                      {
 *                              if (commandOut == Enums.Commands.ReadFlash)
 *                              {
 *                                      MainWindow.Logger.Info("Чтение EEPROM завершено");
 *                                      Device.StatusProgress = Enums.StatusProgress.Finish;
 *                                      // TODO разрешить работать кнопке сохранить ЕЕПРОМ
 *                              }
 *                              commandOut = Enums.Commands.ZeroCommand;
 *                      }
 */         status = (Enums.Status)buffer.Status;
            if (status != Enums.Status.OK)
            {
                MainWindow.Logger.Error("Ошибка операции: {0}", status);
                commandOut            = Enums.Commands.ZeroCommand;
                Device.StatusProgress = Enums.StatusProgress.Alarm;                //Finish
                Function = Enums.FunctionalMode.Disable;
            }
        }
Beispiel #2
0
        private void readProgramVerifyFlash(byte[] array)
        {
            Structures.FlashResult buffer = new Structures.FlashResult();
            object obj = new Structures.FlashResult();

            StructConvert.ByteArrayToStructure(array, ref obj);
            buffer = (Structures.FlashResult)obj;

            Enums.Status status = (Enums.Status)buffer.Status;
            if (status != Enums.Status.OK)
            {
                MainWindow.Logger.Error("Ошибка операции: {0}", status);
                commandOut            = Enums.Commands.ZeroCommand;
                Device.StatusProgress = Enums.StatusProgress.Alarm;
                Function = Enums.FunctionalMode.Disable;
            }
            //Device.AddressOffset += Device.LengthSend; // TODO uncomment
            if (TaskToProcess == 1)
            {
                TaskToProcess = 0;
            }
        }
Beispiel #3
0
        private void readVersionSoft(byte[] array)
        {
            Structures.FlashVersion buffer = new Structures.FlashVersion();
            object obj = new Structures.FlashVersion();

            StructConvert.ByteArrayToStructure(array, ref obj);
            buffer = (Structures.FlashVersion)obj;

            Device.InfoDevice.DeviceAddress     = buffer.FromNetAddress;
            Device.InfoDevice.VersionBootloader = buffer.VersionBootLoader;
            Device.InfoDevice.Machine           = (Enums.Machine)buffer.Machine;
            Device.InfoDevice.NumberMachine     = buffer.NumberMachine;
            Device.InfoDevice.TypeCpu           = (Enums.CpuIdentificator)buffer.TypeCpu;

            Device.InfoDevice.AddressUserCodeBegin = buffer.AddressUserCodeBegin;
            Device.InfoDevice.AddressUserCodeEnd   = buffer.AddressUserCodeEnd;

            Device.InfoDevice.AddressEepromBegin = buffer.AddressEepromBegin;
            Device.InfoDevice.AddressEepromEnd   = buffer.AddressEepromEnd;

            Function = Enums.FunctionalMode.Disable;
        }
Beispiel #4
0
        private void readEraseFlash(byte[] array)
        {
            Structures.FlashResult buffer = new Structures.FlashResult();
            object obj = new Structures.FlashResult();

            StructConvert.ByteArrayToStructure(array, ref obj);
            buffer = (Structures.FlashResult)obj;

            Enums.Status status = (Enums.Status)buffer.Status;
            if (status != Enums.Status.OK)
            {
                MainWindow.Logger.Error("Ошибка операции: {0}", status);
                Device.StatusProgress = Enums.StatusProgress.Alarm;
                Function = Enums.FunctionalMode.Disable;
            }
            else
            {
                MainWindow.Logger.Trace("Очистка завершена");
                Device.StatusProgress = Enums.StatusProgress.Finish;
                Function = Enums.FunctionalMode.Disable;
            }

            commandOut = Enums.Commands.ZeroCommand;
        }
Beispiel #5
0
        private void readReadFlash(byte[] array)
        {
            Structures.FlashReadWrite buffer = new Structures.FlashReadWrite();
            object obj = new Structures.FlashReadWrite();

            StructConvert.ByteArrayToStructure(array, ref obj);
            buffer = (Structures.FlashReadWrite)obj;

            if (Function == Enums.FunctionalMode.ReadEeprom)
            {
                if (buffer.LengthData == 0)                 // Чтение завершено
                {
                    MainWindow.Logger.Trace("Чтение EEPROM завершено");
                    Device.StatusProgress = Enums.StatusProgress.Finish;
                    Function = Enums.FunctionalMode.Disable;
                }

                for (int i = 0; i < buffer.LengthData * 2; i++)
                {
                    Device.EepromData.Add(buffer.Data[i]);
                }
            }
            else if (Function == Enums.FunctionalMode.ReadFlash)
            {
                for (int i = 0; i < buffer.LengthData * 2; i++)
                {
                    Device.FlashData.Add(buffer.Data[i]);
                }

                if (buffer.LengthData == 0)                 // Чтение завершено
                {
                    MainWindow.Logger.Trace("Чтение Flash завершено");
                    Device.StatusProgress = Enums.StatusProgress.Finish;
                    Function = Enums.FunctionalMode.Disable;
                }
            }
            else if (Function == Enums.FunctionalMode.ReadRegion)
            {
                for (int i = 0; i < buffer.LengthData * 2; i++)
                {
                    Device.RegionData.Add(buffer.Data[i]);
                }

                if (buffer.LengthData == 0)                 // Чтение завершено
                {
                    MainWindow.Logger.Trace("Чтение области завершено");
                    Device.StatusProgress = Enums.StatusProgress.Finish;
                    Function = Enums.FunctionalMode.Disable;
                }
            }

            if (buffer.LengthData != 0)
            {
                Device.StatusProgress = Enums.StatusProgress.Inderterminate;
            }

            if (TaskToProcess == 1)
            {
                TaskToProcess = 0;
            }
        }