Пример #1
0
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var serialDate = GetSerialDate(serial_number);
                switch (eeprom[printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr])
                {
                case 0:
                case byte.MaxValue:
                    FanConstValues.FanType index = FanConstValues.FanType.HengLiXin;
                    if (serialDate >= 150602)
                    {
                        index = FanConstValues.FanType.Shenzhew;
                    }

                    FanConstValues.FanValues fanConstant = FanConstValues.FanConstants[index];
                    var num    = (byte)index;
                    var offset = fanConstant.Offset;
                    var scale  = fanConstant.Scale;
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr, BitConverter.GetBytes(num));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr, BitConverter.GetBytes(offset));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr, BitConverter.GetBytes(scale));
                    break;
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogErrorMsg("Exception in FirstrunUpdateDefaulFan.CheckForUpdate " + ex.Message, "Exception");
                return(false);
            }
            return(true);
        }
Пример #2
0
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var num  = eeprom[printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr];
                var flag = false;
                FanConstValues.FanType   index;
                FanConstValues.FanValues fanConstant;
                if (Enum.IsDefined(typeof(FanConstValues.FanType), (int)num))
                {
                    index       = (FanConstValues.FanType)num;
                    fanConstant = FanConstValues.FanConstants[index];
                }
                else
                {
                    index       = FanConstValues.FanType.None;
                    fanConstant = FanConstValues.FanConstants[FanConstValues.FanType.HengLiXin];
                }
                var fanValues = new FanConstValues.FanValues
                {
                    Scale  = BitConverter.ToSingle(eeprom, printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr),
                    Offset = eeprom[(int)printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr]
                };
                if (Math.Abs(fanValues.Offset - fanConstant.Offset) >= 1)
                {
                    flag = true;
                }

                if (Math.Abs(fanValues.Scale - fanConstant.Scale) >= 1.40129846432482E-45)
                {
                    flag = true;
                }

                if (flag)
                {
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr, BitConverter.GetBytes((byte)index));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr, BitConverter.GetBytes((byte)fanConstant.Offset));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr, BitConverter.GetBytes(fanConstant.Scale));
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateFanValues.CheckForUpdate " + ex.Message, "Exception");
                return(false);
            }
            return(true);
        }
Пример #3
0
        public override void SetFanConstants(FanConstValues.FanType fanType)
        {
            var eepromMapping1 = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants);
            var alignedByte1   = (int)eepromMapping1.GetAlignedByte("FANTYPE");
            var alignedByte2   = eepromMapping1.GetAlignedByte("FANOFFSET");
            var num1           = eepromMapping1.GetFloat("FANSCALE");

            FanConstValues.FanValues fanConstant = FanConstValues.FanConstants[fanType];
            var num2 = (int)(byte)fanType;

            if (alignedByte1 != num2)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANTYPE"), eepromMapping1.AlignedByteToBytaArray((ushort)fanType));
            }

            if (alignedByte2 != fanConstant.Offset)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANOFFSET"), eepromMapping1.AlignedByteToBytaArray((ushort)fanConstant.Offset));
            }

            if (num1 != (double)fanConstant.Scale)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANSCALE"), BitConverter.GetBytes(fanConstant.Scale));
            }

            var eepromMapping2 = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants);
            var alignedByte3   = (int)eepromMapping1.GetAlignedByte("FANTYPE");
            var alignedByte4   = eepromMapping1.GetAlignedByte("FANOFFSET");
            var num3           = eepromMapping1.GetFloat("FANSCALE");
            var num4           = (int)(byte)fanType;

            if (alignedByte3 == num4 && alignedByte4 == fanConstant.Offset && num3 == (double)fanConstant.Scale)
            {
                WriteLog(">> ok", Logger.TextType.Read);
            }
            else
            {
                WriteLog(">> failed", Logger.TextType.Read);
            }
        }