public EarleySet(int location) { _predictions = new StateQueue(); _scans = new StateQueue(); _completions = new StateQueue(); _transitions = new StateQueue(); Location = location; }
public void DislodgeCurState(Func<object[], bool> State, int Frequency = -1, params object[] Params) { if (CurState != null) { States.AddLast(CurState); } CurState = new StateQueue(State, ((Frequency == -1) ? DefaultFrequency : Frequency), Params); }
/// <summary> /// Queue a new state, pushing the current state back into the queue /// </summary> /// <param name="State">The boolean function to process</param> /// <param name="Frequency">The frequency to use in milliseconds: defaults to -1, which uses the currently defined Default Frequency</param> /// <param name="Params">Array of objects to pass to the boolean function</param> public void DislodgeCurState(Func <object[], bool> State, int Frequency = -1, params object[] Params) { if (CurState != null) { States.AddLast(CurState); } CurState = new StateQueue(State, ((Frequency == -1) ? DefaultFrequency : Frequency), Params); }
public void InsertState(Func<object[], bool> State, int Frequency = -1, params object[] Params) { States.AddLast(new StateQueue(State, ((Frequency == -1) ? DefaultFrequency : Frequency), Params)); if (CurState == null) { CurState = States.Last(); States.RemoveLast(); } }
public void ClearCurState() { CurState = null; if (States.Count > 0) { CurState = States.Last(); States.RemoveLast(); } }
public string StopCrawler() { StopQueue = CloudConfiguration.GetStopQueue(); StateQueue = CloudConfiguration.GetStateQueue(); if (StopQueue.PeekMessage() == null) { CloudQueueMessage stopSignal = new CloudQueueMessage("stop"); StopQueue.AddMessage(stopSignal); if (StateQueue.PeekMessage() != null) { StateQueue.DeleteMessage(StateQueue.GetMessage()); } CloudQueueMessage state = new CloudQueueMessage("Idle"); StateQueue.AddMessage(state); } return("stopped crawling"); }
public void ExitStateCallback(T owner) { // If we have states queued, enter the next state on that list if (StateQueue.Count > 0) { State <T> state = StateQueue[0]; StateQueue.RemoveAt(0); UpdateStateHistory(); currentState = null; ChangeState(state); } // If we don't have states queued trigger the OnStateFinish event that the owner can react to else if (OnStateFinish != null) { UpdateStateHistory(); currentState = null; OnStateFinish?.Invoke(); } }
public void Clear() { States.Clear(); CurState = null; }
void OnFrame(object sender, EventArgs e) { Random Delta = new Random(); if (DateTime.Now > NextPulse.AddMilliseconds(Delta.Next(100))) { if (CurState != null && Session.Safe && Session.NextSessionChange < Session.Now) { if (CurState.State(CurState.Params)) { if (States.Count > 0) { CurState = States.Last(); States.RemoveLast(); } else { CurState = null; } } } if (CurState == null) { NextPulse = DateTime.Now.AddMilliseconds(DefaultFrequency); } else { NextPulse = DateTime.Now.AddMilliseconds(CurState.Frequency); } } }
public void QueueState(State <T> state) { StateQueue.Add(state); }
public static void InitializeTCPserver(MainModel model) { _model = model; _model.PropertyChanged += ModelChanged; Task.Run(() => { Task.Run(() => { while (ServerAlive) { try { Server1 = new TcpListener(IPAddress.Any, 2111); Server1.Stop(); Server1.Start(); break; } catch { } Thread.Sleep(100); } try { Server1.BeginAcceptTcpClient(new AsyncCallback(OMWinforming), Server1); } catch { } }); Task.Run(() => { while (ServerAlive) { try { Server2 = new TcpListener(IPAddress.Any, 2112); Server2.Stop(); Server2.Start(); break; } catch { } Thread.Sleep(100); } try { if (ServerAlive) { using (TcpClient client = Server2.AcceptTcpClient()) { using (NetworkStream stream = client.GetStream()) { try { OMWsendState(client, stream, (new ControlStruct { Profile = _model.Profile, Logging = _model.Loggong, InfPowerLimits = _model.InfPowerLimits, InfCoreClocks = _model.InfCoreClocks, InfMemoryClocks = _model.InfMemoryClocks, InfOHMCoreClocks = _model.InfOHMCoreClocks, InfOHMMemoryClocks = _model.InfOHMMemoryClocks, InfFanSpeeds = _model.InfFanSpeeds, InfTemperatures = _model.InfTemperatures, InfHashrates = _model.InfHashrates, TotalHashrate = _model.TotalHashrate, WachdogInfo = _model.WachdogInfo, LowHWachdog = _model.LowHWachdog, IdleWachdog = _model.IdleWachdog, Indication = _model.Indicator, Algoritms = _model.Algoritms, Miners = _model.Miners, DefClock = _model.DefClock, }, ContolStateType.ControlStruct)); } catch { } Task.Run(() => { // Отправление статистики while (ServerAlive) { try { Server3 = new TcpListener(IPAddress.Any, 2113); Server3.Stop(); Server3.Start(); break; } catch { } Thread.Sleep(100); } try { using (var statclient = Server3.AcceptTcpClient()) { using (var statstream = statclient.GetStream()) { StateServerActive = true; (object, ContolStateType)? q; while (statclient.Connected && ServerAlive) { q = null; lock (ContolStateKey) { if (StateQueue.Count > 0) { q = StateQueue[0]; StateQueue.RemoveAt(0); } } if (q != null) { OMWsendState(statclient, statstream, q.Value); } Thread.Sleep(100); } StateServerActive = false; lock (ContolStateKey) StateQueue.Clear(); } } } finally { Server3.Stop(); } }); string message; while (client.Connected && ServerAlive) { RootObject RO; try { message = ReadMessage(stream); RO = JsonConvert.DeserializeObject <RootObject>(message, Convs); if (RO != null) { Task.Run(() => OMWsent?.Invoke(RO)); } } catch { } Thread.Sleep(100); } } } } } catch { } }); Task.Run(() => { while (ServerAlive) { try { Server4 = new TcpListener(IPAddress.Any, 2114); Server4.Stop(); Server4.Start(); break; } catch { } Thread.Sleep(100); } try { while (ServerAlive) { using (TcpClient client = Server4.AcceptTcpClient()) { using (NetworkStream stream = client.GetStream()) { stream.Write(new byte[] { 1 }, 0, 1); } } } } catch { } }); }); }