public void OnRequest( IDataObjectOutputStream outStream, Query query, IZone zone, IMessageInfo info ) { // To be a successful publisher of data using the ADK, follow these steps // 1) Examine the query conditions. If they are too complex for your agent, // throw the appropriate SIFException // This example agent uses the autoFilter() capability of DataObjectOutputStream. Using // this capability, any object can be written to the output stream and the stream will // filter out any objects that don't meet the conditions of the Query. However, a more // robust agent with large amounts of data would want to pre-filter the data when it does its // initial database query. outStream.Filter = query; Console.WriteLine( "Responding to SIF_Request for StudentPersonal" ); // 2) Write any data to the output stream foreach ( StudentPersonal sp in fData ) { outStream.Write( sp ); } }
/// <summary> /// The constructor creates a Jet action for use by /// an emitter. To add a Jet to all particles created by an emitter, use the /// emitter's addAction method. /// /// @see org.flintparticles.emitters.Emitter#addAction() /// </summary> /// <param name="accelerationX">The x coordinate of the acceleration to apply, in pixels /// per second per second.</param> /// <param name="accelerationY">The y coordinate of the acceleration to apply, in pixels /// per second per second.</param> /// <param name="zone">The zone in which to apply the acceleration.</param> /// <param name="invertZone">If false (the default) the acceleration is applied only to particles inside /// the zone. If true the acceleration is applied only to particles outside the zone.</param> public Jet(double accelerationX, double accelerationY, IZone zone, bool invertZone) { m_x = accelerationX; m_y = accelerationY; m_zone = zone; m_invert = invertZone; }
/// <summary> Constructs an exception to wrap one or more SIF_Errors received from an /// inbound SIF_Ack message. This form of constructor is only called by /// the Adk. /// </summary> public SifException( SIF_Ack ack, IZone zone ) : base(null, zone) { fAck = ack; fError = ack != null ? ack.SIF_Error : null; }
public Team(IZone zone, JoinCondition join_condition) { _JoinCondidion = join_condition; _Zone = zone; _Handlers = new Utility.TUpdater<MemberHandler>(); }
/// <summary> /// Creates an uninitialized, sealed room. /// </summary> /// <param name="name">The name of the room.</param> /// <param name="owner">The zone that owns this room.</param> /// <returns>Returns an uninitialized room instance</returns> public Task<IRoom> CreateRoom(string name, IZone owner) { var room = new MudRoom(this.doorwayFactory, owner); room.SealRoom(); return Task.FromResult((IRoom)room); }
public float ComputeUtility(IZone o, IZone d) { float sum = 0f; var flatO = this.ZoneSystem.GetFlatIndex( o.ZoneNumber ); var flatD = this.ZoneSystem.GetFlatIndex( d.ZoneNumber ); bool any = false; var zoneIndex = ( flatO * this.Zones.Length + flatD ) * this.Modes.Length; for ( int mode = 0; mode < this.Modes.Length; mode++ ) { EnsureResult( flatO, mode ); if ( this.Modes[mode].Feasible( o, d, this.SimulationTime ) ) { var res = this.Modes[mode].CalculateV( o, d, this.SimulationTime ); if ( !float.IsNaN( res ) ) { float v = (float)Math.Exp( res ); if ( this.Adjustments != null ) { v *= this.Adjustments.GiveAdjustment( o, d, mode, (int)this.CurrentInteractiveCategory ); } this.CurrentUtility[zoneIndex + mode] = v; sum += v; any = true; } } } return any ? (float)sum : float.NaN; }
/// <summary> Constructs an exception with a detailed message that occurs in the /// context of a zone /// </summary> /// <param name="msg">A message describing the exception /// </param> /// <param name="zone">The zone associated with the exception /// </param> public AdkException(string msg, IZone zone) : base(msg) { fZone = zone; fZoneId = zone == null ? null : zone.ZoneId; }
public Adventure(Adventurer adventurer, Remoting.ISoulBinder binder, IZone zone) { _Adventurer = adventurer; _Zone = zone; this._Binder = binder; _Squad = new Squad(adventurer.Formation ,_Adventurer.Teammates, _Adventurer.Controller); }
public override ISifResponseIterator<StudentPersonal> GetSifResponses(Query query, IZone zone) { StudentPersonalIterator studentPersonalIterator = null; if (query == null) { throw new ArgumentNullException("query"); } if (query.HasConditions) { string key = ExtractPrimaryKey(query); if (key == null) { throw new SifException(SifErrorCategoryCode.RequestResponse, SifErrorCodes.REQRSP_UNSUPPORTED_QUERY_9, "SIF Query not supported.", zone); } else { if (log.IsDebugEnabled) log.Debug("SIF Response requested for StudentPersonal with a SIF RefId of " + key + "."); studentPersonalIterator = new StudentPersonalIterator(key); } } else { if (log.IsDebugEnabled) log.Debug("SIF Response requested for all StudentPersonals."); studentPersonalIterator = new StudentPersonalIterator(null); } return studentPersonalIterator; }
public float ComputeAttraction(float[] flatAttraction, IZone[] zones, int numberOfZones) { float totalAttractions = 0; var demographics = this.Root.Demographics; var flatEmploymentRates = demographics.JobOccupationRates.GetFlatData(); var flatJobTypes = demographics.JobTypeRates.GetFlatData(); for ( int i = 0; i < numberOfZones; i++ ) { var total = 0f; foreach ( var empRange in this.EmploymentStatusCategory ) { for ( int emp = empRange.Start; emp <= empRange.Stop; emp++ ) { foreach ( var occRange in this.EmploymentStatusCategory ) { for ( int occ = occRange.Start; occ <= occRange.Stop; occ++ ) { var temp = flatEmploymentRates[i][emp][occ]; temp *= flatJobTypes[i][emp]; temp *= zones[i].Employment; total += temp; } } } } totalAttractions += ( flatAttraction[i] = total ); } return totalAttractions; }
public override float CalculateV(IZone origin, IZone destination, Time time) { if ( this.IsContained( origin, destination ) ) { return this.Constant; } return 0f; }
public override float CalculateV(IZone origin, IZone destination, XTMF.Time time) { if ( IsContained( origin, destination ) ) { return this.Aivtt * this.NetworkData.TravelTime( origin, destination, time ).ToMinutes(); } return 0; }
public override float CalculateV(IZone origin, IZone destination, Time time) { if ( IsContained( origin, destination ) ) { return this.Cost * this.NetworkData.TravelCost( origin, destination, time ); } return 0; }
/// <summary> Constructs an exception to wrap one or more SIF_Errors received from an /// inbound SIF_Ack message. This form of constructor is only called by /// the Adk. /// </summary> public SifException( string msg, SIF_Ack ack, IZone zone ) : base(msg, zone) { fAck = ack; fError = ack != null ? ack.SIF_Error : null; }
protected Acces(string nom, IZone zoneFrom, IZone zoneTo) { this.Nom = nom; ZoneFrom = zoneFrom; ZoneTo = zoneTo; zoneFrom.Access.Add(this); zoneTo.Access.Add(this); }
public IZone Other(IZone zone) { if (ZoneFrom == zone) return ZoneTo; if (ZoneTo == zone) return ZoneFrom; return null; }
/// <summary> /// Initializes a new instance of the <see cref="MudRoom"/> class. /// </summary> /// <param name="doorFactory">The door factory used to create new doorway instances.</param> public MudRoom(IDoorwayFactory doorFactory, IZone owner) { this.actors = new List<IActor>(); this.doorways = new List<IDoorway>(); this.doorFactory = doorFactory; this.IsSealed = true; this.Owner = owner; }
public override float CalculateV(IZone origin, IZone destination, Time time) { if ( this.IsContained( origin, destination ) ) { return this.NetworkData.WaitTime( origin, destination, time ).ToMinutes() * this.Wait; } return 0f; }
public override float CalculateV(IZone origin, IZone destination, XTMF.Time time) { if ( this.IsContained( origin, destination ) ) { return this.Factor * ( this.Root.ZoneSystem.Distances[origin.ZoneNumber, destination.ZoneNumber] / 1000f ); } return 0; }
public Household(int id, ITashaPerson[] persons, IVehicle[] vehicles, float expansion, IZone zone) { //this.auxiliaryTripChains = new List<ITripChain>(7); HouseholdId = id; Persons = persons; Vehicles = vehicles; ExpansionFactor = expansion; HomeZone = zone; }
public float CalculateV(IZone origin, IZone destination, Time time) { float total = 0f; for ( int i = 0; i < this.UtilityComponents.Count; i++ ) { total += this.UtilityComponents[i].CalculateV( origin, destination, time ); } return total; }
/** * Creates a SIF_Query element from the specified Adk query object using * zone-specific querying rules * @param query The Query to convert to a SIF_Query * @param zone The IZone to retrieve query settings from, or null * @return a SIF_Query instance */ public static SIF_Query CreateSIF_Query(Query query, IZone zone) { bool allowFieldRestrictions = query.HasFieldRestrictions; if (allowFieldRestrictions && zone != null) { allowFieldRestrictions = !zone.Properties.NoRequestIndividualElements; } return CreateSIF_Query(query, query.EffectiveVersion, allowFieldRestrictions); }
public override float CalculateV(IZone origin, IZone destination, Time time) { var v = base.CalculateV( origin, destination, time ); for ( int i = 0; i < this.UtilityComponents.Count; i++ ) { v += this.UtilityComponents[i].CalculateV( origin, destination, time ); } return v; }
public void OnQueryPending(IMessageInfo info, IZone zone) { Adk.Log.Info ( string.Format ("Requested {0} from {1}", ((SifMessageInfo)info).SIFRequestObjectType.Name, zone.ZoneId)); }
/// <summary> /// Process an event for the StudentPersonal SIF Object. /// </summary> /// <param name="sifEvent">StudentPersonal event received.</param> /// <param name="zone">Zone used.</param> protected override void ProcessEvent(SifEvent<StudentPersonal> sifEvent, IZone zone) { if (!receivedSifRefIds.Contains(sifEvent.SifDataObject.RefId)) { receivedSifRefIds.Add(sifEvent.SifDataObject.RefId); } if (log.IsDebugEnabled) log.Debug("Received a " + sifEvent.EventAction.ToString() + " event for StudentPersonal in Zone " + zone.ZoneId + " with a SifRefId of " + sifEvent.SifDataObject.RefId + ":\n" + sifEvent.SifDataObject.ToXml()); }
public virtual IKey CreatePredictionKey( IZone zone, int index ) { if( zone == null ) throw new ArgumentNullException( "zone" ); var key= zone.Keys.Create( index ); key.CurrentLayout.Current.Visible = false; CustomizePredictionKey( key ); return key; }
public override void ApplyOutboundPolicy(SifMessagePayload msg, IZone zone ) { SifMessageType pload = Adk.Dtd.GetElementType(msg.ElementDef.Name); switch( pload ){ case SifMessageType.SIF_Request: SetRequestPolicy((SIF_Request)msg, zone ); break; } }
public static PolicyManager GetInstance(IZone zone) { lock (getInstanceLock) { if (sInstance == null) { sInstance = (PolicyManager)ObjectFactory.GetInstance().CreateInstance(ObjectFactory.ADKFactoryType.POLICY_MANAGER, zone.Agent); } return sInstance; } }
private float ComputeAttraction(float[] flatAttraction, IZone[] zones, int numberOfZones) { float totalAttractions = 0; var zoneArray = this.Root.ZoneSystem.ZoneArray.GetFlatData(); for ( int i = 0; i < numberOfZones; i++ ) { var temp = zoneArray[i].RetailEmployment; totalAttractions += ( flatAttraction[i] = temp ); } return totalAttractions; }
public Core(Regulus.Remoting.ISoulBinder binder, IStorage storage, IZone zone ) { _Zone = zone; Storage = storage; _Binder = binder; _StageMachine = new Regulus.Utility.StageMachine(); binder.BreakEvent += _OnInactive; _StatusEvent += (s) => { }; }
public float CalculateV(IZone origin, IZone destination, Time time) { throw new NotImplementedException("This mode is designed for Tasha only!"); }