示例#1
0
 public static IFlash Information(
     this IFlash flash,
     string content,
     string title = null,
     string key   = null)
 {
     return(AddMessage(flash, nameof(Information), content, title, key));
 }
示例#2
0
        public void Write(IFlash aFlash, uint aOffset, FileStream aFile)
        {
            byte[] data = new byte[aFile.Length];

            aFile.Read(data, 0, data.Length);

            Write(aFlash, aOffset, data);
        }
示例#3
0
 public static IFlash Error(
     this IFlash flash,
     string content,
     string title = null,
     string key   = null)
 {
     return(AddMessage(flash, nameof(Error), content, title, key));
 }
示例#4
0
        public void Write(IFlash aFlash, uint aOffset, byte[] aData)
        {
            if (aOffset + aData.Length > aFlash.SectorCount * aFlash.SectorBytes)
            {
                throw (new FlashException("Flash size exceeded, writing " + aData.Length + " bytes to " + aOffset));
            }

            uint offset = 0;
            uint count  = (uint)aData.Length;

            while (count > 0)
            {
                uint payload = 64;

                if (count < 64)
                {
                    payload = count;
                }

                string record = "S3";

                uint checksum = 0;

                record += (payload + 5).ToString("X2");

                checksum += payload + 5;

                uint address = aOffset + offset;

                record += address.ToString("X8");

                checksum += (byte)address;
                checksum += (byte)(address >> 8);
                checksum += (byte)(address >> 16);
                checksum += (byte)(address >> 24);

                for (int i = 0; i < payload; i++)
                {
                    byte value = aData[offset++];
                    record   += value.ToString("X2");
                    checksum += value;
                }

                checksum = ~checksum;

                record += ((byte)checksum).ToString("X2");

                record += "\n";

                byte[] data = UTF8Encoding.UTF8.GetBytes(record);

                iOutput.Write(data, 0, data.Length);

                count -= payload;
            }

            ReportSuccess();
        }
 public void SetUp()
 {
     request = new InMemoryFubuRequest();
     handler = MockRepository.GenerateStub<IValidationContinuationHandler>();
     flash = MockRepository.GenerateStub<IFlash>();
     policy = new PlaceOrderValidationFailurePolicy(request, handler, flash);
     var notification = Notification.Invalid();
     var failure = new ValidationFailure(null, notification, null);
     policy.Handle(failure);
 }
示例#6
0
        public FallbackEmulatorSrecA(IConsole aConsole, string aOutput)
        {
            iConsole = aConsole;
            iFlash   = new Flash(4, 128, 256 * 1024);

            try
            {
                iOutput = new FileStream(aOutput, FileMode.Create);
            }
            catch (Exception)
            {
                throw (new FlashException());
            }

            byte[] hdr = UTF8Encoding.UTF8.GetBytes("HDR");

            uint count = (uint)hdr.Length;

            string record = "S0";

            uint checksum = 0;

            record += (count + 3).ToString("X2");

            checksum += count + 3;

            uint address = 0;

            record += address.ToString("X4");

            checksum += (byte)address;
            checksum += (byte)(address >> 8);
            checksum += (byte)(address >> 16);
            checksum += (byte)(address >> 24);

            for (int i = 0; i < count; i++)
            {
                byte value = hdr[i];
                record   += value.ToString("X2");
                checksum += value;
            }

            checksum = ~checksum;

            record += ((byte)checksum).ToString("X2");

            record += "\n";

            byte[] data = UTF8Encoding.UTF8.GetBytes(record);

            iOutput.Write(data, 0, data.Length);

            ReportSuccess();
        }
        public void SetUp()
        {
            _flash   = MockRepository.GenerateStub <IFlash>();
            _auth    = MockRepository.GenerateStub <IAuthenticationContext>();
            _locator = MockRepository.GenerateStub <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => _locator);
            _resolver = MockRepository.GenerateStub <IUrlResolver>();
            _locator.Stub(l => l.GetInstance <IUrlResolver>()).Return(_resolver);
            _controller = new LoginController(_flash, _auth, _resolver);

            beforeEach();
        }
        public void SetUp()
        {
            _flash = MockRepository.GenerateStub<IFlash>();
            _auth = MockRepository.GenerateStub<IAuthenticationContext>();
            _locator = MockRepository.GenerateStub<IServiceLocator>();
            ServiceLocator.SetLocatorProvider(()=> _locator);
            _resolver = MockRepository.GenerateStub<IUrlResolver>();
            _locator.Stub(l => l.GetInstance<IUrlResolver>()).Return(_resolver);
            _controller = new LoginController(_flash, _auth, _resolver);

            beforeEach();
        }
示例#9
0
        public void Erase(IFlash aFlash, uint aOffset, uint aBytes)
        {
            uint id          = aFlash.Id;
            uint sectorbytes = aFlash.SectorBytes;

            /*
             * if (aOffset % sectorbytes != 0 || aBytes % sectorbytes != 0)
             * {
             *  throw (new FlashException("Sector alignment error"));
             * }
             */

            iSector = aOffset / sectorbytes;
            iCount  = (aBytes + sectorbytes - 1) / sectorbytes;

            iConsole.ProgressOpen((int)iCount);

            for (int i = 0; i < iCount;)
            {
                uint retry = kMaxEraseSectorRetries;

                while (true)
                {
                    iEraseSectorComplete.Reset();

                    iActionEraseSector.EraseSectorBegin(id, iSector);

                    if (iEraseSectorComplete.WaitOne(kMaxEraseSectorSeconds * 1000, false))
                    {
                        break;
                    }

                    if (--retry == 0)
                    {
                        iConsole.ProgressClose();
                        throw (new FlashException());
                    }
                }

                iSector++;

                iConsole.ProgressSetValue(++i);
            }

            iConsole.ProgressClose();
            ReportSuccess();
        }
