Пример #1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     /*   Rest client = Rest.Instanse(services);
      * CoreState.Rest = client;*/
     CoreState.AddContextWithSwagger(services, "http://172.17.9.105:1600/api", "qrpay", "joha", "123456789$j");
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
 }
Пример #2
0
    public override void Die()
    {
        coreState = CoreState.Won;
        endScreen.gameObject.SetActive(true);

        base.Die();
    }
Пример #3
0
    // Use FixedUpdate for simulation
    void FixedUpdate()
    {
        int tempDelta = 0;

        switch (state)
        {
        case CoreState.Running:
            tempDelta += temperature_step_up;
            break;

        case CoreState.Exploded:
            break;
        }

        GridManager.Instance.AddHeat(this, tempDelta);

        switch (state)
        {
        case CoreState.Running:
            if (GridManager.Instance.GetMaxTemp(this) > maxTemp)
            {
                state = CoreState.Exploded;
                anim.Play("core_explode");
            }
            break;

        case CoreState.Exploded:
            break;
        }
    }
Пример #4
0
 /// <summary>
 /// Start up the node process
 /// </summary>
 public void Start(int port)
 {
     AssertStoresLocation();
     InitializeStores();
     
     _nodeComms.Start(port);
     _state = CoreState.WaitingForMaster;
 }
Пример #5
0
        /// <summary>
        /// Start up the node process
        /// </summary>
        public void Start(int port)
        {
            AssertStoresLocation();
            InitializeStores();

            _nodeComms.Start(port);
            _state = CoreState.WaitingForMaster;
        }
Пример #6
0
    private void ChangeState()
    {
        if (LockState)
        {
            return;
        }

        AnimationState = AnimationState.Equals(CoreState.Open) ? CoreState.Close : CoreState.Open;
    }
Пример #7
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     CoreState.ContextMiddleware(app);
     app.UseMvc();
 }
Пример #8
0
 public CoreError(CoreState state, TraceBack traceback, CoreErrorType type, string msg = null)
 {
     this.state     = state;
     this.traceback = traceback;
     this.type      = type;
     // Check if the error is fatal by checking the error type
     this.fatal = ((int)type) > 0;
     this.msg   = msg;
 }
Пример #9
0
 private void OnSlaveAdded(object sender, SlaveListEventArgs e)
 {
     if (_state == CoreState.WaitingForSlaves)
     {
         if (_nodeComms.GetActiveSlaveCount() >= _masterConfiguration.WriteQuorum)
         {
             _state = CoreState.RunningMaster;
         }
     }
 }
Пример #10
0
 private void OnSlaveAdded(object sender, SlaveListEventArgs e)
 {
     if (_state == CoreState.WaitingForSlaves)
     {
         if (_nodeComms.GetActiveSlaveCount()>= _masterConfiguration.WriteQuorum)
         {
             _state = CoreState.RunningMaster;
         }
     }
 }
Пример #11
0
 void CrystalDestroyed()
 {
     crystals--;
     if (crystals == 0)
     {
         healthBar.gameObject.SetActive(true);
         coreState = CoreState.ShellOff;
         StartCoroutine(ShellOff());
     }
 }
Пример #12
0
 protected BaseCore(string type, int durability, string name)
 {
     this.Type = type;
     this.Name = name;
     this.initialDurability = durability;
     this.Durability        = durability;
     this.fragments         = new LStack();
     this.state             = CoreState.NORMAL;
     this.pressureOnCore    = 0;
 }
        // Constructor
        public MainMenu(Texture2D mmButtonTexture, SpriteFont mmButtonFont)
        {
            SelectedCorePage = CoreState.Menu;

            // Divide the grid of the screen into rows and columns
            DesignScreenLayout();

            // Create and place the objects needed for this page
            CreateAndPlaceElements(mmButtonTexture, mmButtonFont);
        }
Пример #14
0
        private void StartSyncToMaster()
        {
            _state = CoreState.SyncToMaster;
            var lastTxn = new Dictionary <string, string>();

            foreach (var store in _stores)
            {
                lastTxn.Add(store, GetLastTransactionId(store).ToString());
            }
            _nodeComms.SendSyncToMaster(_masterAddress, lastTxn);
        }
Пример #15
0
 internal void SetState(CoreState state)
 {
     if (_state != state)
     {
         _state = state;
         if (StateChanged != null)
         {
             StateChanged(this, EventArgs.Empty);
         }
     }
 }
