public void RegisterEventHandlerForPort(IPort port) { //port.StateChanged += (sender, state) => //{ // Console.WriteLine("Station detected the port {0} changed its State to {1}", ((IPort)sender).IdentityNumber, state); //}; }
public Causality(string name, Guid guid, IPort exceptionPort, IPort coordinationPort) { this.name = name; Guid = guid; this.exceptionPort = exceptionPort; this.coordinationPort = coordinationPort; }
public void RegisterOnPortEvent(IPort port) { port.OnOutgoingRequest += this.ProcessRequest; port.OnOutgoingResponse += this.ProcessResponse; port.OnTerminateRequest += this.ProcessEndOfCall; port.OnUnplaged += this.TerminateAllConnections; }
protected void AcceptRequest(Request request, IPort port) { _Logger.WriteToLog("-> ATS process"); _Logger.WriteToLog(ObjectToLogString.ToLogString(request)); port.IncomingRequest(request); }
public void AddPort(IPort port) { if (port == null) throw new ArgumentNullException(nameof(port)); RegisterPort(port); _ports.Add(port); }
public Message(IPort port, object data, Guid correlationId) { this.Port = port; this.CorrelationId = correlationId; this.Data = data; this.Causalities = new CausalityStack(); this.FlowStack = new FlowStack(); }
public TerminalToPortConnection(IPort port, IClientTerminal terminal) { Port = port; Terminal = terminal; // handle terminal events Port.ConnectWithTerminal(Terminal); }
public IListContract<IParamType> Invoke(string roleName, string opName, IListContract<IParamType> parameters, IPort p, ICapability reqCap, ICapability respCap) { return CollectionAdapters.ToIListContract<VParamType, IParamType>(_view.Invoke(roleName, opName, CollectionAdapters.ToIList<IParamType, VParamType>(parameters, BaseTypeAdapter.C2V, BaseTypeAdapter.V2C), PortAdapter.C2V(p), CapabilityAdapter.C2V(reqCap), CapabilityAdapter.C2V(respCap)), BaseTypeAdapter.V2C, BaseTypeAdapter.C2V); }
internal static VPort C2V(IPort contract) { if (contract == null) { return null; } if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) && (contract.GetType().Equals(typeof(PortV2C)))) { return ((PortV2C)(contract)).GetSourceView(); } else { return new PortC2V(contract); } }
private void btnOutput_Click(object sender, EventArgs e) { FormComSelect comDlg = new FormComSelect(); comDlg.IsInputPort = false; DialogResult ret = comDlg.ShowDialog(); if (DialogResult.OK == ret) { IPort newPort = comDlg.GetPort(); if (newPort != null) { if (outPort != null) outPort.Dispose(); outPort = newPort; textBoxOutputPort.Text = comDlg.GetDisplayString(); } } }
public override void RegisterEventHandlersForPort(IPort port) { port.StateChanged += (sender, state) => { Console.WriteLine("Station detected the port changed its State to {0}", state); }; port.StateChanging += (sender, state) => { var a = PortsMapping.FirstOrDefault(x => x.Value == sender).Key; var d = GetTerminalByPhoneNumber(a); if (_activeCallMapping.ContainsKey(d) || _activeCallMapping.Values.Contains(d)) { d.Drop(); } else { d.Reject(); } }; }
private void btnInput_Click(object sender, EventArgs e) { FormComSelect comDlg = new FormComSelect(); comDlg.IsInputPort = true; DialogResult ret = comDlg.ShowDialog(); if(DialogResult.OK == ret) { IPort newPort = comDlg.GetPort(); if(newPort != null) { if (inPort != null) inPort.Dispose(); inPort = newPort; textBoxInputPort.Text = comDlg.GetDisplayString(); inPort.Read += new PortReadEvent(inPort_Read); } } }
/// <summary> /// Constructor /// </summary> /// <param name="wrapperName">Gives the name that the wrapper is to use for the log messages that it creates</param> /// <param name="wrappedPort">Gives the IPort instance that the AEW is to implement auto echo for</param> public AutoEchoWrapper(string wrapperName, IPort wrappedPort) : base(wrapperName, "AutoEchoWrapper") { port = wrappedPort; portWrActionParam.Buffer = portRdActionParam.Buffer; portRdAction = port.CreateReadAction(portRdActionParam); portWrAction = port.CreateWriteAction(portWrActionParam); portRdAction.NotifyOnComplete.OnNotify += this.ReadActionComplete; portWrAction.NotifyOnComplete.OnNotify += this.WriteActionComplete; // I Want the BaseStateNotifier to act as both a IGuardedNotificationObject and an ISequencedRefObjectSource so that // can signal on its state change AND use an observer to look at it cheaply. portBaseStateObserver = new SequencedRefObjectSourceObserver<IBaseState, int>(port.BaseStateNotifier); portBaseStateObserver.Update(); SetBaseState(UseState.Initial, ConnState.Initial, "CTOR", true); AddExplicitDisposeAction(() => MosaicLib.Utils.Fcns.DisposeOfObject(ref port)); }
protected virtual void Dispose(bool disposing) { if (! disposed) { if (disposing) { if (in_port != null) { in_port.Dispose(); in_port = null; } if (out_port != null) { out_port.Dispose(); out_port = null; } } application = null; config = null; engine = null; disposed = true; } }
public async Task<bool> Search(IPort p) { _port = p; Task<bool> run = new Task<bool>(() => { lock (_port) { if (!_port.InitializePort()) return false; _lastDiscrepancy = -1; _lastSelectedBit = 0x00; _done = true; do { this.Run(_lastSelectedBit); _ds.Add(_port.BitsToBytes(_currentId)); } while (!_done); } return true; }); run.Start(); return await run; }
protected override EllipseVisual UpdateVisual(IRenderContext context, EllipseVisual oldVisual, IPort port) { // arrange the old ellipse var transform = new Matrix(); var topLeft = port.GetLocation() + new PointD(Width * 0.5, Height * 0.5); transform.Translate((float)topLeft.X, (float)topLeft.Y); oldVisual.Transform = transform; return(oldVisual); }
/// <summary> /// Creates a sample graph and introduces all important graph elements present in /// yFiles.NET. Additionally, this method now overrides the label placement for some specific labels. /// </summary> private void PopulateGraph() { #region Sample Graph creation // Creates two nodes with the default node size // The location is specified for the _center_ INode node1 = Graph.CreateNode(new PointD(50, 50)); INode node2 = Graph.CreateNode(new PointD(150, 50)); // Creates a third node with a different size of 80x40 // In this case, the location of (360,280) describes the _upper left_ // corner of the node bounds INode node3 = Graph.CreateNode(new RectD(260, 180, 80, 40)); // Creates some edges between the nodes IEdge edge1 = Graph.CreateEdge(node1, node2); IEdge edge2 = Graph.CreateEdge(node2, node3); // Creates the first bend for edge2 at (400, 50) IBend bend1 = Graph.AddBend(edge2, new PointD(300, 50)); // Actually, edges connect "ports", not nodes directly. // If necessary, you can manually create ports at nodes // and let the edges connect to these. // Creates a port in the center of the node layout IPort port1AtNode1 = Graph.AddPort(node1, FreeNodePortLocationModel.NodeCenterAnchored); // Creates a port at the middle of the left border // Note to use absolute locations when placing ports using PointD. IPort port1AtNode3 = Graph.AddPort(node3, new PointD(node3.Layout.X, node3.Layout.GetCenter().Y)); // Creates an edge that connects these specific ports IEdge edgeAtPorts = Graph.CreateEdge(port1AtNode1, port1AtNode3); // Adds labels to several graph elements Graph.AddLabel(node1, "Node 1"); Graph.AddLabel(node2, "Node 2"); Graph.AddLabel(node3, "Node 3"); Graph.AddLabel(edgeAtPorts, "Edge at Ports"); // Add some more elements to have a larger graph to edit var n4 = Graph.CreateNode(new PointD(50, -50)); Graph.AddLabel(n4, "Node 4"); var n5 = Graph.CreateNode(new PointD(50, -150)); Graph.AddLabel(n5, "Node 5"); var n6 = Graph.CreateNode(new PointD(-50, -50)); Graph.AddLabel(n6, "Node 6"); var n7 = Graph.CreateNode(new PointD(-50, -150)); Graph.AddLabel(n7, "Node 7"); var n8 = Graph.CreateNode(new PointD(150, -50)); Graph.AddLabel(n8, "Node 8"); Graph.CreateEdge(n4, node1); Graph.CreateEdge(n5, n4); Graph.CreateEdge(n7, n6); var e6_1 = Graph.CreateEdge(n6, node1); Graph.AddBend(e6_1, new PointD(-50, 50), 0); ///////////////// New in this Sample ///////////////// // Creates a group node programmatically which groups the child nodes n4, n5, and n8 var groupNode = CreateGroupNodes(n4, n5, n8); // creates an edge between the group node and node 2 var eg_2 = Graph.CreateEdge(groupNode, node2); Graph.AddBend(eg_2, new PointD(100, 0), 0); Graph.AddBend(eg_2, new PointD(150, 0), 1); ////////////////////////////////////////////////////// #endregion }
public void Start(IPort port) { this.port = port; Task.Run(() => ReceiveThread()); }
/// <summary> /// Unregisters a port from this IPortOwner. /// </summary> /// <param name="key">The key by which the port being unregistered is known.</param> public void RemovePort(IPort port) { m_ports.RemovePort(port); }
public FP550(IPort port, byte startingMessageId = Communication.MinimumMessageId, Encoding?communicationEncoding = null) : this(port, port, startingMessageId, communicationEncoding) { }
protected override Ellipse UpdateVisual(IRenderContext context, Ellipse oldVisual, IPort port) { // arrange the old ellipse oldVisual.SetCanvasArrangeRect(new Rect(GetLocation(port) + new PointD(-Width * 0.5, -Height * 0.5), new SizeD(Width, Height))); return(oldVisual); }
protected override Task RunModule() { IMapperRegistry registry = CurrentIGraph.MapperRegistry; OptionGroup toplevelGroup = Handler.GetGroupByName(TOP_LEVEL); if ((bool)toplevelGroup[ClearAllConstraints].Value) { //deregistriere den Mapper, d.h. port constraints werden nicht mehr vorgegeben. registry.RemoveMapper(PortConstraintKeys.SourceGroupIdDpKey); registry.RemoveMapper(PortConstraintKeys.TargetGroupIdDpKey); sourceIDMapper = null; targetIDMapper = null; } else { registry.RemoveMapper(PortConstraintKeys.SourceGroupIdDpKey); registry.RemoveMapper(PortConstraintKeys.TargetGroupIdDpKey); if (sourceIDMapper == null) { sourceIDMapper = new DictionaryMapper <IEdge, object>(); } if (targetIDMapper == null) { targetIDMapper = new DictionaryMapper <IEdge, object>(); } string scope = (string)toplevelGroup[Scope].Value; string sourceId = toplevelGroup[SourceID].Value.ToString(); string targetId = toplevelGroup[TargetID].Value.ToString(); foreach (IEdge edge in CurrentIGraph.Edges) { bool isSelected = false; switch (scope) { case ScopeAllEdges: isSelected = true; break; case ScopeSelectedEdges: isSelected = IsSelected(Context, edge); break; case ScopeEdgesAtSelectedNodes: IPort sourcePort = edge.SourcePort; IPort targetPort = edge.TargetPort; isSelected = IsSelected(Context, sourcePort) || IsSelected(Context, targetPort) || IsSelected(Context, sourcePort.Owner) || IsSelected(Context, targetPort.Owner); break; } if (isSelected) { sourceIDMapper[edge] = sourceId.Length > 0 ? sourceId : null; targetIDMapper[edge] = targetId.Length > 0 ? targetId : null; } } registry.AddMapper(PortConstraintKeys.SourceGroupIdDpKey, sourceIDMapper); registry.AddMapper(PortConstraintKeys.TargetGroupIdDpKey, targetIDMapper); } return(Task.FromResult <object>(null)); }
/// <summary> /// Creates a sample graph and introduces all important graph elements present in /// yFiles WPF. Additionally, this method now overrides the label placement for some specific labels. /// </summary> private void PopulateGraph() { #region Sample Graph creation //////////// Sample node creation /////////////////// // Creates two nodes with the default node size // The location is specified for the _center_ INode node1 = Graph.CreateNode(new PointD(50, 50)); INode node2 = Graph.CreateNode(new PointD(150, 50)); // Creates a third node with a different size of 80x40 // In this case, the location of (360,380) describes the _upper left_ // corner of the node bounds INode node3 = Graph.CreateNode(new RectD(360, 380, 80, 40)); ///////////////////////////////////////////////////// //////////// Sample edge creation /////////////////// // Creates some edges between the nodes IEdge edge1 = Graph.CreateEdge(node1, node2); IEdge edge2 = Graph.CreateEdge(node2, node3); ///////////////////////////////////////////////////// //////////// Using Bends //////////////////////////// // Creates the first bend for edge2 at (400, 50) IBend bend1 = Graph.AddBend(edge2, new PointD(400, 50)); ///////////////////////////////////////////////////// //////////// Using Ports //////////////////////////// // Actually, edges connect "ports", not nodes directly. // If necessary, you can manually create ports at nodes // and let the edges connect to these. // Creates a port in the center of the node layout IPort port1AtNode1 = Graph.AddPort(node1, FreeNodePortLocationModel.NodeCenterAnchored); // Creates a port at the middle of the left border // Note to use absolute locations when placing ports using PointD. IPort port1AtNode3 = Graph.AddPort(node3, new PointD(node3.Layout.X, node3.Layout.GetCenter().Y)); // Creates an edge that connects these specific ports IEdge edgeAtPorts = Graph.CreateEdge(port1AtNode1, port1AtNode3); ///////////////////////////////////////////////////// //////////// Sample label creation /////////////////// // Adds labels to several graph elements Graph.AddLabel(node1, "N 1"); Graph.AddLabel(node2, "N 2"); Graph.AddLabel(node3, "N 3"); var edgeLabel = Graph.AddLabel(edgeAtPorts, "Edge at Ports"); ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// #endregion ///////////////// New in this Sample ///////////////// // Override default styles // Changes the style for the second node // Creates a new node style, this time a ShapeNodeStyle: ShapeNodeStyle sns = new ShapeNodeStyle { Shape = ShapeNodeShape.Ellipse, Pen = Pens.Black, Brush = Brushes.OrangeRed }; // Sets the node's style property to the new style through its owning graph, // since you can't set the style property of an INode directly // (you'll set most other graph object properties this way as well) Graph.SetStyle(node2, sns); // Creates a different style for the label with black text and a red border // and intransparent white background DefaultLabelStyle sls = new DefaultLabelStyle { Typeface = new Typeface("Arial Black"), TextSize = 12, TextBrush = Brushes.Black }; sls.BackgroundPen = Pens.Red; sls.BackgroundBrush = Brushes.White; // And sets the style for the edge label, again through its owning graph. Graph.SetStyle(edgeLabel, sls); // Override the style for the "Edge at Ports" edge: // Uses a dashed red Pen with thickness 2. Pen defaultPen = new Pen(Brushes.Red, 2) { DashStyle = DashStyles.Dash }; defaultPen.Freeze(); // Creates an edge style that will apply the new default pen // to the entire line using PolyLineEdgeStyle, // which draws a polyline determined by the edge's control points (bends) var edgeStyle = new PolylineEdgeStyle { Pen = defaultPen }; // Sets the source and target arrows on the edge style instance // Note that IEdgeStyle itself does not have these properties // also note: by default the arrows have a default brush and pen edgeStyle.SourceArrow = Arrows.Circle; // set color and size to match the thick red line edgeStyle.TargetArrow = new Arrow(Brushes.Red.Color) { Type = ArrowType.Short, Scale = 2 }; // Sets the defined edge style as the default for all edges that don't have // another style assigned explicitly: Graph.SetStyle(edge2, edgeStyle); ////////////////////////////////////////////////////// }
protected override Task RunModule() { IMapperRegistry registry = CurrentIGraph.MapperRegistry; OptionGroup toplevelGroup = Handler.GetGroupByName(TOP_LEVEL); if ((bool)toplevelGroup[ClearAllConstraints].Value) { //deregistriere den Mapper, d.h. port constraints werden nicht mehr vorgegeben. registry.RemoveMapper(PortConstraintKeys.TargetPortConstraintDpKey); registry.RemoveMapper(PortConstraintKeys.SourcePortConstraintDpKey); sourcePCMapper = null; targetPCMapper = null; } else { registry.RemoveMapper(PortConstraintKeys.TargetPortConstraintDpKey); registry.RemoveMapper(PortConstraintKeys.SourcePortConstraintDpKey); if (sourcePCMapper == null) { sourcePCMapper = new DictionaryMapper <IEdge, PortConstraint>(); } if (targetPCMapper == null) { targetPCMapper = new DictionaryMapper <IEdge, PortConstraint>(); } string scope = (string)toplevelGroup[Scope].Value; OptionGroup spcg = toplevelGroup.GetGroupByName(SourcePortConstraints); OptionGroup tpcg = toplevelGroup.GetGroupByName(TargetPortConstraints); PortConstraintType sourceType = (PortConstraintType)spcg[PortConstraintStr].Value; bool strongSource = (bool)spcg[StrongPortConstraint].Value; PortConstraintType targetType = (PortConstraintType)tpcg[PortConstraintStr].Value; bool strongTarget = (bool)spcg[StrongPortConstraint].Value; foreach (IEdge edge in CurrentIGraph.Edges) { bool isSelected = false; switch (scope) { case ScopeAllEdges: isSelected = true; break; case ScopeSelectedEdges: isSelected = IsSelected(Context, edge); break; case ScopeEdgesAtSelectedNodes: IPort sourcePort = edge.SourcePort; IPort targetPort = edge.TargetPort; isSelected = IsSelected(Context, sourcePort) || IsSelected(Context, targetPort) || IsSelected(Context, sourcePort.Owner) || IsSelected(Context, targetPort.Owner); break; } if (isSelected) { sourcePCMapper[edge] = CreatePortConstraint(edge, sourceType, true, strongSource); targetPCMapper[edge] = CreatePortConstraint(edge, targetType, false, strongTarget); } } registry.AddMapper(PortConstraintKeys.SourcePortConstraintDpKey, sourcePCMapper); registry.AddMapper(PortConstraintKeys.TargetPortConstraintDpKey, targetPCMapper); } return(Task.FromResult <object>(null)); }
private static PortConstraint CreatePortConstraintFromSketch(IEdge e, bool source, bool strong) { //Get connection port and owner IPort port = source ? e.SourcePort : e.TargetPort; INode portOwner = port.Owner as INode; if (portOwner != null) { //Einfachste Loesung: //Erzeugt einen strong PortConstraint genau an der port location //anschluesse in alle richtungen moeglich // return PortConstraint.create(PortConstraint.ANY_SIDE, strong); //alternativ: z.B. Kantenpfad bestimmen und einen PortConstraint //erzeugen, dessen Richtung durch den Schnittpunkt zwischen Pfad und Knotenrand gegeben ist. //hier nur geradlinige Verbindung zwischen Bends PointD portLocation = port.GetLocation(); PointD seg = new PointD(); var bends = e.Bends; if (bends.Count == 0) { // no bends, instead take the endpoint seg = source ? e.TargetPort.GetLocation() : e.SourcePort.GetLocation(); } else { IPoint p1 = bends[0].Location; IPoint p2 = bends[bends.Count - 1].Location; seg = source ? new PointD(p1) : new PointD(p2); } // Some offset for ports, which lie exactly on the border RectD enlarged = portOwner.Layout.ToRectD().GetEnlarged(5); var generalPath = new GeneralPath(2); generalPath.MoveTo(portLocation); generalPath.LineTo(seg); if (generalPath.FindLineIntersection(enlarged.TopLeft, enlarged.TopRight) < 1) { //Erstes Segment verlaesst den Knoten auf der Nordseite //Die tatsaechliche Position des Constraints ergibt sich aus dem Startpunkt der Kante, muss //hier also nicht noch mal angegeben werden, dafuer aber, dass es sich wirklich um einen STRONG constraint //handelt. return(PortConstraint.Create(PortSide.North, strong)); } if (generalPath.FindLineIntersection(enlarged.TopLeft, enlarged.BottomLeft) < 1) { //first segment leaves at west... return(PortConstraint.Create(PortSide.West, strong)); } if (generalPath.FindLineIntersection(enlarged.TopRight, enlarged.BottomRight) < 1) { //first segment leaves at east... return(PortConstraint.Create(PortSide.East, strong)); } if (generalPath.FindLineIntersection(enlarged.BottomLeft, enlarged.BottomRight) < 1) { //first segment leaves at south... return(PortConstraint.Create(PortSide.South, strong)); } //keine intersection mit dem ersten segment, hier waehlen wir den einfachen Weg... return(PortConstraint.Create(PortSide.Any, strong)); } return(null); }
/// <summary> /// Configures a specific input port on a downstream component. This method will perform a shallow copy of the output /// port it is to be connected to. /// </summary> /// <param name="config">User provided port configuration object.</param> /// <param name="copyPort">The output port we are copying format data from.</param> /// <param name="handler">The input port capture handler. This will be non-null if this port's component is the 1st component in the /// pipeline and you are feeding data to it directly from a <see cref="IInputCaptureHandler"/>. If this port is connected to by another component then leave this parameter null. /// </param> /// <returns>This <see cref="MMALDownstreamComponent"/>.</returns> public virtual unsafe IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) { this.Inputs[0].Configure(config, copyPort, handler); if (this.Outputs.Count > 0 && this.Outputs[0].Ptr->Format->Type == MMALFormat.MMAL_ES_TYPE_T.MMAL_ES_TYPE_UNKNOWN) { throw new PiCameraError("Unable to determine settings for output port."); } return(this); }
void MyWorkflow_PortDataPresented(object data, IPort where) { Token token = (Token)data; token.Complete(); }
protected void MapTerminalToPort(ITerminal terminal, IPort port) { this.m_portMapping.Add(terminal.PhoneNumber, port); port.RegisterEventHandlerForTerminal(terminal); terminal.RegisterEventHandlerForPort(port); }
public FP550(IPort sendingPort, IPort receivingPort, byte startingMessageId = Communication.MinimumMessageId, Encoding?communicationEncoding = null) { programCommunication = new Communication(sendingPort, communicationEncoding); printerCommunication = new Communication(receivingPort, communicationEncoding); nextMessageId = Math.Min(Math.Max(startingMessageId, Communication.MinimumMessageId), Communication.MaximumMessageId); }
public bool Initialize(PatchTreeDef patchTree, List <Node> list) { this.patchTree = patchTree; if (inputNode == null) { if (inputNodeName != null) { if (!(list.FirstOrDefault(t => t.name == inputNodeName) is Node node)) { Log.Error($"[[LC]AutoPatcher] TempError 687669"); return(false); } inputNode = node; } else { if (!(list.FirstOrDefault(t => t.index == inputNodeInd) is Node node)) { Log.Error($"[[LC]AutoPatcher] TempError 949867"); return(false); } inputNode = node; } } if (outputNode == null) { if (outputNodeName != null) { if (!(list.FirstOrDefault(t => t.name == outputNodeName) is Node node)) { Log.Error($"[[LC]AutoPatcher] TempError 687669"); return(false); } outputNode = node; } else { if (!(list.FirstOrDefault(t => t.index == outputNodeInd) is Node node)) { Log.Error($"[[LC]AutoPatcher] TempError 949867"); return(false); } outputNode = node; } } if (inputPort != null && outputPort != null) { return(true); } if (inputPortInd < 0 || outputPortInd < 0) { List <IPort> inputPorts; List <IPort> outputPorts; if (inputPortInd < 0) { inputPortGroup = inputPortGroup < 0 ? 0 : inputPortGroup; inputPorts = inputNode.inputPortGroups[inputPortGroup]; } else { if (inputPortGroup < 0) { inputPort = inputNode.inputPorts[inputPortInd]; } else { inputPort = inputNode.inputPortGroups[inputPortGroup][inputPortInd]; } inputPorts = new List <IPort>() { inputPort }; } if (outputPortInd < 0) { outputPortGroup = outputPortGroup < 0 ? 0 : outputPortGroup; outputPorts = outputNode.outputPortGroups[outputPortGroup]; } else { if (outputPortGroup < 0) { outputPort = outputNode.outputPorts[outputPortInd]; } else { outputPort = outputNode.outputPortGroups[outputPortGroup][outputPortInd]; } outputPorts = new List <IPort>() { outputPort }; } foreach (var outPort in outputPorts) { foreach (var inPort in inputPorts) { if (outPort.DataType.CanCastTo(inPort.DataType)) // if (inPort.DataType.IsAssignableFrom(outPort.DataType)) { var branch = new PatchTreeBranch(patchTree) { inputNode = inputNode, outputNode = outputNode, inputPort = inPort, outputPort = outPort, }; patchTree.Branches.Add(branch); branch.Initialize(patchTree, list); } } } patchTree.Branches.Remove(this); } else { if (inputPortGroup < 0) { inputPort = inputNode.inputPorts[inputPortInd]; } else { inputPort = inputNode.inputPortGroups[inputPortGroup][inputPortInd]; } if (outputPortGroup < 0) { outputPort = outputNode.outputPorts[outputPortInd]; } else { outputPort = outputNode.outputPortGroups[outputPortGroup][outputPortInd]; } } return(true); }
/// <summary> /// Registers a port with this IPortOwner /// </summary> /// <param name="key">The key by which this IPortOwner will know this port.</param> /// <param name="port">The port that this IPortOwner will know by this key.</param> public void AddPort(IPort port) { m_ports.AddPort(port); }
private void OnUnbindPortEvent(IPort port) { UnbindPortEvent?.Invoke(MACAddress, port); }
public void AddPort(IPort port) { throw new Exception("The method or operation is not implemented."); }
protected void Dispose(bool disposing) { if (! disposed) { if (disposing) { if (started) Stop(); protocolTimer.Dispose(); } application = null; config = null; engine = null; appPort = null; outputThread = null; disposed = true; } }
static void Main(string[] args) { //Creating station and terminals Station stantion = new Station(); Terminal terminal1 = new Terminal(); Terminal terminal2 = new Terminal(); //Creating user 1 Console.WriteLine("Creating user 1"); User user1 = new User("Vladislav", "Ivanov", terminal1); Account acc1 = new Account(user1); acc1.AddFounds(15); IPort port1 = stantion.GeneratePort(Region.Region1, "+375298005544"); user1.Terminal.AddPort(port1); Console.WriteLine(acc1.ActivateAccount()); Console.WriteLine(""); //Creating user 2 Console.WriteLine("Creating user2"); User user2 = new User("Kirill", "Nekrasov", terminal2); Account acc2 = new Account(user2); acc2.AddFounds(27); IPort port2 = stantion.GeneratePort(Region.Region1, "+375291234567"); user2.Terminal.AddPort(port2); Console.WriteLine(acc2.ActivateAccount()); Console.WriteLine(""); //Adding and removing ports for user 2 Console.WriteLine("Adding and removing ports for user 2"); Console.WriteLine("Remove port"); Console.WriteLine(user2.Terminal.RemovePort()); Console.WriteLine("Add port"); Console.WriteLine(user2.Terminal.AddPort(port2)); Console.WriteLine(""); //Checking ATS Status Console.WriteLine("ATS Status:"); Console.WriteLine(stantion.Status); Console.WriteLine(""); //Calling user 1 from user 2 Console.WriteLine("Calling from user 1 to user 2"); Console.WriteLine(user1.Terminal.Call("+375291234567")); Console.WriteLine(""); //Checking balance Console.WriteLine("Balance for users 1 and 2"); Console.WriteLine("User 1 account balance: {0}", acc1.AccountBalance); Console.WriteLine("User 2 account balance: {0}", acc2.AccountBalance); Console.WriteLine(""); Console.WriteLine("User's ports statuses:"); Console.WriteLine(terminal1.Port.Status + " " + terminal2.Port.Status); Console.WriteLine(""); //Ending call System.Threading.Thread.Sleep(6000); Console.WriteLine("Ending call"); user1.Terminal.Decline(); Console.WriteLine(""); Console.WriteLine("User's ports statuses:"); Console.WriteLine(terminal1.Port.Status); Console.WriteLine(terminal2.Port.Status); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Output log for user 1:"); Console.WriteLine(acc1.GetAccountLog()); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Output log for user 2:"); Console.WriteLine(acc2.GetAccountLog()); Console.WriteLine(""); Console.WriteLine("Turning off power for user 1 terminal"); Console.WriteLine(user1.Terminal.PowerOff()); Console.WriteLine("Trying to call..."); Console.WriteLine(user1.Terminal.Call("+375291234567")); Console.WriteLine("Turning on power for user 1 terminal"); Console.WriteLine(user1.Terminal.PowerOn()); Console.WriteLine(""); Console.ReadKey(); }
public void Stop() { if (disposed) throw new ObjectDisposedException(GetType().Name); started = false; protocolTimer.Change(Timeout.Infinite, Timeout.Infinite); if (engineMutex.WaitOne()) { try { if (appPortMutex.WaitOne()) { try { outputThread.Abort(); outputThread = null; appPort.Close(); appPort.Dispose(); appPort = null; engine = null; } finally { appPortMutex.ReleaseMutex(); } } else throw new Exception("Failed to lock application port mutex"); } finally { engineMutex.ReleaseMutex(); } } else throw new Exception("Failed to lock protocol engine mutex"); }
public SerialRead(IReadingRepository repo, IPort port, IServiceScopeFactory serviceScopeFactory) { _port = port; _serviceScopeFactory = serviceScopeFactory; Sequence = null; }
private void appPort_Error(IPort sender, string error) { application.LogMessage(this, "App Port Error: " + error); }
public SumpCommander(IPort port) { Port=port; }
public AbstractReader(string readerName, IPort commPort) { ReaderName = readerName; CommPort = commPort; }
/// <summary> /// Calculates the bounds of this port. /// </summary> /// <remarks> /// These are also used for arranging the visual, hit testing, visibility testing, and marquee box tests. /// </remarks> protected override RectD GetBounds(ICanvasContext context, IPort port) { return(RectD.FromCenter(GetLocation(port), new SizeD(Width, Height))); }
public Ship(IRouteMap routeMap, IPort port) : base(routeMap, port) { }
public virtual void UnbindPort(IPort port) { if (port == null) throw new ArgumentNullException(nameof(port)); if (port.MACAddress != _bindedPortMAC) throw new RegistrationException($"{this} did'n bind to {port}"); port.StateChangedEvent -= PortOnStateChangedEvent; IsBindedPortNotClosed = false; port.SendRequestEvent -= ProcessRequest; port.SendResponseEvent -= ProcessResponse; _bindedPortMAC = null; if (State != PortState.Close) State = PortState.Open; OnUnbindPortEvent(port); }
/// <summary> /// This method returns the static current location of the port. /// </summary> /// <param name="port">The port.</param> /// <returns>The current location of the given port.</returns> private static PointD GetLocation(IPort port) { var param = port.LocationParameter; return(param.Model.GetLocation(port, param)); }
public virtual void BindPort(IPort port) { if (port == null) throw new ArgumentNullException(nameof(port)); if (IsPortBinded) throw new RegistrationException($"{this} already binded"); port.StateChangedEvent += PortOnStateChangedEvent; PortOnStateChangedEvent(this, port.State, port.State); port.SendRequestEvent += ProcessRequest; port.SendResponseEvent += ProcessResponse; _bindedPortMAC = port.MACAddress; if (State != PortState.Close) State = PortState.Listened; OnBindPortEvent(port); }
/// <inheritdoc/> public IVisualCreator GetVisualCreator(IPort item, IPortStyle style) { var adapter = ((EventPortStyle)style).adapter; return(adapter.Renderer.GetVisualCreator(item, adapter)); }
public void Start() { if (disposed) throw new ObjectDisposedException(GetType().Name); if (engineMutex.WaitOne()) { try { if (appPortMutex.WaitOne()) { try { try { engine = new GarminProtocolEngine((short)((int)settings["gpsProductId"].Value), (short)((int)settings["gpsSoftwareVersion"].Value), (string)settings["gpsProductDescription"].Value, (uint)((long)settings["gpsUnitId"].Value), (int)settings["snrMin"].Value, (int)settings["snrMax"].Value); appPort = application.GetPort(this, (string)settings["appPort"].Value); appPort.Read += new PortReadEvent(appPort_Read); appPort.Error += new PortErrorEvent(appPort_Error); appPort.Open(); outputThread = new EventThread(new EventThreadCallback(OutputThreadCallback)); outputThread.Priority = ThreadPriority.Normal; outputThread.Start(); protocolTimer.Change(0, 1000); } catch { protocolTimer.Change(Timeout.Infinite, Timeout.Infinite); if (outputThread != null) { outputThread.Abort(); outputThread = null; } if (appPort != null) { appPort.Close(); appPort.Dispose(); appPort = null; } engine = null; throw; } } finally { appPortMutex.ReleaseMutex(); } } else throw new Exception("Failed to lock application port mutex"); } finally { engineMutex.ReleaseMutex(); } } else throw new Exception("Failed to lock protocol engine mutex"); started = true; }
/// <inheritdoc/> public IBoundsProvider GetBoundsProvider(IPort item, IPortStyle style) { var adapter = ((EventPortStyle)style).adapter; return(adapter.Renderer.GetBoundsProvider(item, adapter)); }
private void appPort_Read(IPort sender, byte[] data) { if (engineMutex.WaitOne()) { try { if (engine != null) { if (logGarminProtocol) application.LogMessage(this, "in: " + HexFormatPacket(data)); engine.ProcessReceivedData(data); outputThread.ThreadEvent.Set(); } } finally { engineMutex.ReleaseMutex(); } } else { application.LogMessage(this, "Failed to lock protocol engine mutex"); } }
/// <inheritdoc/> public IVisibilityTestable GetVisibilityTestable(IPort item, IPortStyle style) { var adapter = ((EventPortStyle)style).adapter; return(adapter.Renderer.GetVisibilityTestable(item, adapter)); }
public virtual void RegisterEventHandlersForPort(IPort port) { port.StateChanged += (sender, state) => { if (IsOnline && state == PortState.connected) { this.OnOffline(sender, null); } }; }
/// <inheritdoc/> public IMarqueeTestable GetMarqueeTestable(IPort item, IPortStyle style) { var adapter = ((EventPortStyle)style).adapter; return(adapter.Renderer.GetMarqueeTestable(item, adapter)); }
public Message(IPort port, object data) : this(port, data, Guid.Empty) { }
protected override IShapeGeometry GetPortGeometry(IPort port) { return(port.Style.Renderer.GetContext(port, port.Style).Lookup <IShapeGeometry>()); }
/// <summary> /// Constructs a new netram instance /// </summary> /// <param name="port">The port containing the netgram</param> public InboundNetgram(IPort port) { this.Port = port; }
public StatisticReportActor(IPort <IStatisticRequestHandelr> statisticPort) { _statisticPort = statisticPort; }
protected void UnMapTerminalFromPort(ITerminal terminal, IPort port) { this.m_portMapping.Remove(terminal.PhoneNumber); terminal.ClearEvents(); port.ClearEvents(); }
/// <summary> /// Creates a sample graph and introduces all important graph elements present in /// yFiles.NET. Additionally, this method now overrides the label placement for some specific labels. /// </summary> private void PopulateGraph() { #region Sample Graph creation //////////// Sample node creation /////////////////// // Creates two nodes with the default node size // The location is specified for the _center_ INode node1 = Graph.CreateNode(new PointD(50, 50)); INode node2 = Graph.CreateNode(new PointD(150, 50)); // Creates a third node with a different size of 80x40 // In this case, the location of (360,380) describes the _upper left_ // corner of the node bounds INode node3 = Graph.CreateNode(new RectD(360, 380, 80, 40)); ///////////////////////////////////////////////////// //////////// Sample edge creation /////////////////// // Creates some edges between the nodes IEdge edge1 = Graph.CreateEdge(node1, node2); IEdge edge2 = Graph.CreateEdge(node2, node3); ///////////////////////////////////////////////////// //////////// Using Bends //////////////////////////// // Creates the first bend for edge2 at (400, 50) IBend bend1 = Graph.AddBend(edge2, new PointD(400, 50)); ///////////////////////////////////////////////////// //////////// Using Ports //////////////////////////// // Actually, edges connect "ports", not nodes directly. // If necessary, you can manually create ports at nodes // and let the edges connect to these. // Creates a port in the center of the node layout IPort port1AtNode1 = Graph.AddPort(node1, FreeNodePortLocationModel.NodeCenterAnchored); // Creates a port at the middle of the left border // Note to use absolute locations when placing ports using PointD. IPort port1AtNode3 = Graph.AddPort(node3, new PointD(node3.Layout.X, node3.Layout.GetCenter().Y)); // Creates an edge that connects these specific ports IEdge edgeAtPorts = Graph.CreateEdge(port1AtNode1, port1AtNode3); ///////////////////////////////////////////////////// //////////// Sample label creation /////////////////// // Adds labels to several graph elements Graph.AddLabel(node1, "N 1"); Graph.AddLabel(node2, "N 2"); var node3Label = Graph.AddLabel(node3, "N 3"); Graph.AddLabel(edgeAtPorts, "Edge at Ports"); ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// #endregion ///////////////// New in this Sample ///////////////// // Override default label placement // For our "special" label, we use a model that describes discrete positions // outside the node bounds ExteriorLabelModel exteriorLabelModel = new ExteriorLabelModel(); // We use some extra insets from the label to the node bounds exteriorLabelModel.Insets = new InsetsD(5); // We assign this label a specific symbolic position out of the eight possible // external locations valid for ExteriorLabelModel Graph.SetLabelLayoutParameter(node3Label, exteriorLabelModel.CreateParameter(ExteriorLabelModel.Position.South)); ///////////////////////////////////////////////////// }
public override void RegisterEventHandlersForPort(IPort port) { port.StateChanged += (sender, state) => { Console.WriteLine("Station detected the port changed its State to {0}", state); }; }
/// <summary> /// Creates a sample graph and introduces all important graph elements present in /// yFiles.NET. /// </summary> private void PopulateGraph() { #region Sample Graph creation ///////////////// New in this Sample ///////////////// // Creates a node outside the initial content rectangle INode node4 = Graph.CreateNode(new PointD(-100, -100)); ILabel outsiderLabel = Graph.AddLabel(node4, "Outside Initial Viewport"); ////////////////////////////////////////////////////// //////////// Sample node creation /////////////////// // Creates two nodes with the default node size // The location is specified for the _center_ INode node1 = Graph.CreateNode(new PointD(50, 50)); INode node2 = Graph.CreateNode(new PointD(150, 50)); // Creates a third node with a different size of 80x40 // In this case, the location of (360,380) describes the _upper left_ // corner of the node bounds INode node3 = Graph.CreateNode(new RectD(360, 380, 80, 40)); ///////////////////////////////////////////////////// //////////// Sample edge creation /////////////////// // Creates some edges between the nodes IEdge edge1 = Graph.CreateEdge(node1, node2); IEdge edge2 = Graph.CreateEdge(node2, node3); ///////////////////////////////////////////////////// //////////// Using Bends //////////////////////////// // Creates the first bend for edge2 at (400, 50) IBend bend1 = Graph.AddBend(edge2, new PointD(400, 50)); ///////////////////////////////////////////////////// //////////// Using Ports //////////////////////////// // Actually, edges connect "ports", not nodes directly. // If necessary, you can manually create ports at nodes // and let the edges connect to these. // Creates a port in the center of the node layout IPort port1AtNode1 = Graph.AddPort(node1, FreeNodePortLocationModel.NodeCenterAnchored); // Creates a port at the middle of the left border // Note to use absolute locations when placing ports using PointD. IPort port1AtNode3 = Graph.AddPort(node3, new PointD(node3.Layout.X, node3.Layout.GetCenter().Y)); // Creates an edge that connects these specific ports IEdge edgeAtPorts = Graph.CreateEdge(port1AtNode1, port1AtNode3); ///////////////////////////////////////////////////// //////////// Sample label creation /////////////////// // Adds labels to several graph elements Graph.AddLabel(node1, "N 1"); Graph.AddLabel(node2, "N 2"); Graph.AddLabel(node3, "N 3"); Graph.AddLabel(edgeAtPorts, "Edge at Ports"); ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// #endregion }