public void Dispose_should_throw_if_child_loops_not_disposed() { using (var loop = new Loop(Times.Once())) { loop.CreateLoop(Times.Exactly(2)); } }
BlockingTcpListener(Loop loop) : base(loop) { TcpListener = new TcpListener(loop); Listener = TcpListener as Listener; Handle = TcpListener; }
public IEnumerator Routine(Loop loop,float loopTime) { if (loop.actionDictionary.Count > 0) { List<Action> actionList = new List<Action>(); actionList.AddRange(loop.actionDictionary.Values); while (runningLoop) { foreach (Action action in actionList) switch (action.actionType) { case Action.ActionTypes.Move: Move move = (Move)action; move.ExecuteAction(this.gameObject); break; default: CodeInputHandler.abortPlay("type failed ! check your action type - 66 action.cs "); runningLoop = false; break; } yield return new WaitForSeconds(loopTime); } } else { yield return new WaitForSeconds(loopTime); } }
public override void Compile(ByteCode bc) { var L = new Loop { Scope = m_StackFrame }; bc.PushSourceRef(m_Repeat); bc.LoopTracker.Loops.Push(L); var start = bc.GetJumpPointForNextInstruction(); bc.Emit_Enter(m_StackFrame); m_Block.Compile(bc); bc.PopSourceRef(); bc.PushSourceRef(m_Until); bc.Emit_Debug("..end"); m_Condition.Compile(bc); bc.Emit_Leave(m_StackFrame); bc.Emit_Jump(OpCode.Jf, start); bc.LoopTracker.Loops.Pop(); var exitpoint = bc.GetJumpPointForNextInstruction(); foreach (var i in L.BreakJumps) i.NumVal = exitpoint; bc.PopSourceRef(); }
BlockingPipeListener(Loop loop) : base(loop) { PipeListener = new PipeListener(loop); Listener = PipeListener as Listener; Handle = PipeListener; }
public PrepareWatcher(Loop loop, Action<PrepareWatcher, EventTypes> callback) : base(loop) { this.callback = callback; watcher_ptr = manos_prepare_watcher_create (unmanaged_callback, GCHandle.ToIntPtr (gc_handle)); }
void Awake() { _source = GetComponent<AudioSource>(); _current = loops[0]; _source.clip = _current.clips[0]; _receiverVolume = GetComponent<ReceiverVolume>(); }
private EdiMapping(XDocument xml) { if (xml.Root == null) throw new Exception("XML is missing a root element."); Errors = new List<string>(); _root = ReadLoop(xml.Root); }
public void Dispose_should_do_nothing_if_called_multiple_times() { using (var loop = new Loop(Times.Once())) { loop.Dispose(); loop.Dispose(); } }
public FlatLoop(Loop sourceLoop, FlatFace flatFace) { this.sourceLoop = sourceLoop; this.flatFace = flatFace; fins = new List<FlatFin>(); foreach (Fin fin in sourceLoop.Fins) fins.Add(new FlatFin(this, fin)); }
public MicroThread(Loop loop, Action callback) { Loop = loop; State = MicroThreadState.NotStarted; Loop.GetMicroThreadCollection().Add(this); cb = callback; }
public void A_new_step_should_be_added_directly_if_it_contains_no_child_loops() { using (var loop = new Loop(Times.Once())) { var step = loop.CreateStep("", Times.Once()); Assert.That(loop.Steps.Contains(step)); } }
public void A_new_loop_should_be_added_directly_if_it_contains_no_child_loops() { using (var loop = new Loop(Times.Once())) { using (var child = loop.CreateLoop(Times.Once())) { Assert.That(loop.Steps.Contains(child)); } } }
public static void Compute(Loop loop, string file) { var @in = new UVFileStream(loop); @in.Open(file, UVFileAccess.Read, (ex) => { HashStream.ComputeString(SHA1Managed.Create(), @in, (str) => { Console.WriteLine ("{0} {1}", str, file); }); @in.Resume(); }); }
public void InvalidRange() { var stringlit = new StringLiteral("foo", 0); var range = new Range(stringlit, stringlit, 0); var variabledecl = new VariableDeclaration("foo", "int", 0); var variable = new VariableReference("foo", 0); var loop = new Loop(variable, range, new List<Statement>(), 0); statementlist.Add(variabledecl); statementlist.Add(loop); var parsetree = new Program(statementlist); Assert.Throws<SemanticError>(() => symbolTableBuilder.BuildSymbolTableAndTypeCheck(parsetree)); }
public void visit(Loop node) { if (symboltable.resolve(node.VarName).Type != "int") throw new SemanticError("Loop variable " + node.VarName + " on row " + node.Row + " is not an int."); for (int i = 0; i < 2; i++) { // Check twice to prevent variable declarations inside the loop body // (would cause problems because of singular scope). foreach (Statement statement in node.LoopBody) statement.accept(this); } }
//------------------------------------------------------------------ protected Driver(Car car) : base(car) { Loop = new Loop(); Sequence = new Sequence(); AddInLoop (Sequence); Car = car; Velocity = Car.Lane.Velocity; ChangeLaneSpeed = 1; SafeZone = new SafeZone (this, 1); Primary = Direction.Left; }
public void NonIntegerLoopVariable(string type) { var variabledecl = new VariableDeclaration("foo", type, 0); statementlist.Add(variabledecl); var variable = new VariableReference("foo", 0); var integer = new IntegerLiteral("5", 0); var range = new Range(integer, integer, 0); var variabledecl2 = new VariableDeclaration("bar", "int", 0); var loopbody = new List<Statement>(); loopbody.Add(variabledecl2); var loop = new Loop(variable, range, loopbody, 0); statementlist.Add(loop); var parsetree = new Program(statementlist); Assert.Throws<SemanticError>(() => symbolTableBuilder.BuildSymbolTableAndTypeCheck(parsetree)); }
public static Task Create(Loop loop, string name, int mode) { var tcs = new TaskCompletionSource<object>(); try { UVDirectory.Create(loop, name, mode, (e) => { if (e == null) { tcs.SetResult(null); } else { tcs.SetException(e); } }); } catch (Exception e) { tcs.SetException(e); } return tcs.Task; }
public static Task Delete(Loop loop, string path) { var tcs = new TaskCompletionSource<object>(); try { UVDirectory.Delete(loop, path, (e) => { if (e == null) { tcs.SetResult(null); } else { tcs.SetException(e); } }); } catch (Exception e) { tcs.SetException(e); } return tcs.Task; }
public override void Compile(ByteCode bc) { bc.PushSourceRef(m_RefFor); Loop L = new Loop() { Scope = m_StackFrame }; bc.LoopTracker.Loops.Push(L); m_End.Compile(bc); bc.Emit_ToNum(3); m_Step.Compile(bc); bc.Emit_ToNum(2); m_Start.Compile(bc); bc.Emit_ToNum(1); int start = bc.GetJumpPointForNextInstruction(); var jumpend = bc.Emit_Jump(OpCode.JFor, -1); bc.Emit_Enter(m_StackFrame); //bc.Emit_SymStorN(m_VarName); bc.Emit_Store(m_VarName, 0, 0); m_InnerBlock.Compile(bc); bc.PopSourceRef(); bc.PushSourceRef(m_RefEnd); bc.Emit_Debug("..end"); bc.Emit_Leave(m_StackFrame); bc.Emit_Incr(1); bc.Emit_Jump(OpCode.Jump, start); bc.LoopTracker.Loops.Pop(); int exitpoint = bc.GetJumpPointForNextInstruction(); foreach (Instruction i in L.BreakJumps) i.NumVal = exitpoint; jumpend.NumVal = exitpoint; bc.Emit_Pop(3); bc.PopSourceRef(); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Loop loop = new Loop(); loop.Run(doc); return Result.Success; // TODO: start here modifying the behaviour of your command. // --- RhinoApp.WriteLine("The {0} command will add a line right now.", EnglishName); Point3d pt0; using (GetPoint getPointAction = new GetPoint()) { getPointAction.SetCommandPrompt("Please select the start point"); if (getPointAction.Get() != GetResult.Point) { RhinoApp.WriteLine("No start point was selected."); return getPointAction.CommandResult(); } pt0 = getPointAction.Point(); } Point3d pt1; using (GetPoint getPointAction = new GetPoint()) { getPointAction.SetCommandPrompt("Please select the end point"); getPointAction.SetBasePoint(pt0, true); getPointAction.DynamicDraw += (sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed); if (getPointAction.Get() != GetResult.Point) { RhinoApp.WriteLine("No end point was selected."); return getPointAction.CommandResult(); } pt1 = getPointAction.Point(); } doc.Objects.AddLine(pt0, pt1); doc.Views.Redraw(); RhinoApp.WriteLine("The {0} command added one line to the document.", EnglishName); // --- return Result.Success; }
public static void Execute(Loop loop) { loop.Run(async delegate { try { await loop.Async(() => Directory.CreateDirectory("testing")); await loop.Async(() => Directory.Move("testing", "testing123")); var dirs = await loop.FAsync(() => Directory.GetFiles("./")); Console.WriteLine("{0} files.", dirs.Length); Console.WriteLine(); foreach (var dir in dirs) { Console.WriteLine(dir); } await loop.Async(() => Directory.Delete("testing123")); } catch (Exception e) { Console.WriteLine(e); } }); }
public LoopAdorner(TextBox adornedElement, Loop loop) : base(adornedElement) { this.children = new VisualCollection (this); this.children.Add (this.border); this.iterations = loop.Operations.OfType<LoopIteration>().ToArray(); var grid = new Grid(); grid.ColumnDefinitions.Add (new ColumnDefinition()); grid.ColumnDefinitions.Add (new ColumnDefinition()); grid.ColumnDefinitions.Add (new ColumnDefinition()); grid.Background = Brushes.White; this.previous = new Button(); this.previous.Content = "<"; this.previous.Background = Brushes.Transparent; this.previous.Click += OnPreviousClick; Grid.SetColumn (this.previous, 0); grid.Children.Add (this.previous); this.text = new TextBlock(); this.text.FontSize = adornedElement.FontSize * 0.8; this.text.Padding = new Thickness (5, 0, 5, 0); Grid.SetColumn (this.text, 1); grid.Children.Add (this.text); this.next = new Button(); this.next.Content = ">"; this.next.Background = Brushes.Transparent; this.next.Click += OnNextClick; Grid.SetColumn (this.next, 2); grid.Children.Add (this.next); this.border.Child = grid; Update(); }
public void A_new_loop_should_be_added_to_most_recently_created_child_loop() { using (var loop = new Loop(Times.Once())) { using (var child1 = loop.CreateLoop(Times.Once())) { using (loop.CreateLoop(Times.Once())) { } using (var child2 = loop.CreateLoop(Times.Once())) { Assert.That(child1.Steps.Contains(child2)); using (var child3 = loop.CreateLoop(Times.Once())) { Assert.That(child2.Steps.Contains(child3)); } } } } }
public override void Compile(ByteCode bc) { Loop L = new Loop() { Scope = m_StackFrame }; bc.LoopTracker.Loops.Push(L); bc.PushSourceRef(m_Start); int start = bc.GetJumpPointForNextInstruction(); m_Condition.Compile(bc); var jumpend = bc.Emit_Jump(OpCode.Jf, -1); bc.Emit_Enter(m_StackFrame); m_Block.Compile(bc); bc.PopSourceRef(); bc.Emit_Debug("..end"); bc.PushSourceRef(m_End); bc.Emit_Leave(m_StackFrame); bc.Emit_Jump(OpCode.Jump, start); bc.LoopTracker.Loops.Pop(); int exitpoint = bc.GetJumpPointForNextInstruction(); foreach (Instruction i in L.BreakJumps) i.NumVal = exitpoint; jumpend.NumVal = exitpoint; bc.PopSourceRef(); }
public void A_new_step_should_be_added_to_most_recently_created_child_loop() { using (var loop = new Loop(Times.Once())) { using (loop.CreateLoop(Times.Once())) { using (loop.CreateLoop(Times.Once())) { } using (var child2 = loop.CreateLoop(Times.Once())) { var step2 = loop.CreateStep("", Times.Once()); Assert.That(child2.Steps.Contains(step2)); using (var child3 = loop.CreateLoop(Times.Once())) { var step3 = loop.CreateStep("", Times.Once()); Assert.That(child3.Steps.Contains(step3)); } } } } }
/// <summary> /// /// </summary> /// <param name="loop"></param> /// <param name="settings"></param> protected Server(Loop loop, ISettings settings) { _loop = loop; _settings = settings; if (string.IsNullOrEmpty(_settings.ip)) _endpoint = new IPEndPoint(IPAddress.IPv6Any, _settings.port); else if (string.Equals(_settings.ip.Trim(), "localhost", StringComparison.OrdinalIgnoreCase)) _endpoint = new IPEndPoint(IPAddress.IPv6Loopback, _settings.port); else _endpoint = new IPEndPoint(IPAddress.Parse(_settings.ip), _settings.port); _accepts = new SocketAsyncEventArgs[Math.Min(_settings.backlog, (int)SocketOptionName.MaxConnections)]; EventHandler<SocketAsyncEventArgs> completed = (sender, args) => { ProcessAccept(args); }; for (int i = 0; i < _accepts.Length; ++i) { SocketAsyncEventArgs args = new SocketAsyncEventArgs(); args.Completed += completed; _accepts[i] = args; } _started = false; Init(); }
/// <summary>通过ID查找该流程中的任意元素</summary> /// <param name="id">元素的Id</param> /// <returns>流程元素,如:Activity,Task,Synchronizer等等</returns> public IWFElement findWFElementById(String id) { if (this.Id.Equals(id)) { return(this); } List <Task> tasksList = this.Tasks; for (int i = 0; i < tasksList.Count; i++) { Task task = (Task)tasksList[i]; if (task.Id.Equals(id)) { return(task); } } List <Activity> activityList = this.Activities; for (int i = 0; i < activityList.Count; i++) { Activity activity = activityList[i]; if (activity.Id.Equals(id)) { return(activity); } List <Task> taskList = activity.getTasks(); for (int j = 0; j < taskList.Count; j++) { Task task = taskList[j]; if (task.Id.Equals(id)) { return(task); } } } if (this.StartNode.Id.Equals(id)) { return(this.StartNode); } List <Synchronizer> synchronizerList = this.Synchronizers; for (int i = 0; i < synchronizerList.Count; i++) { Synchronizer synchronizer = synchronizerList[i]; if (synchronizer.Id.Equals(id)) { return(synchronizer); } } List <EndNode> endNodeList = this.EndNodes; for (int i = 0; i < endNodeList.Count; i++) { EndNode endNode = endNodeList[i]; if (endNode.Id.Equals(id)) { return(endNode); } } List <Transition> transitionList = this.Transitions; for (int i = 0; i < transitionList.Count; i++) { Transition transition = transitionList[i]; if (transition.Id.Equals(id)) { return(transition); } } List <DataField> dataFieldList = this.DataFields; for (int i = 0; i < dataFieldList.Count; i++) { DataField dataField = dataFieldList[i]; if (dataField.Id.Equals(id)) { return(dataField); } } List <Loop> loopList = this.Loops; for (int i = 0; i < loopList.Count; i++) { Loop loop = loopList[i]; if (loop.Id.Equals(id)) { return(loop); } } return(null); }
/// Finds all the switch statements within a list of blocks public static List <SwitchStatement> Find(DecompileContext ctx) { List <SwitchStatement> res = new List <SwitchStatement>(); foreach (Block b in ctx.Blocks.List) { if (b.Instructions.Count >= 1) { var instr = b.Instructions[0]; if (instr.Kind == Instruction.Opcode.Popz) { // This is most likely the end of a switch statement (repeat loops already abstracted out anyway) // It only can't be if this is inside another switch and we exit the script Block header = null; Block continueBlock = null; Block endCasesBranch = null; Block defaultCaseBranch = null; List <Block> caseBranches = new List <Block>(); bool empty; if (b.Predecessors.Count == 1) { header = (Block)b.Predecessors[0]; empty = true; // Do check for exit if (b.Instructions.Count >= 2 && b.Instructions[^ 1].Kind == Instruction.Opcode.Exit) { bool allPopz = true; for (int i = 1; i < b.Instructions.Count - 1; i++) { allPopz &= b.Instructions[i].Kind == Instruction.Opcode.Popz; } if (allPopz) { // Abort. This isn't a switch statement; it's an exit inside of another switch continue; } } } else { empty = false; // Do check for exit if (b.Instructions.Count > 2 && b.Instructions[^ 1].Kind == Instruction.Opcode.Exit) { bool shouldAbort = true; for (int i = 0; i < b.Instructions.Count - 1; i++) { if (b.Instructions[i].Kind != Instruction.Opcode.Popz) { shouldAbort = false; } } if (shouldAbort) { // Abort. This isn't a switch statement; it's an exit inside of other switches/repeats continue; } } // Find the end of the chain of cases (using "header" as a temporary variable here) for (int i = 0; i < b.Predecessors.Count; i++) { if ((b.Predecessors[i] as Block)?.LastInstr.Kind == Instruction.Opcode.B) { header = b.Predecessors[i] as Block; break; } } // Work backwards to the first one in this statement while (header.Index > 0) { Block next = ctx.Blocks.List[header.Index - 1]; if (next.Instructions.Count >= 1 && next.Instructions[^ 1].Kind == Instruction.Opcode.B && next.Branches[0].Address <= b.Address) { header = next; } else { break; } } endCasesBranch = header; // Go backwards, searching for the real header int startCaseBodies = int.MaxValue; while (header.Index > 0) { Block next = ctx.Blocks.List[header.Index - 1]; if (next.Instructions.Count >= 4 && next.Instructions[^ 1].Kind == Instruction.Opcode.Bt) { startCaseBodies = Math.Min(startCaseBodies, next.Branches[0].Address); caseBranches.Add(next); header = next; } else { break; } } caseBranches.Reverse(); // They're in the wrong order, so reverse the list // Check if this switch has a default case or not, and register it if (endCasesBranch.Index + 1 < ctx.Blocks.List.Count) { Block maybeRealEnd = ctx.Blocks.List[endCasesBranch.Index + 1]; if (maybeRealEnd.Address < startCaseBodies && maybeRealEnd.Instructions.Count == 1 && maybeRealEnd.Instructions[0].Kind == Instruction.Opcode.B) { defaultCaseBranch = endCasesBranch; // The end case branch is actually one further here endCasesBranch = maybeRealEnd; } } // Also check if there's a continue block right before the tail if (b.Index > 0 && ctx.Blocks.List[b.Index - 1].ControlFlow == Block.ControlFlowType.Continue) { continueBlock = ctx.Blocks.List[b.Index - 1]; } } // Find surrounding loop for later Loop surroundingLoop = null; foreach (var loop in ctx.LoopNodes) { if (loop.Address < header.Address && loop.EndAddress > header.Address && (surroundingLoop == null || loop.Address > surroundingLoop.Address)) { surroundingLoop = loop; } } res.Add(new SwitchStatement(header, b, empty, caseBranches, defaultCaseBranch, endCasesBranch, continueBlock, surroundingLoop)); } } } // Get into order we want to process (top to bottom, inner to outer), and return return(res.OrderBy(s => s.EndAddress).ThenByDescending(s => s.Address).ToList()); }
public void Init(Loop loop, Tcp tcp, IComponentContext ctx, IMasterClock clock, (IPEndPoint IPEndPoint, TcpProxyProtocolConfig ProxyProtocol) endpointConfig, string connectionId,
public TypedLoopLIN(Loop loop) : base(loop) { }
public void OnConnected() { lock (manager.sockets) { manager.sockets.Add(this, true); } new Thread(delegate() { Thread.CurrentThread.Name = "Network Read"; byte[] bytes = new byte[64 * 1024]; while (manager.running) { bool result; try { result = Socket.Poll(-1, SelectMode.SelectRead); } catch (ObjectDisposedException) { lock (manager.sockets) { manager.sockets.Remove(this); } break; } if (result) { int total = 0; try { while (Socket.Available > 0) { int length = Socket.Receive(bytes); if (length == 0) { break; } total += length; OnReceive(bytes, length); } if (total == 0) { Close(); break; } } catch (SocketException e) { if (e.SocketErrorCode == SocketError.ConnectionReset || e.SocketErrorCode == SocketError.ConnectionAborted || e.SocketErrorCode == SocketError.NotConnected || e.SocketErrorCode == SocketError.Shutdown) { Close(); break; } if (manager.settings.events.exception != null) { Loop.Run(() => { if (manager.settings.events.exception != null) { manager.settings.events.exception(this, e); } }); } } catch (ObjectDisposedException) { lock (manager.sockets) { manager.sockets.Remove(this); } break; } catch (Exception e) { if (manager.settings.events.exception != null) { Loop.Run(() => { if (manager.settings.events.exception != null) { manager.settings.events.exception(this, e); } }); } } if (total != 0 && manager.settings.events.read != null) { Loop.Run(() => { if (manager.settings.events.read != null) { manager.settings.events.read(this, total); } }); } } } }).Start(); }
public void SetLoop(Loop loop) { _control.SetLoop(loop); }
public void Listen(int port, Action <NetHandler> callback) { if (!running) { throw new ObjectDisposedException(ToString()); } new Thread(delegate() { Thread.CurrentThread.Name = "Network Server"; TcpListener server = new TcpListener(IPAddress.Any, port); server.Start(); Control ctrl; lock (listens) { if (listens.TryGetValue(port, out ctrl)) { ctrl.running = true; } else { ctrl = new Control { running = true }; listens[port] = ctrl; } } ctrl.action = callback; while (running) { if (!server.Server.Poll(1000, SelectMode.SelectRead)) { if (!ctrl.running) { break; } continue; } if (!server.Pending()) { break; } NetHandlerImpl socket = new NetHandlerImpl(server.AcceptSocket(), this); socket.Socket.Blocking = false; socket.OnConnected(); Loop.Run(() => { ctrl.action(socket); }); } lock (listens) { Control ctrlnow; if (listens.TryGetValue(port, out ctrlnow) && ctrlnow == ctrl) { listens.Remove(port); } } server.Stop(); }).Start(); new Thread(delegate() { Thread.CurrentThread.Name = "Network Server"; TcpListener server = new TcpListener(IPAddress.IPv6Any, port); server.Start(); Control ctrl; lock (listensv6) { if (listensv6.TryGetValue(port, out ctrl)) { ctrl.running = true; } else { ctrl = new Control { running = true }; listensv6[port] = ctrl; } } ctrl.action = callback; while (running) { if (!server.Server.Poll(1000, SelectMode.SelectRead)) { if (!ctrl.running) { break; } continue; } if (!server.Pending()) { break; } NetHandlerImpl socket = new NetHandlerImpl(server.AcceptSocket(), this); socket.Socket.Blocking = false; socket.OnConnected(); Loop.Run(() => { ctrl.action(socket); }); } lock (listensv6) { Control ctrlnow; if (listensv6.TryGetValue(port, out ctrlnow) && ctrlnow == ctrl) { listensv6.Remove(port); } } server.Stop(); }).Start(); }
public static void Initialize() { Loop.Initialize(); }
public void Configure(Player player, Loop loop) { this.player = player; Configure(loop); }
//------------------------------------------------------------------ public override void Disable() { base.Disable(); timer = null; }
/// <summary> /// パースします /// </summary> /// <param name="fileContents"></param> void ParsePma(string fileContents) { var indexDataOffset = fileContents.IndexOf("データ="); if (indexDataOffset < 0) { Debug.LogError("想定外のデータのためクローズ"); return; } var contenText = fileContents.Substring(indexDataOffset + "データ=".Length); Debug.Log("解析対象のデータは:" + contenText); //ゴミデータ、かどうか分からないけど解析できないデータ群と、単純なモーション群に分けてパースしていきたい。 //モーションファイルは順に追いかけて行って "02"から4文字空けたら"03"があって、また4文字空けたら"04"があったらモーションデータ、と仮定する素朴な実装で一旦やってみます。 //まずは半角スペースで分割した文字列を得ます。 var hexByteArray = contenText.Split(' '); var tailIndex = hexByteArray.Length; var headIndex = 0; var seekIndex = headIndex; Debug.Log(tailIndex + "個のhexがあります"); int frameCounter = 0; totalKomas = 0; var loops = new Stack <Loop>(); // ループ情報。読み込み中に都度都度増減する _frames.Clear(); //ここからhex文字列の配列からパースしていきます。 while (seekIndex < tailIndex) { //50 18 から始まるのがモーションデータ作法 if (hexByteArray[seekIndex] == "50" && (seekIndex + 6 < tailIndex) && hexByteArray[seekIndex + 1] == "18") { //ガガッとフレームパースしますよ~~ //なんも考えずにspanでarray渡そうかな~ 末尾に50 18 が大体ついてそう 25サーボ*3データで75個分を抜き出すと良い? string[] servoArray = hexByteArray.Skip(seekIndex).Take(0x50).ToArray(); var parsedFrame = ParseOneFrame(servoArray); if (parsedFrame != null) { parsedFrame.frameNumber = _frames.Count; _frames.Add(parsedFrame); totalKomas += parsedFrame.wait; //Debug.Log(frameCounter + " : " + parsedFrame.frameWait + " : " + parsedFrame.wait); } frameCounter++; seekIndex += 0x50; } // ループ始点 else if (hexByteArray[seekIndex] == "08" && (seekIndex + 7 < tailIndex) && hexByteArray[seekIndex + 1] == "02") { string[] commandArray = hexByteArray.Skip(seekIndex).Take(0x08).ToArray(); Loop loop = new Loop(); loop.iteration = HexToInt(commandArray[5]); // ここが繰り返し回数? loop.startKeyFrameIndex = _frames.Count - 1; // ループ始点となるキーフレーム番号 loops.Push(loop); seekIndex += 0x08; } // ループ終点 else if (hexByteArray[seekIndex] == "08" && (seekIndex + 7 < tailIndex) && hexByteArray[seekIndex + 1] == "07") { string[] commandArray = hexByteArray.Skip(seekIndex).Take(0x08).ToArray(); InterpretLoop(loops.Pop()); seekIndex += 0x08; } else { seekIndex++; } } Debug.Log("合計:" + frameCounter + "個のキーフレームがありました"); Debug.Log("合計:" + totalKomas + "個のフレームがありました"); }
private static Solid Representations(this IfcProduct product) { var reps = product.Representation.Representations.SelectMany(r => r.Items); foreach (var r in reps) { if (r is IfcSurfaceCurveSweptAreaSolid) { throw new Exception("IfcSurfaceCurveSweptAreaSolid is not supported yet."); } if (r is IfcRevolvedAreaSolid) { throw new Exception("IfcRevolvedAreaSolid is not supported yet."); } if (r is IfcSweptDiskSolid) { throw new Exception("IfcSweptDiskSolid is not supported yet."); } else if (r is IfcExtrudedAreaSolid) { var eas = (IfcExtrudedAreaSolid)r; var profileDef = (IfcArbitraryClosedProfileDef)eas.SweptArea; var pline = (IfcPolyline)profileDef.OuterCurve; var outline = pline.ToPolygon(true); var solid = Solid.SweepFace(outline, null, (IfcLengthMeasure)eas.Depth); } else if (r is IfcFacetedBrep) { var solid = new Solid(); var fbr = (IfcFacetedBrep)r; var shell = fbr.Outer; var faces = new Face[shell.CfsFaces.Count]; for (var i = 0; i < shell.CfsFaces.Count; i++) { var f = shell.CfsFaces[i]; var boundCount = 0; Loop outer = null; Loop[] inner = new Loop[f.Bounds.Count - 1]; foreach (var b in f.Bounds) { var loop = (IfcPolyLoop)b.Bound; var newLoop = loop.Polygon.ToLoop(solid); if (boundCount == 0) { outer = newLoop; } else { inner[boundCount - 1] = newLoop; } boundCount++; } solid.AddFace(outer, inner); } return(solid); } else if (r is IfcFacetedBrepWithVoids) { throw new Exception("IfcFacetedBrepWithVoids is not supported yet."); } } return(null); }
void OnClosed(Idle handle) { handle.Dispose(); this.loop?.Dispose(); this.loop = null; }
public void Dispose() { Loop?.Dispose(); }
public UdpIPv6Tests() { this.loop = new Loop(); }
public void initInventory() { inventorySkills = new baseSkill[14]; inventorySkills [0] = new Arrays (); inventorySkills [1] = new BreakAndContinue (); inventorySkills [2] = new DDOS (); inventorySkills [3] = new DefaultFunctions (); inventorySkills [4] = new FireWall (); inventorySkills [5] = new FunctionsWithInputOutput (); inventorySkills [6] = new FunctionsWithOutput (); inventorySkills [7] = new Hash (); inventorySkills [8] = new IfElse (); inventorySkills [9] = new InfiniteLoop (); inventorySkills [10] = new Loop (); inventorySkills [11] = new PacketSniffing (); inventorySkills [12] = new Recursion (); inventorySkills [13] = new Stack (); Debug.Log ("Finished Loading Inventory"); }
public List <Interchange> ParseMultiple(Stream stream, Encoding encoding) { var envelopes = new List <Interchange>(); using (X12StreamReader reader = new X12StreamReader(stream, encoding, _ignoredChars)) { Interchange envelop = new Interchange(_specFinder, reader.CurrentIsaSegment); envelopes.Add(envelop); Container currentContainer = envelop; FunctionGroup fg = null; Transaction tr = null; Dictionary <string, HierarchicalLoop> hloops = new Dictionary <string, HierarchicalLoop>(); string segmentString = reader.ReadNextSegment(); string segmentId = reader.ReadSegmentId(segmentString); int segmentIndex = 1; Stack <string> containerStack = new Stack <string>(); while (segmentString.Length > 0) { switch (segmentId) { case "ISA": envelop = new Interchange(_specFinder, segmentString + reader.Delimiters.SegmentTerminator); envelopes.Add(envelop); currentContainer = envelop; fg = null; tr = null; hloops = new Dictionary <string, HierarchicalLoop>(); break; case "IEA": if (envelop == null) { throw new InvalidOperationException(string.Format("Segment {0} does not have a matching ISA segment preceding it.", segmentString)); } envelop.SetTerminatingTrailerSegment(segmentString); break; case "GS": if (envelop == null) { throw new InvalidOperationException(String.Format("Segment '{0}' cannot occur before and ISA segment.", segmentString)); } currentContainer = fg = envelop.AddFunctionGroup(segmentString);; break; case "GE": if (fg == null) { throw new InvalidOperationException(String.Format("Segment '{0}' does not have a matching GS segment precending it.", segmentString)); } fg.SetTerminatingTrailerSegment(segmentString); fg = null; break; case "ST": if (fg == null) { throw new InvalidOperationException(string.Format("segment '{0}' cannot occur without a preceding GS segment.", segmentString)); } segmentIndex = 1; currentContainer = tr = fg.AddTransaction(segmentString); hloops = new Dictionary <string, HierarchicalLoop>(); break; case "SE": if (tr == null) { throw new InvalidOperationException(string.Format("Segment '{0}' does not have a matching ST segment preceding it.", segmentString)); } tr.SetTerminatingTrailerSegment(segmentString); tr = null; break; case "HL": Segment hlSegment = new Segment(null, reader.Delimiters, segmentString); string id = hlSegment.GetElement(1); string parentId = hlSegment.GetElement(2); string levelCode = hlSegment.GetElement(3); while (!(currentContainer is HierarchicalLoopContainer) || !((HierarchicalLoopContainer)currentContainer).AllowsHierarchicalLoop(levelCode)) { if (currentContainer.Parent != null) { currentContainer = currentContainer.Parent; } else { throw new InvalidOperationException(String.Format("Heierchical Loop {0} cannot be added to transaction set {1} because it's specification cannot be identified.", segmentString, tr.ControlNumber)); } } bool parentFound = false; if (parentId != "") { if (hloops.ContainsKey(parentId)) { parentFound = true; currentContainer = hloops[parentId].AddHLoop(segmentString); } else { if (_throwExceptionOnSyntaxErrors) { throw new InvalidOperationException(String.Format("Hierarchical Loop {0} expects Parent ID {1} which did not occur preceding it. To change this to a warning, pass throwExceptionOnSyntaxErrors = false to the X12Parser constructor.", id, parentId)); } else { OnParserWarning(new X12ParserWarningEventArgs { FileIsValid = false, InterchangeControlNumber = envelop.InterchangeControlNumber, FunctionalGroupControlNumber = fg.ControlNumber, TransactionControlNumber = tr.ControlNumber, SegmentPositionInInterchange = segmentIndex, Segment = segmentString, SegmentId = segmentId, Message = String.Format("Hierarchical Loop {0} expects Parent ID {1} which did not occur preceding it. This will be parsed as if it has no parent, but the file may not be valid.", id, parentId) }); } } } if (parentId == "" || !parentFound) { while (!(currentContainer is HierarchicalLoopContainer && ((HierarchicalLoopContainer)currentContainer).HasHierachicalSpecs())) { currentContainer = currentContainer.Parent; } currentContainer = ((HierarchicalLoopContainer)currentContainer).AddHLoop(segmentString); //hloops = new Dictionary<string, HierarchicalLoop>(); } if (hloops.ContainsKey(id)) { throw new InvalidOperationException(String.Format("Hierarchical Loop {0} cannot be added to transaction {1} because the ID {2} already exists.", segmentString, tr.ControlNumber, id)); } hloops.Add(id, (HierarchicalLoop)currentContainer); break; case "TA1": // Technical acknowledgement if (envelop == null) { throw new InvalidOperationException(string.Format("Segment {0} does not have a matching ISA segment preceding it.", segmentString)); } envelop.AddSegment(segmentString); break; default: var originalContainer = currentContainer; containerStack.Clear(); while (currentContainer != null) { if (currentContainer.AddSegment(segmentString) != null) { if (segmentId == "LE") { currentContainer = currentContainer.Parent; } break; } else { if (currentContainer is LoopContainer) { LoopContainer loopContainer = (LoopContainer)currentContainer; Loop newLoop = loopContainer.AddLoop(segmentString); if (newLoop != null) { currentContainer = newLoop; break; } else { if (currentContainer is Transaction) { var tran = (Transaction)currentContainer; if (_throwExceptionOnSyntaxErrors) { throw new TransactionValidationException( "Segment '{3}' in segment position {4} within transaction '{1}' cannot be identified within the supplied specification for transaction set {0} in any of the expected loops: {5}. To change this to a warning, pass throwExceptionOnSyntaxErrors = false to the X12Parser constructor.", tran.IdentifierCode, tran.ControlNumber, "", segmentString, segmentIndex, string.Join(",", containerStack)); } else { currentContainer = originalContainer; currentContainer.AddSegment(segmentString, true); OnParserWarning(new X12ParserWarningEventArgs { FileIsValid = false, InterchangeControlNumber = envelop.InterchangeControlNumber, FunctionalGroupControlNumber = fg.ControlNumber, TransactionControlNumber = tran.ControlNumber, SegmentPositionInInterchange = segmentIndex, SegmentId = segmentId, Segment = segmentString, Message = string.Format("Segment '{3}' in segment position {4} within transaction '{1}' cannot be identified within the supplied specification for transaction set {0} in any of the expected loops: {5}. It will be added to loop {6}, but this may invalidate all subsequent segments.", tran.IdentifierCode, tran.ControlNumber, "", segmentString, segmentIndex, string.Join(",", containerStack), containerStack.LastOrDefault()) }); break; } } else { if (currentContainer is Loop) { containerStack.Push(((Loop)currentContainer).Specification.LoopId); } if (currentContainer is HierarchicalLoop) { var hloop = ((HierarchicalLoop)currentContainer); containerStack.Push(string.Format("{0}[{1}]", hloop.Specification.LoopId, hloop.Id)); } currentContainer = currentContainer.Parent; continue; } } } else { break; } } } break; } segmentString = reader.ReadNextSegment(); segmentId = reader.ReadSegmentId(segmentString); segmentIndex++; } return(envelopes); } }
//----------------------------------------------------------- //<Loop>// public void Visit(Loop node, char i) { loopCounter += 1; VisitChildren(node, i); loopCounter -= 1; }
public void Dispose() { this.loop?.Dispose(); this.loop = null; }