示例#10
0
        private static IFlash AddMessage(
            this IFlash flash,
            string type,
            string content,
            string title = null,
            string key   = null)
        {
            if (string.IsNullOrWhiteSpace(type))
            {
                throw new ArgumentNullException(nameof(type));
            }

            flash.Push(new Message {
                Type = type, Content = content, Key = key, Title = title
            });
            return(flash);
        }
示例#11
0
 /// <summary>
 /// 命令名字闪烁操作
 /// </summary>
 public void FlashName()
 {
     if (Wait_seconds > 0)
     {
         Wait_seconds--;
         foreach (var item in FlashSignals)
         {
             if (item is IFlash)
             {
                 IFlash f = item as IFlash;
                 f.FlashNameFlag = !f.FlashNameFlag;
                 item.InvalidateVisual();
             }
         }
     }
     else
     {
         foreach (var item in FlashSignals)
         {
             item.FlashNameFlag = false;
         }
         FlashSignals.Clear();
     }
 }
示例#12
0
 public void Erase(IFlash aFlash, uint aOffset, uint aBytes)
 {
     ReportSuccess();
 }
示例#13
0
 public byte[] Read(IFlash aFlash, uint aOffset, uint aBytes)
 {
     throw (new FlashException());
 }
示例#14
0
 public post_handler(IRepository repository, IFlash flash)
 {
     _repository = repository;
     _flash = flash;
 }
示例#15
0
 public LoginController(IFlash flash, IAuthenticationContext authContext, IUrlResolver resolver)
 {
     _flash       = flash;
     _authContext = authContext;
     _resolver    = resolver;
 }
示例#16
0
        public byte[] Read(IFlash aFlash, uint aOffset, uint aBytes)
        {
            if (aOffset + aBytes > aFlash.SectorCount * aFlash.SectorBytes)
            {
                throw (new FlashException("Flash size exceeded"));
            }

            iData = new byte[aBytes];

            iOffset = 0;

            uint bytes = aBytes;

            iConsole.ProgressOpen((int)aBytes);

            while (bytes > kMaxReadBytes)
            {
                uint retry = kMaxReadRetries;

                while (true)
                {
                    iReadComplete.Reset();

                    iActionRead.ReadBegin(aFlash.Id, aOffset + iOffset, kMaxReadBytes);

                    if (iReadComplete.WaitOne(kMaxReadSeconds * 1000, false))
                    {
                        break;
                    }

                    if (--retry == 0)
                    {
                        iConsole.ProgressClose();
                        throw (new FlashException());
                    }
                }

                bytes   -= kMaxReadBytes;
                iOffset += kMaxReadBytes;

                iConsole.ProgressSetValue((int)iOffset);
            }

            if (bytes > 0)
            {
                iReadComplete.Reset();

                iActionRead.ReadBegin(aFlash.Id, aOffset + iOffset, bytes);

                if (!iReadComplete.WaitOne(kMaxReadSeconds * 1000, false))
                {
                    iConsole.ProgressClose();
                    throw (new FlashException());
                }
            }

            iConsole.ProgressClose();

            ReportSuccess();

            return(iData);
        }
示例#17
0
        public void Write(IFlash aFlash, uint aOffset, FileStream aFile)
        {
            if (aOffset + aFile.Length > aFlash.SectorCount * aFlash.SectorBytes)
            {
                throw (new FlashException("Flash size exceeded"));
            }

            iOffset = 0;

            int bytes = (int)aFile.Length;

            iConsole.ProgressOpen(bytes);

            while (bytes > kMaxWriteBytes)
            {
                byte[] data = new byte[kMaxWriteBytes];

                aFile.Read(data, 0, kMaxWriteBytes);

                uint retry = kMaxWriteRetries;

                while (true)
                {
                    iWriteComplete.Reset();

                    iActionWrite.WriteBegin(aFlash.Id, aOffset + (uint)iOffset, data);

                    if (iWriteComplete.WaitOne(kMaxWriteSeconds * 1000, false))
                    {
                        break;
                    }

                    if (--retry == 0)
                    {
                        iConsole.ProgressClose();
                        throw (new FlashException());
                    }
                }

                bytes   -= kMaxWriteBytes;
                iOffset += kMaxWriteBytes;

                iConsole.ProgressSetValue((int)iOffset);
            }

            if (bytes > 0)
            {
                byte[] data = new byte[bytes];

                aFile.Read(data, 0, bytes);

                uint retry = kMaxWriteRetries;

                while (true)
                {
                    iWriteComplete.Reset();

                    iActionWrite.WriteBegin(aFlash.Id, aOffset + (uint)iOffset, data);

                    if (iWriteComplete.WaitOne(kMaxWriteSeconds * 1000, false))
                    {
                        break;
                    }

                    if (--retry == 0)
                    {
                        iConsole.ProgressClose();
                        throw (new FlashException());
                    }
                }
            }

            iConsole.ProgressClose();
            ReportSuccess();
        }
 public PlaceOrderValidationFailurePolicy(IFubuRequest request, IValidationContinuationHandler handler, IFlash flash)
 {
     _request = request;
     _handler = handler;
     _flash = flash;
 }
示例#19
0
 public get_handler(IFlash flash)
 {
     _flash = flash;
 }
 public TopScoreUpdater(IDocumentSession session, IFlash flash)
 {
     this.session = session;
     this.flash = flash;
 }