static void setInitSchedule() { Set<BarName> cmd1 = new Set<BarName>(); cmd1 = cmd1.Add("sample-microphone"); cmd1 = cmd1.Add("read-commands"); Bar bar1 = new Bar("start",1000.0, inf, cmd1, 0, inf, 1); schedule = schedule.Add("start", bar1); Set<BarName> cmd2 = new Set<BarName>(); cmd2 = cmd2.Add("filter"); Bar bar2 = new Bar("sample-microphone",1.0, 20.0, cmd2, 0, inf, (int)inf); schedule = schedule.Add("sample-microphone", bar2); Set<BarName> cmd3 = new Set<BarName>(); cmd3 = cmd3.Add("fft-start"); Bar bar3 = new Bar("filter",1.0, inf, cmd3, 0, inf, (int)inf); schedule = schedule.Add("filter", bar3); Set<BarName> cmd4 = new Set<BarName>(); cmd4 = cmd4.Add("fft"); Bar bar4 = new Bar("fft-start",10.0, inf, cmd4, 0, inf, (int)inf); schedule = schedule.Add("fft-start", bar4); Set<BarName> cmd5 = new Set<BarName>(); cmd5 = cmd5.Add("fft"); cmd5 = cmd5.Add("send-bytes"); Bar bar5 = new Bar("fft",10.0, inf, cmd5, 0, inf, 10); schedule = schedule.Add("fft", bar5); Set<BarName> cmd6 = new Set<BarName>(); Bar bar6 = new Bar("send-bytes",0.2, 1, cmd6, 0, inf, 4); schedule = schedule.Add("send-bytes", bar6); Set<BarName> cmd7 = new Set<BarName>(); Bar bar7 = new Bar("read-commands",1, 10, cmd7, 0, inf, (int)inf); schedule = schedule.Add("read-command", bar7); //state = SchedulerState.WAITING; }
static void UpdateReadyQueue(Bar b, int currentTime) { readyQueue = readyQueue.RemoveKey(currentTime); foreach (Bar b1 in schedule.Values) { if (b.triggers.Contains(b1.name)) { if (readyQueue.ContainsKey(currentTime + (int)b.duration)){ Set<Bar> bars = readyQueue[currentTime+(int)b.duration]; readyQueue = readyQueue.RemoveKey(currentTime+(int)b.duration); readyQueue = readyQueue.Add(currentTime + (int)b.duration,bars.Add(b1)); } else readyQueue = readyQueue.Add(currentTime + (int)b.duration, new Set<Bar>(b1)); } } if (b.offset < Scheduler.inf) if (readyQueue.ContainsKey(currentTime + (int)b.offset)) { Set<Bar> bars = readyQueue[currentTime + (int)b.offset]; readyQueue = readyQueue.RemoveKey(currentTime + (int)b.offset); readyQueue = readyQueue.Add(currentTime + (int)b.offset, bars.Add(b)); } else readyQueue = readyQueue.Add(currentTime + (int)b.offset, new Set<Bar>(b)); }
static void Match(Bar b) { Set<Bar> readyBars; if (Scheduler.readyQueue.ContainsKey(TimeUpdate.time)) { readyBars = Scheduler.readyQueue[TimeUpdate.time]; if (readyBars.Contains(b)) { currentBar = new Set<Bar> (b); switch (state) { case ProcessState.MATCH: state = ProcessState.PREWAIT; break; case ProcessState.REMATCH: state = ProcessState.REWAIT; break; } } else state = ProcessState.COMPLETE; } else state = ProcessState.COMPLETE; }