コード例 #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
ファイル: BootloaderController.cs プロジェクト: urish/M3D
        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);
            }
        }
コード例 #3
0
ファイル: BaseController.cs プロジェクト: urish/M3D
 public abstract void SetFanConstants(FanConstValues.FanType fanType);