Пример #16
0
 private static ControlBase CreateMockControl(string name, CoreCompetenceRole coreRole, ReviewCompetenceRole reviewRole, CoreState coreState, ReviewState reviewState )
 {
     return new ControlBase
     {
         Name = name,
         CoreCompetenceRole = coreRole,
         ReviewCompetenceRole = reviewRole,
         CoreState = coreState,
         ReviewState = reviewState
     };
 }
Пример #17
0
 /// <summary>
 /// Handle a endsync message from a master to a slave
 /// </summary>
 /// <param name="syncStatus">Indicates the status of the sync. Should be either OK or FAIL.</param>
 public void SlaveSyncCompleted(string syncStatus)
 {
     if (syncStatus.Equals("OK", StringComparison.OrdinalIgnoreCase))
     {
         _state = CoreState.RunningSlave;
     }
     else
     {
         // Partial sync failed
         // TODO: start full sync
     }
 }
Пример #18
0
        private void OnJobCompleted(object sender, JobCompletedEventArgs e)
        {
            var jobStatus = _serverCore.GetJobStatus(e.StoreId, e.CompletedJob.JobId.ToString());

            if (jobStatus != null && jobStatus.JobStatus == JobStatus.TransactionError)
            {
                // Because all transactions should be processable, this indicates a hardware problem or persistent software problem
                _serverCore.Shutdown(true);
                _state = CoreState.Broken;
            }
            _storeInfo[e.StoreId].Commit(e.CompletedJob.JobId);
        }
Пример #19
0
        private void FinishDisconnect()
        {
            CoreState oldState = CoreProxy.State;

            UnregisterCoreEvents();

            CoreProxy.Dispose();
            CoreProxy = null;

            StateChanged?.Invoke(this, new StateChangedEventArgs(oldState, CoreState.Disconnected));
            Log.Info("Disconnected from core");
        }
Пример #20
0
        // Constructor
        public ShopPage(Texture2D mmButtonTexture, SpriteFont mmButtonFont, Dictionary <string, ShopItem> images, PlayerManager playerManagerin)
        {
            SelectedCorePage = CoreState.Shop;
            Images           = images;
            MmButtonFont     = mmButtonFont;
            _playerManager   = playerManagerin;

            // Divide the grid of the screen into rows and columns
            DesignScreenLayout();

            // Create and place the objects needed for this page
            CreateAndPlaceElements(mmButtonTexture);
        }
Пример #21
0
 private void WaitForState(NodeCore node, CoreState expectedState, int timeToWait)
 {
     for (int i = 0; i < 10; i++)
     {
         Thread.Sleep(timeToWait / 10);
         if (node.GetStatus() == expectedState)
         {
             return;
         }
     }
     Thread.Sleep(timeToWait / 10);
     Assert.AreEqual(expectedState, node.GetStatus(), "Node did not enter the expected state after {0} milliseconds", timeToWait);
 }
        // Constructor
        public StatsPage(Texture2D mmButtonTexture, SpriteFont mmButtonFont, PlayerManager playerManagerin)
        {
            SelectedCorePage = CoreState.Stats;
            _playerManager   = playerManagerin;

            _buttonTexture = mmButtonTexture;
            _font          = mmButtonFont;

            // Divide the grid of the screen into rows and columns
            DesignScreenLayout();

            // Create and place the objects needed for this page
            CreateAndPlaceElements(mmButtonTexture, mmButtonFont);
        }
Пример #23
0
 public bool SetMaster(MasterConfiguration masterConfiguration)
 {
     _masterConfiguration = masterConfiguration;
     if (_masterConfiguration.WriteQuorum == 0)
     {
         // Don't need any slaves to enter running state
         _state = CoreState.RunningMaster;
     }
     else
     {
         // Need 1 or more slaves to connect before we enter running state
         _state = CoreState.WaitingForSlaves;
     }
     return(true);
 }
Пример #24
0
        private void CheckPressureAndAlterDurability()
        {
            if (IsPressureAboveZero())
            {
                this.state      = CoreState.CRITICAL;
                this.durability = this.initialDurability - this.pressureOnCore;

                if (this.durability < 0)
                {
                    this.durability = 0;
                }
            }
            else
            {
                //this.durability = this.initialDurability;
                this.state = CoreState.NORMAL;
            }
        }
