protected IActorRef CreateTestArea(AreaIdentifier areaIdentifier = null) { if (areaIdentifier is null) { areaIdentifier = new AreaIdentifier("North"); } return(Sys.ActorOf(SensorAreaActor.Props(areaIdentifier))); }
/** * TODO write this up */ public override Scaled Origin(AreaIdentifier id) { if(id.End) { // get the origin for this node. return 0; } else if( id.Current == 0) { // get the origin for the child node id.MoveNext(); return child.Origin(id); } else { // bad monkey throw new InvalidIdentifier(); } }
/** * not supported on simple nodes * TODO find out why */ public override Scaled RightSide(AreaIdentifier id) { throw new InvalidOperation(); }
/** * if the id id empty (at a terminal node), return 0, * otherwise throw an invalid id exception * TODO figure out why we do this */ public override Scaled Origin(AreaIdentifier id) { if(id.End) { return 0; } else throw new InvalidIdentifier(); }
/** * simple areas are terminsl nodes, so make sure the identifer * is empty at this point, and return this node, otherwise * throw an invalid id exception */ public override Area GetArea(AreaIdentifier identifier) { if(identifier.End) { return this; } else throw new InvalidIdentifier(); }
/** * get the right side value. * the identier is only valid if it is for the child * node, or one of the child node's descendants. a * bin container can not have a right side value. */ public override Scaled RightSide(AreaIdentifier id) { if(id.End) { throw new InvalidOperation(); } else if(id.Current == 0) { id.MoveNext(); return child.RightSide(id); } else { throw new InvalidIdentifier(); } }
/** * create an identifier for a descendant area. * as a BinContainerArea can only have one direct child area, * the only valie identifiers are ones that are at the end of * thier path, indicating that it identifies this this node, * or an identifier with its' current element being zero, indicating * that the current leg of its's path identifies the zero'th and * only child node. */ public override Area GetArea(AreaIdentifier id) { if(id.End) { return this; } else if(id.Current == 0) { id.MoveNext(); return child.GetArea(id); } else { throw new InvalidIdentifier(); } }
/** * get the width of all nodes up to the identified nodes, * plus the the origin of the identifed node. * This is the relative distance from the identified node's origin * to this node's origin. */ public override Scaled Origin(AreaIdentifier id) { if(id.End) { return 0; } else if(id.Current < content.Length) { Scaled width = 0; // all nodes up to, but not including the identified node for(int i = 0; i < id.Current; i++) { width += content[i].BoundingBox.Width; } return content[id.Current].Origin(id++) + width; } else { throw new InvalidIdentifier(); } }
public static Props Props(AreaIdentifier id) => Akka.Actor.Props.Create(() => new SensorAreaActor(id));
public SensorAreaActor(AreaIdentifier id) { _id = id; _sensors = new Dictionary <SensorIdentifier, IActorRef>(); _subscribers = new HashSet <IActorRef>(); }
/** * if the id is for this node, return 0. otherwise if the id is for * a child node, return that node's left side. */ public override Scaled RightSide(AreaIdentifier id) { if(id.End) { return 0; } else if(id.Current < content.Length) { return content[id.Current].RightSide(id++); } else { throw new InvalidIdentifier(); } }
/** * get a child area that has a path to this node * if the identifier is at its's last item, this final step * in the path, so return this node, otherwise, if the current step * is valid (less than the size of the child node list, the child * area at the current position will get the path moved to the next * position. If the id is not at it's end, and the current item is * out of range, an invalid id exception is thrown. */ public override Area GetArea(AreaIdentifier id) { if(id.End) { return this; } else if(id.Current < content.Length) { Area current = content[id.Current]; id.MoveNext(); return current.GetArea(id); } else { throw new InvalidIdentifier(); } }