public void OnExecuted(object sender, COMMAND cmnd) { CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "Get execution form own CC [sector: Event]."); base.Decode(); base.Execute(); base.currient.COMPLITE = true; base.state = CONTROLLER_STATE.READY; }
public virtual void OnState() { switch (state) { case CONTROLLER_STATE.READY: //if (DeadCount == 5) state = CONTROLLER_STATE.IDLE; //else DeadCount--; break; case CONTROLLER_STATE.IDLE: if (DeadCount == 0) { state = CONTROLLER_STATE.INTERRUPT; } else { DeadCount--; } break; case CONTROLLER_STATE.STARTING: Console.WriteLine("<" + Name + "> STARTING"); //if (PickTask()) //{ // Console.WriteLine("Pick on " + Name + "task: " + currient.TYPE.ToString()); // _state = CONTROLLER_STATE.BUSY; //} //else if (!currient.COMPLITE && (currient.TYPE == COMMAND_TYPE.NON_CACHE || currient.TYPE == COMMAND_TYPE.NON_CACHE_CTRL)) // _state = CONTROLLER_STATE.BUSY; //else Console.WriteLine("Currient task on " + Name + ": " + currient.TYPE.ToString()); break; case CONTROLLER_STATE.WAITING: Wait(); state = CONTROLLER_STATE.READY; break; case CONTROLLER_STATE.BUSY: Execute(); //Remove(); //if (CommandList.Count == 0) //{ // Console.WriteLine(Name + " go break."); // state = CONTROLLER_STATE.END; //} break; case CONTROLLER_STATE.INTERRUPT: state = CONTROLLER_STATE.WAITING; break; case CONTROLLER_STATE.END: CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "state.END."); break; } OnStatusChange(); }
public override void Simulator() { CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "START POINT"); base.state = CONTROLLER_STATE.STARTING; UpOwnCache(); //base.FeatTask(); base.state = CONTROLLER_STATE.READY; base.Simulator(); }
public void Wait() { try { Thread.Sleep(Timeout.Infinite); } catch (ThreadInterruptedException) { CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "woke the f**k up"); } }
public virtual void Simulator() { for (; ;) { OnState(); if (state == CONTROLLER_STATE.END) { CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "END"); //Console.WriteLine(Name + " END"); return; } } }
public override void Execute() { CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "Call override Execute()."); switch (caching.TYPE) { case COMMAND_TYPE.NON_CACHE: if (!SystemBus.IsBusy()) { SystemBus.TakeBus(); CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "take SystemBus."); //for (int i = 0; i < 6; i++) //{ // FormDrawer.BrickUP(caching.TYPE); //} SystemBus.FreeBus(); CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "free SystemBus."); base.state = CONTROLLER_STATE.EXECUTED; OnCahed(); } else { base.OnSetRequest(); Console.WriteLine(Name + " go to INTERRUPT case."); base.state = CONTROLLER_STATE.INTERRUPT; } break; case COMMAND_TYPE.NON_CACHE_CTRL: if (!SystemBus.IsBusy()) { SystemBus.TakeBus(); Console.WriteLine(Name + " take SystemBus."); //for (int i = 0; i < 6; i++) //{ // FormDrawer.BrickUP(caching.TYPE); //} SystemBus.FreeBus(); Console.WriteLine(Name + " free SystemBus."); base.state = CONTROLLER_STATE.EXECUTED; } else { base.OnSetRequest(); Console.WriteLine(Name + " go to INTERRUPT case."); base.state = CONTROLLER_STATE.INTERRUPT; } break; } }
public void OnCahed() { CachingEvent?.Invoke(this, caching); CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "[CC] cached: " + caching.TYPE); }
public void Caching(COMMAND cache) { CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "Caching task: " + currient.TYPE); caching = cache; state = CONTROLLER_STATE.BUSY; }
public override void Execute() { //Console.WriteLine("Call override Execute() in MPController."); CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "Call override Execute()."); switch (base.currient.TYPE) { case COMMAND_TYPE.CACHE: base.Decode(); base.Execute(); //base.Remove(); //base.state = CONTROLLER_STATE.READY; base.OnExecuted(); break; case COMMAND_TYPE.CACHE_CTRL: base.Decode(); if (!SystemBus.IsBusy()) { SystemBus.TakeBus(); CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "take SystemBus."); base.Execute(); SystemBus.FreeBus(); CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "free SystemBus."); //base.Remove(); base.state = CONTROLLER_STATE.READY; } else { base.OnSetRequest(); //base.currient.DEFERRED = true; Console.WriteLine(Name + " go to INTERRUPT case."); base.state = CONTROLLER_STATE.INTERRUPT; } break; case COMMAND_TYPE.NON_CACHE: own_cache.Caching(base.currient); if (own_cache.state == CONTROLLER_STATE.WAITING) { cache_thread.Interrupt(); Thread.Sleep(100); } //_own_cache.Simulator(); if (own_cache.state == CONTROLLER_STATE.EXECUTED) { CoreExtensions.ConsoleLog(Thread.CurrentThread.Name, "Get execution form own CC."); base.Decode(); base.Execute(); base.currient.COMPLITE = true; own_cache.state = CONTROLLER_STATE.END; //base.Remove(); base.state = CONTROLLER_STATE.READY; } break; case COMMAND_TYPE.NON_CACHE_CTRL: own_cache.Caching(base.currient); if (own_cache.state == CONTROLLER_STATE.WAITING) { cache_thread.Interrupt(); } //_own_cache.Simulator(); if (own_cache.state == CONTROLLER_STATE.EXECUTED) { Console.WriteLine("Get execution in " + Name); base.Decode(); base.currient.COMPLITE = true; //base.Remove(); base.state = CONTROLLER_STATE.READY; } break; } }