Пример #25
0
        public void Update()
        {
            StartTimer();
            CoreState cs = c.State();

            if (cs.remainingDives == 0)
            {
                MessageBox.Show("Meet is Finished!", "Meet Finished", MessageBoxButton.OK, MessageBoxImage.Information);
                c.AutoSave();
                this.Close();
                return;
            }
            TotalDiveBlock.Text     = "Total Dives: " + cs.totalDives;
            RemainingDiveBlock.Text = "Remaining Dives: " + cs.remainingDives;
            CompletedDiveBlock.Text = "Completed Dives: " + cs.completedDives;
            DiverNameBlock.Text     = cs.curDiver.Name;
            EventNameBlock.Text     = cs.curEvent.name + " - " + cs.curEvent.Board;
            Dive d = cs.curDiver.CurrentDive();

            DiveBlock.Text = d.Code + " | " + d.Description;
        }
Пример #26
0
 public NetResult <ResponseData> AddImage([FromForm] AddImageView model)
 {
     try
     {
         if (model == null || string.IsNullOrEmpty(model.Id))
         {
             return(null);
         }
         var project = _project.Get(model.Id);
         var file    = CoreState.AddwwwRoot("projects", model.File);
         project.ImageUrl = file;
         _project.Update(project);
         return(new ResponseData()
         {
             Result = new { url = project.ImageUrl }
         });
     }
     catch (Exception ext)
     {
         return(ext);
     }
 }
Пример #27
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            CoreState.AddContextWithSwagger(services, "http://172.17.9.105:1600/api", "postman", "postman", "postman");

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            ContainerBuilder builder = new ContainerBuilder();

            services.AddCors();
            Assembly assembly = typeof(IRepositoryCore <,>).Assembly;

            //builder.RegisterGeneric(typeof(IRepositoryCore<,>), assembly);
            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            // Assembly[] assemblies = GetYourAssemblies();
            builder.RegisterGeneric(typeof(LiteRepository.Repository.LiteRepository <>))
            .As(typeof(IRepositoryCore <,>))
            .InstancePerLifetimeScope();
            var lite = new LiteDbContext();

            builder.RegisterInstance(lite).As <ILiteContext>();
            Service.Start.Builder(builder);
            builder.Populate(services);
            Container = builder.Build();
            return(new AutofacServiceProvider(Container));
        }
Пример #28
0
 // Start is called before the first frame update
 void Start()
 {
     state = CoreState.Running;
 }
Пример #29
0
 public WrongHandlerStateException(string methodName, CoreState state)
     : base($"Cannot run {methodName}, simulation is in {state} state.")
 {
 }
Пример #30
0
        protected override void OnPaint(PaintEventArgs e)
        {
            this.OnPaintBackground(e);
            if (_debugger == null)
            {
                return;
            }
            if (_debugger.DebugHost.CpuHook == null)
            {
                return;
            }

            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;

            int x = 2;
            int y = 2;

            Brush labelBrush = (this.Enabled == true) ? _labelFontBrush : _disabledFontBrush;
            Brush valueBrush = (this.Enabled == true) ? _valueFontBrush : _disabledFontBrush;

            CoreState state = _debugger.DebugHost.CpuHook.GetCoreState(0);

            // PC
            e.Graphics.DrawString("PC", _font, labelBrush, x, y, _stringFormat);
            e.Graphics.DrawString(state.ProgramCounter.ToString("X8"), _font, valueBrush, x + _labelWidth + 3, y, _stringFormat);
            y += _lineHeight;

            RegisterType mode = RegisterType.General;

            switch (mode)
            {
            case RegisterType.General:
            {
                RegisterBank bank = RegisterBanks.General;
                for (int n = 1; n < 32; n++)
                {
                    Register reg = bank.Registers[n];

                    // Label
                    e.Graphics.DrawString(reg.Name, _font, labelBrush, x, y, _stringFormat);

                    // Value
                    string value = state.GeneralRegisters[n].ToString("X8");
                    e.Graphics.DrawString(value, _font, valueBrush, x + _labelWidth + 3, y, _stringFormat);

                    y += _lineHeight;
                }

                // LO
                e.Graphics.DrawString("$lo", _font, labelBrush, x, y, _stringFormat);
                e.Graphics.DrawString(state.Lo.ToString("X8"), _font, valueBrush, x + _labelWidth + 3, y, _stringFormat);
                y += _lineHeight;

                // HI
                e.Graphics.DrawString("$hi", _font, labelBrush, x, y, _stringFormat);
                e.Graphics.DrawString(state.Hi.ToString("X8"), _font, valueBrush, x + _labelWidth + 3, y, _stringFormat);
                y += _lineHeight;
            }
            break;

            case RegisterType.Fpu:
            {
                // Control register
                e.Graphics.DrawString("fcr", _font, labelBrush, x, y, _stringFormat);
                e.Graphics.DrawString(state.FpuControlRegister.ToString("X8"), _font, valueBrush, x + _labelWidth + 3, y, _stringFormat);
                y += _lineHeight;

                // Condition bit
                e.Graphics.DrawString("fc", _font, labelBrush, x, y, _stringFormat);
                e.Graphics.DrawString(state.FpuConditionBit.ToString(), _font, valueBrush, x + _labelWidth + 3, y, _stringFormat);
                y += _lineHeight;

                // Registers
                RegisterBank bank = RegisterBanks.Fpu;
                for (int n = 0; n < 32; n++)
                {
                    Register reg = bank.Registers[n];

                    // Label
                    e.Graphics.DrawString(reg.Name, _font, labelBrush, x, y, _stringFormat);

                    // Value
                    string value = state.FpuRegisters[n].ToString();
                    e.Graphics.DrawString(value, _font, valueBrush, x + _labelWidth + 3, y, _stringFormat);

                    y += _lineHeight;
                }
            }
            break;

            case RegisterType.Vfpu:
                break;
            }
        }
