public void NodeIdentifier_Valid() { Test(() => { NodeIdentifier.Get(User.Administrator); }); }
public void NodeIdentifier_Create() { var services = new ServiceCollection() .AddSingleton <DataProvider>(new InMemoryDataProvider()) .AddSingleton(NullLoggerFactory.Instance.CreateLogger <DataStore>()) .AddSingleton <IDataStore, DataStore>() .AddSingleton(NullLoggerFactory.Instance.CreateLogger <TreeLock>()) .AddSingleton <ITreeLockController, TreeLockController>() .BuildServiceProvider(); Providers.Instance = new Providers(services); var identifier = NodeIdentifier.Get(123); Assert.AreEqual(123, identifier.Id, "#1 identifier is incorrect."); Assert.IsNull(identifier.Path, "#2 identifier is incorrect."); identifier = NodeIdentifier.Get("/Root/P1"); Assert.AreEqual("/Root/P1", identifier.Path, "#3 identifier is incorrect."); Assert.AreEqual(0, identifier.Id, "#4 identifier is incorrect."); identifier = NodeIdentifier.Get("123"); Assert.AreEqual(123, identifier.Id, "#5 identifier is incorrect."); Assert.IsNull(identifier.Path, "#6 identifier is incorrect."); short shortId = 123; identifier = NodeIdentifier.Get(shortId); Assert.AreEqual(shortId, identifier.Id, "#7 identifier is incorrect."); Assert.IsNull(identifier.Path, "#8 identifier is incorrect."); }
public DisplayOnPacketDequeued(NodeIdentifier nodeId, IObservable <NetworkEvent> networkEvents, PacketTypeReadModel packetTypeReadModel, IDisplayPacketEnqueue consumerPacket) { networkEvents .OfType <NetworkEvent, NetworkEvent.PacketDequeued>() .Where(packetDequed => packetDequed.NodeId == nodeId) .Subscribe(color => consumerPacket.DequeuePacket()); }
public override void Store(FileId key, IEnumerable <FileLocation> value, NodeIdentifier <FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> Store(key: {0}, value: {1}, callerIdentifier: {2})", key, value.WriteValues(), callerIdentifier); base.Store(key, value, callerIdentifier); }
public NodeBase Parse(Parser parser, NodeBase left, Token token) { List <NodeBase> args = new List <NodeBase>(); if (!parser.Match(TokenTypes.ParenthesisOut)) { do { args.Add(parser.Parse()); }while (parser.Match(TokenTypes.Comma)); parser.Consume(TokenTypes.ParenthesisOut); } NodeIdentifier name = left as NodeIdentifier; FunctionInfo info = FunctionRegistry.GetFunction(name.IdentifierName); if (info == null) { throw new MismatchedRuleException("Function " + name + " not found."); } return(new NodeFunction(info, args.ToArray())); }
public SetNodePositionWhenNodeAdded(NodeIdentifier nodeId, IObservable <NetworkEvent> networkEvents, IDisplayNodePosition displayNodePosition) { networkEvents .OfType <NetworkEvent, NetworkEvent.NodeAdded>() .Where(nodeAdded => nodeAdded.Node.Id == nodeId) .Subscribe(nodeAdded => displayNodePosition.Position = nodeAdded.Node.Position); }
protected override ISetKadNode <FileId, FileLocation> CreateClientFromNodeId( NodeIdentifier <FileId> nodeIdentifier) { return(nodeIdentifier == NodeIdentifier ? Service : new FileToMachineClient(new BasicHttpBinding(), new EndpointAddress(nodeIdentifier.ServiceUrl))); }
public override void Store(FileId key, IEnumerable<FileLocation> value, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> Store(key: {0}, value: {1}, callerIdentifier: {2})", key, value.WriteValues(), callerIdentifier); base.Store(key, value, callerIdentifier); }
public override FindValueResult<FileId, IEnumerable<FileLocation>> FindValue(FileId key, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> FindValue(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return base.FindValue(key, callerIdentifier); }
public override FindValueResult <string, IEnumerable <FileId> > FindValue(string key, NodeIdentifier <string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> FindValue(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return(base.FindValue(key, callerIdentifier)); }
public override FindValueResult<string, IEnumerable<FileId>> FindValue(string key, NodeIdentifier<string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> FindValue(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return base.FindValue(key, callerIdentifier); }
protected override ISetKadNode <string, FileId> CreateClientFromNodeId(NodeIdentifier <string> nodeIdentifier) { return(nodeIdentifier == NodeIdentifier ? Service : (ISetKadNode <string, FileId>) new ReverseIndexServiceClient(new BasicHttpBinding(), new EndpointAddress(nodeIdentifier.ServiceUrl))); }
public void Initialize(IObservable <NetworkEvent> networkEvents, NodeIdentifier nodeIdentifier) { _packetQueue = new Queue <Packet>(); _gameObjectQueue = new Queue <GameObject>(DisplaySize); _nodeIdentifier = nodeIdentifier; InitializeEventListeners(networkEvents); }
public InitializeRouterArrowsWhenLinkAddedAsSource(NodeIdentifier nodeId, IObservable <NetworkEvent> networkEvents, IEnqueueCommand <NetworkCommand> commandQueue) { this.commandQueue = commandQueue; networkEvents .OfType <NetworkEvent, NetworkEvent.LinkAdded>() .Where(linkAdded => linkAdded.Link.Source == nodeId) .Subscribe(linkAdded => Initialize(nodeId, linkAdded.Link.Id)); }
public HeartBeat <string> Ping(NodeIdentifier <string> callerIdentifier) { var inValue = new PingRequest(); inValue.callerIdentifier = callerIdentifier; PingResponse retVal = ((IReverseIndexServiceContract)(this)).Ping(inValue); return(retVal.PingResult); }
public void Store(string key, FileId[] value, NodeIdentifier <string> callerIdentifier) { var inValue = new StoreRequest(); inValue.key = key; inValue.value = value; inValue.callerIdentifier = callerIdentifier; StoreResponse retVal = ((IReverseIndexServiceContract)(this)).Store(inValue); }
public DisplayOnPacketEnqueued(NodeIdentifier nodeId, IObservable <NetworkEvent> networkEvents, PacketTypeReadModel packetTypeReadModel, IDisplayPacketEnqueue consumerPacket) { networkEvents .OfType <NetworkEvent, NetworkEvent.PacketEnqueued>() .Where(packetEnqued => packetEnqued.NodeId == nodeId) .Select(packetEnqued => packetTypeReadModel[packetEnqued.PacketId]) .Do(packetEnqueued => Debug.Log($"Packet Enqueued {packetEnqueued}")) .Subscribe(color => consumerPacket.EnqueuePacket(color)); }
public FindValueResult <string, FileId[]> FindValue(string key, NodeIdentifier <string> callerIdentifier) { var inValue = new FindValueRequest(); inValue.key = key; inValue.callerIdentifier = callerIdentifier; FindValueResponse retVal = ((IReverseIndexServiceContract)(this)).FindValue(inValue); return(retVal.FindValueResult); }
public bool Remove(string key, NodeIdentifier <string> callerIdentifier) { var inValue = new RemoveRequest(); inValue.key = key; inValue.callerIdentifier = callerIdentifier; RemoveResponse retVal = ((IReverseIndexServiceContract)(this)).Remove(inValue); return(retVal.RemoveResult); }
public override int GetHashCode() { int hashcode = 157; unchecked { hashcode = (hashcode * 397) + Ip.GetHashCode(); hashcode = (hashcode * 397) + MetaPort.GetHashCode(); hashcode = (hashcode * 397) + NodeIdentifier.GetHashCode(); hashcode = (hashcode * 397) + DataPort.GetHashCode(); } return(hashcode); }
public bool SpoolMessage(MailMessage message, out string reply) { reply = null; string subject = message.Subject; if (String.IsNullOrEmpty(subject)) { reply = "Missing subject"; return(false); } string[] parts = subject.Split('|'); if (parts.Length == 0) { reply = "Missing command arguments seperator"; return(false); } if (parts[0] == "NI") { using (XBee xbee = new XBee("COM4", ApiType.Enabled)) { xbee.Open(); XBeeResponse res = xbee.Execute(new NodeIdentifierCommand()); if (res == null) { reply = "Could not execute NI command"; return(false); } AtCommandResponse atr = res as AtCommandResponse; if (atr != null) { NodeIdentifier ni = NodeIdentifier.Parse(atr); if (ni != null) { reply = "XBee module response: " + ni.GetType() + " = " + ni.Identifier; return(false); } } } } return(true); }
/// <summary> /// Appends a single node definition to the output stream. /// </summary> /// <param name="node">The node to append.</param> protected virtual void WriteNode(INode node) { long id = NodeIdentifier.GetIdentifier(node); WriteIdentifier(id.ToString()); if (NodeAdorner != null) { WriteEntityAttributes(NodeAdorner.GetNodeAttributes(node, id)); } WriteSemicolon(); Writer.WriteLine(); }
private void BuildNetwork(IEnqueueCommand <NetworkCommand> commandQueue) { var node1 = new NodeIdentifier(); var node2 = new NodeIdentifier(); var node3 = new NodeIdentifier(); var linkAttributes = new LinkAttributes(2, 2f); commandQueue.Enqueue(BuildAddNodeCommand(node1, 0, 0)); commandQueue.Enqueue(BuildAddNodeCommand(node2, 4, 4)); commandQueue.Enqueue(BuildAddNodeCommand(node3, -4, -4)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(node1, PortDirection.Right, node2, PortDirection.Bottom, linkAttributes)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(node1, PortDirection.Bottom, node3, PortDirection.Right, linkAttributes)); }
/// <summary> /// Appends an edge to the output stream. /// </summary> /// <param name="edge">The edge to append.</param> protected virtual void WriteEdge(IEdge edge) { long sourceId = NodeIdentifier.GetIdentifier(edge.Origin); long targetId = NodeIdentifier.GetIdentifier(edge.Target); WriteIdentifier(sourceId.ToString()); Writer.Write(" -> "); WriteIdentifier(targetId.ToString()); if (EdgeAdorner != null) { WriteEntityAttributes(EdgeAdorner.GetEdgeAttributes(edge, sourceId, targetId)); } WriteSemicolon(); Writer.WriteLine(); }
public IPromise Send(IMessage message, CallbackPoint callbackPoint) { message.Domain = securityProvider.GetDomain(message.Identity); var promise = new Promise(Interlocked.Increment(ref lastCallbackKey)); message.RegisterCallbackPoint(new Messaging.CallbackPoint { Key = promise.CallbackKey.Value, Messages = callbackPoint.MessageIdentifiers, ReceiverIdentity = ReceiverIdentifier, ReceiverNodeIdentity = NodeIdentifier.Local() }); callbackHandlers.Push(promise, callbackPoint.MessageIdentifiers); messageRouter.Route(message); return(promise); }
public void NodeIdentifier_Create() { var identifier = NodeIdentifier.Get(123); Assert.AreEqual(123, identifier.Id, "#1 identifier is incorrect."); Assert.IsNull(identifier.Path, "#2 identifier is incorrect."); identifier = NodeIdentifier.Get("/Root/P1"); Assert.AreEqual("/Root/P1", identifier.Path, "#3 identifier is incorrect."); Assert.AreEqual(0, identifier.Id, "#4 identifier is incorrect."); identifier = NodeIdentifier.Get("123"); Assert.AreEqual(123, identifier.Id, "#5 identifier is incorrect."); Assert.IsNull(identifier.Path, "#6 identifier is incorrect."); short shortId = 123; identifier = NodeIdentifier.Get(shortId); Assert.AreEqual(shortId, identifier.Id, "#7 identifier is incorrect."); Assert.IsNull(identifier.Path, "#8 identifier is incorrect."); }
private void BuildNetwork(IEnqueueCommand <NetworkCommand> commandQueue) { var gateway = new NodeIdentifier(); var router = new NodeIdentifier(); var consumer1 = new NodeIdentifier(); var consumer2 = new NodeIdentifier(); var consumer3 = new NodeIdentifier(); var linkAttributes = new LinkAttributes(2, 2f); commandQueue.Enqueue(new NetworkCommand.AddGatewayNode(gateway, new NodePosition(0, 4), 50)); commandQueue.Enqueue(new NetworkCommand.AddRouterNode(router, new NodePosition(0, 0), 5)); commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer1, new NodePosition(4, -4), 5)); commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer2, new NodePosition(-4, -4), 5)); commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer3, new NodePosition(0, -4), 5)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(gateway, PortDirection.Bottom, router, PortDirection.Top, new LinkAttributes(50, .5f))); commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Right, consumer1, PortDirection.Left, linkAttributes)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Left, consumer2, PortDirection.Right, linkAttributes)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Bottom, consumer3, PortDirection.Top, linkAttributes)); }
private HermiteDataGrid getGrid(LodOctreeNode node, int minNodeSize, Func <Vector3, float> density) { var nId = new NodeIdentifier(node); if (cachedGrids.ContainsKey(nId)) { return(cachedGrids[nId]); } var currScaling = node.size / minNodeSize; // Then we add another +1 to be able to connect the gaps between the hermite grids //TODO: do lod stitching here var gridSize = minNodeSize + 1; var grid = HermiteDataGrid.CopyGrid( new DensityFunctionHermiteGrid(v => density(v * currScaling + (Vector3)node.LowerLeft.ToVector3()), new Point3(gridSize, gridSize, gridSize))); cachedGrids[nId] = grid; return(grid); }
public void NodeIdentifier_Create() { Providers.Instance.DataProvider = new InMemoryDataProvider(); Providers.Instance.InitializeDataStore(); var identifier = NodeIdentifier.Get(123); Assert.AreEqual(123, identifier.Id, "#1 identifier is incorrect."); Assert.IsNull(identifier.Path, "#2 identifier is incorrect."); identifier = NodeIdentifier.Get("/Root/P1"); Assert.AreEqual("/Root/P1", identifier.Path, "#3 identifier is incorrect."); Assert.AreEqual(0, identifier.Id, "#4 identifier is incorrect."); identifier = NodeIdentifier.Get("123"); Assert.AreEqual(123, identifier.Id, "#5 identifier is incorrect."); Assert.IsNull(identifier.Path, "#6 identifier is incorrect."); short shortId = 123; identifier = NodeIdentifier.Get(shortId); Assert.AreEqual(shortId, identifier.Id, "#7 identifier is incorrect."); Assert.IsNull(identifier.Path, "#8 identifier is incorrect."); }
public override bool RemoveInto(string key, FileId value, NodeIdentifier<string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> RemoveInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); return base.RemoveInto(key, value, callerIdentifier); }
internal void Accept(NodeIdentifier ident) { builder.currentLineNumber = ident.EndLine; builder.Load(ident.image); }
void ASTVisitor.Accept(NodeIdentifier value) { Accept(value); }
public virtual NodeMetadata GetMetadata() { IPAddress external = IPAddress.Any; IPAddress local = IPAddress.Any; //Task.Factory.StartNew(async () => //{ // external = await _natUtils.GetExternalIPAddress(); // local = await _natUtils.GetLocalIPAddress(); //}).Wait(); AddressingInfo addrInfo = new AddressingInfo(); addrInfo.PrivateEndpoint = new EndpointData() { IPAddress = local.ToString(), Port = 9999 }; addrInfo.PublicEndpoint = new EndpointData() { IPAddress = external.ToString(), Port = 9999 }; NodeIdentifier identifier = new NodeIdentifier() { Name = Environment.MachineName, NodeId = Guid.NewGuid().ToString() }; return new NodeMetadata() { AddressingInfo = addrInfo, Identifier = identifier, TimeStamp = DateTime.Now }; }
public override void StoreInto(FileId key, FileLocation value, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> StoreInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); base.StoreInto(key, value, callerIdentifier); }
public ProcessNodeQueuePeriodically(NodeIdentifier nodeId, IEnqueueCommand <NetworkCommand> commandQueue, TimeSpan period) { Observable.Interval(period) .Subscribe(_ => commandQueue.Enqueue(new NetworkCommand.ProcessNodeQueue(nodeId))); }
public override bool Remove(FileId key, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> Remove(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return base.Remove(key, callerIdentifier); }
public override void StoreInto(FileId key, FileLocation value, NodeIdentifier <FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> StoreInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); base.StoreInto(key, value, callerIdentifier); }
public override HeartBeat<FileId> Ping(NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> Ping({0}) : {1}", callerIdentifier, KadCore.NodeIdentifier); return base.Ping(callerIdentifier); }
public override void Store(string key, IEnumerable<FileId> value, NodeIdentifier<string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> Store(key: {0}, value: {1}, callerIdentifier: {2})", key, value.WriteValues(), callerIdentifier); base.Store(key, value, callerIdentifier); }
public override void StoreInto(string key, FileId value, NodeIdentifier<string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> StoreInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); base.StoreInto(key, value, callerIdentifier); }
public override FindNodeResult<FileId> FindNode(FileId key, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> FindNode(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return base.FindNode(key, callerIdentifier); }
private Node PrimaryExpression(bool allowPostfixInvocation = true) { if (!TokensRemain) return null; var loc = Location; Node node; switch (Current.type) { case WILDCARD: // If we aren't in a truly anon function, we ignore this if (CurrentFunction != null && CurrentFunction.fullAnon && CurrentFunction.paramNames.Count == 0) CurrentFunction.paramNames.Add(null); node = new NodeWildcard(loc); Advance(); break; case PARAM_INDEX: var index = (uint)Current.intValue; // If we aren't in a truly anon function, we ignore this if (CurrentFunction != null && CurrentFunction.fullAnon) while (CurrentFunction.paramNames.Count <= index) CurrentFunction.paramNames.Add(null); node = new NodeParamIndex(loc, index); Advance(); break; case IDENTIFIER: node = new NodeIdentifier(loc, Current.image); Advance(); break; case SYMBOL: node = new NodeSymbol(loc, Current.image); Advance(); break; case NULL: node = new NodeNull(loc); Advance(); break; case TRUE: case FALSE: node = new NodeBool(loc, Check(TRUE)); Advance(); break; case ENDL: node = new NodeEndL(loc); Advance(); break; case THIS: node = new NodeThis(loc); Advance(); break; case SELF: node = new NodeSelf(loc); Advance(); break; case INT: node = new NodeInt(loc, Current.intValue); Advance(); break; case FLOAT: node = new NodeFloat(loc, Current.floatValue); Advance(); break; case STRING: node = new NodeString(loc, Current.image); Advance(); break; case OPEN_BRACE: Advance(); if (Check(CLOSE_BRACE)) { // 0-length tuple: node = new NodeTuple(loc, new List<Node>()); node.EndLine = Current.location.line; Advance(); } else { var values = CommaExpressions(); if (values.Count != 1) { // This is a tuple :D node = new NodeTuple(loc, values); Expect(CLOSE_BRACE, "Closing brace (')') expected to end tuple expression."); node.EndLine = tokens[-1].location.line; } else { Expect(CLOSE_BRACE, "Closing brace (')') expected to surround expression."); // Just an expression, carry on: node = values[0]; } } break; case OPEN_SQUARE_BRACE: // This is a list :D Advance(); node = new NodeList(loc, (TokensRemain && Current.type != CLOSE_SQUARE_BRACE) ? CommaExpressions() : new List<Node>()); Expect(CLOSE_SQUARE_BRACE, "Closing square brace (']') expected to end list expression."); node.EndLine = tokens[-1].location.line; break; case OPEN_CURLY_BRACE: // This is a code block :D Advance(); var exprs = new List<Node>(); while (!Check(CLOSE_CURLY_BRACE)) { if (!TokensRemain) { log.Error(tokens[-1].location, "Unfinished block. A closing curly brace ('}') should be used to end blocks."); break; } var expr = Expression(); if (expr != null) exprs.Add(expr); } Expect(CLOSE_CURLY_BRACE, "Closing curly brace ('}') expected to end block."); node = new NodeBlock(loc, exprs); node.EndLine = tokens[-1].location.line; break; case TAILREC: Advance(); Expect(OPEN_BRACE, "Expected an open brace ('(') to begin the tailrec argument list."); List<Node> args; if (!Check(CLOSE_BRACE)) args = CommaExpressions(); else args = new List<Node>(); Expect(CLOSE_BRACE, "Expected a close brace (')') to end the tailrec argument list."); node = new NodeTailRec(loc, args); break; // These can't be postfix'd, so we don't allow it. case OPERATOR: var prefix = Current.image; Advance(); if (!TokensRemain) log.Error(loc, "An expression is expected after prefix operator, but the end of the file was reached."); var prefixValue = PrimaryExpression(); return new NodePrefix(loc, prefix, prefixValue); case NOT: Advance(); if (!TokensRemain) log.Error(loc, "An expression is expected after the 'not' keyword, but the end of the file was reached."); return new NodeNot(loc, Expression()); case THROW: Advance(); if (!TokensRemain) log.Error(loc, "An expression is expected after the 'throw' keyword, but the end of the file was reached."); return new NodeThrow(loc, Expression()); case YIELD: Advance(); if (!TokensRemain) log.Error(loc, "An expression is expected after the 'yield' keyword, but the end of the file was reached."); return new NodeYield(loc, Expression()); case RES: Advance(); if (!TokensRemain) log.Error(loc, "An expression is expected after the 'res' keyword, but the end of the file was reached."); return new NodeRes(loc, Expression()); case BREAK: Advance(); string bLabel = null; if (Check(IDENTIFIER) && Current.location.line == loc.line) { bLabel = Current.image; Advance(); } return new NodeBreak(loc, bLabel); case CONT: Advance(); string cLabel = null; if (Check(IDENTIFIER) && Current.location.line == loc.line) { cLabel = Current.image; Advance(); } return new NodeCont(loc, cLabel); case FN: return ParseFn(); case GEN: return ParseFn(true); case VAR: return ParseVar(); case IF: return ParseIf(); case WHILE: return ParseWhile(); case TRY: return ParseTry(); case ITER: return ParseIter(); case EACH: return ParseEach(); // And here, we don't know what they want... oops. default: log.Error(Location, "Unexpected token '{0}', skipping...", Current.ToString()); // We don't know what to do with this, let's skip and try to recover. Advance(); // Error saying we couldn't understand the token: // return a new primary expression. return PrimaryExpression(); } // TODO postfix return Postfix(node, allowPostfixInvocation); }
public override bool Remove(string key, NodeIdentifier<string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> Remove(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return base.Remove(key, callerIdentifier); }
public override bool RemoveInto(FileId key, FileLocation value, NodeIdentifier <FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> RemoveInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); return(base.RemoveInto(key, value, callerIdentifier)); }
public override HeartBeat<string> Ping(NodeIdentifier<string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> Ping({0}) : {1}", callerIdentifier, KadCore.NodeIdentifier); return base.Ping(callerIdentifier); }
// IO public void Load(string path) { using (BinaryReader br = new BinaryReader(File.OpenRead(path))) { string magicWord = br.ReadString(); if (magicWord != "CIRCUITZ") { return; } Reset(); int nodeCount = br.ReadInt32(); for (int i = 0; i < nodeCount; i++) { NodeIdentifier type = (NodeIdentifier)br.ReadUInt32(); int inputCount = br.ReadInt32(); int outputCount = br.ReadInt32(); Point pos = new Point(br.ReadInt32(), br.ReadInt32()); switch (type) { case NodeIdentifier.None: break; case NodeIdentifier.Constant: bool value = br.ReadBoolean(); AddNode(new Constant { Position = pos, Value = value }); break; case NodeIdentifier.And: AddNode(new And(inputCount) { Position = pos }); break; case NodeIdentifier.Or: AddNode(new Or(inputCount) { Position = pos }); break; case NodeIdentifier.Xor: AddNode(new Xor(inputCount) { Position = pos }); break; case NodeIdentifier.Buffer: AddNode(new Buffer { Position = pos }); break; case NodeIdentifier.Not: AddNode(new Not { Position = pos }); break; case NodeIdentifier.Nand: AddNode(new Nand(inputCount) { Position = pos }); break; case NodeIdentifier.Nor: AddNode(new Nor(inputCount) { Position = pos }); break; case NodeIdentifier.Xnor: AddNode(new Xnor(inputCount) { Position = pos }); break; case NodeIdentifier.Adder: AddNode(new Adder(inputCount) { Position = pos }); break; case NodeIdentifier.SRLatch: AddNode(new SRLatch { Position = pos }); break; case NodeIdentifier.Timer: uint interval = br.ReadUInt32(); AddNode(new Timer { Position = pos, Interval = interval }); break; } } int wireCount = br.ReadInt32(); for (int i = 0; i < wireCount; i++) { Node node1 = Nodes[br.ReadInt32()]; Node node2 = Nodes[br.ReadInt32()]; int inputIndex = br.ReadInt32(); int outputIndex = br.ReadInt32(); Wire(node1, node2, inputIndex, outputIndex); } } }
public override bool RemoveInto(FileId key, FileLocation value, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> RemoveInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); return base.RemoveInto(key, value, callerIdentifier); }