Пример #31
0
 private void StartSyncToMaster()
 {
     _state = CoreState.SyncToMaster;
     var lastTxn = new Dictionary<string, string>();
     foreach (var store in _stores)
     {
         lastTxn.Add(store, GetLastTransactionId(store).ToString());
     }
     _nodeComms.SendSyncToMaster(_masterAddress, lastTxn);
 }
 private void BackButton_Click(object sender, EventArgs e)
 {
     SelectedCorePage = CoreState.Menu;
 }
 private void StatsButton_Click(object sender, EventArgs e)
 {
     SelectedCorePage = CoreState.Stats;
 }
Пример #34
0
 /// <summary>
 /// Handle a endsync message from a master to a slave
 /// </summary>
 /// <param name="syncStatus">Indicates the status of the sync. Should be either OK or FAIL.</param>
 public void SlaveSyncCompleted(string syncStatus)
 {
     if (syncStatus.Equals("OK", StringComparison.OrdinalIgnoreCase))
     {
         _state = CoreState.RunningSlave;
     } else
     {
         // Partial sync failed
         // TODO: start full sync
     }
 }
 private void PlayButton_Click(object sender, EventArgs e)
 {
     SelectedCorePage = CoreState.Play;
 }
Пример #36
0
 private void OnJobCompleted(object sender, JobCompletedEventArgs e)
 {
     var jobStatus = _serverCore.GetJobStatus(e.StoreId, e.CompletedJob.JobId.ToString());
     if (jobStatus != null && jobStatus.JobStatus == JobStatus.TransactionError)
     {
         // Because all transactions should be processable, this indicates a hardware problem or persistent software problem
         _serverCore.Shutdown(true);
         _state = CoreState.Broken;
     }
     _storeInfo[e.StoreId].Commit(e.CompletedJob.JobId);
 }
Пример #37
0
 private void WaitForState(NodeCore node, CoreState expectedState, int timeToWait)
 {
     for(int i = 0; i < 10; i++)
     {
         Thread.Sleep(timeToWait/10);
         if (node.GetStatus() == expectedState) return;
     }
     Thread.Sleep(timeToWait/10);
     Assert.AreEqual(expectedState, node.GetStatus(), "Node did not enter the expected state after {0} milliseconds", timeToWait);
 }
Пример #38
0
 public bool SetMaster(MasterConfiguration masterConfiguration)
 {
     _masterConfiguration = masterConfiguration;
     if (_masterConfiguration.WriteQuorum == 0)
     {
         // Don't need any slaves to enter running state
         _state = CoreState.RunningMaster;
     }
     else
     {
         // Need 1 or more slaves to connect before we enter running state
         _state = CoreState.WaitingForSlaves;
     }
     return true;
 }