Esempio n. 1
0
        public void TestHandoverEventActionCallHandover()
        {
            int dropped = 0;
            int createdhandover = 0;
            int createdend = 0;

            var data = new CallData( 1, 5, 20, 0 );
            var tostation = new Station( 1, 0, 10, 10 );

            var fromstation = new Station( 1, 0, 0, 10 );
            fromstation.ClaimChannel( true );

            var e = new HandoverEvent(
                fromstation,
                tostation,
                () => { dropped++; },
                ( d, cd ) => { createdend++; },
                ( d, cd ) =>
                {
                    createdhandover++;
                    Assert.AreEqual( data, cd );
                    Assert.AreEqual( (uint) 15, d );
                },
                5,
                data );

            e.Action();

            Assert.AreEqual( 0, dropped );
            Assert.AreEqual( 0, createdend );
            Assert.AreEqual( 1, createdhandover );
        }
Esempio n. 2
0
 /// <summary>
 /// Adds the hangup event.
 /// </summary>
 /// <param name="triggertime">The triggertime.</param>
 /// <param name="data">The data.</param>
 internal void AddHangupEvent(uint triggertime, CallData data)
 {
     // Add the hang up event to queue
     AddEvent(
         triggertime,
         new HangupEvent(
             _stations.GetStationForPosition(data.EndPosition, false),
             triggertime,
             _dataGatherer.SignalCallHangup                     // callback for call hangup
             ));
 }
Esempio n. 3
0
 public bool Equals(CallData other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.Speed == Speed && other.StartPosition == StartPosition && other.Duration == Duration && other.StartTime == StartTime);
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HandoverEvent"/> class.
 /// </summary>
 /// <param name="fromStation">The station that the call is being transferred from.</param>
 /// <param name="toStation">The station that the call is being transferred to.</param>
 /// <param name="dropped">Action that records if a call is dropped.</param>
 /// <param name="newCallHangupEventCallBack">Call back that adds a new hangu event to action queue.</param>
 /// <param name="newCallHandoverEventCallBack">Call back that adds a new handover event to action queue.</param>
 /// <param name="triggerTime">The trigger time for this event.</param>
 /// <param name="data">The call data associated with.</param>
 public HandoverEvent(
     Station fromStation,
     Station toStation,
     Action dropped,
     Action <uint, CallData> newCallHangupEventCallBack,
     Action <uint, CallData> newCallHandoverEventCallBack,
     uint triggerTime,
     CallData data)
     : base(triggerTime)
 {
     _fromStation = fromStation;
     _toStation   = toStation;
     _dropped     = dropped;
     _newCallHangupEventCallBack   = newCallHangupEventCallBack;
     _newCallHandoverEventCallBack = newCallHandoverEventCallBack;
     _data = data;
 }
Esempio n. 5
0
        /// <summary>
        /// Adds the call event.
        /// </summary>
        /// <param name="lastcallstarttime">The lastcallstarttime.</param>
        internal void AddCallEvent(uint lastcallstarttime)
        {
            CallData newcall = _generator.GenerateRandomCall(lastcallstarttime);

            // add the new call event
            AddEvent(
                newcall.StartTime,
                new CallEvent(
                    _stations.GetStationForPosition(newcall.StartPosition),
                    newcall,
                    _dataGatherer.SignalCallBlocked,
                    _dataGatherer.SignalCallStarted,
                    AddCallEvent,                     // callback for adding new call events
                    AddHangupEvent,                   // callback for adding hangup events
                    AddHandoverEvent,                 // callback for adding handover events
                    newcall.StartTime));
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CallEvent"/> class.
 /// </summary>
 /// <param name="baseStation">The base station.</param>
 /// <param name="data">The data.</param>
 /// <param name="blocked">The blocked.</param>
 /// <param name="callstart">The callstart.</param>
 /// <param name="addNextCallCallBack">The add next call call back.</param>
 /// <param name="newCallHangupEventCallBack">The new call hangup event call back.</param>
 /// <param name="newCallHandoverEventCallBack">The new call handover event call back.</param>
 /// <param name="triggerTime">The trigger time.</param>
 public CallEvent(
     Station baseStation,
     CallData data,
     Action blocked,
     Action callstart,
     Action <uint> addNextCallCallBack,
     Action <uint, CallData> newCallHangupEventCallBack,
     Action <uint, CallData> newCallHandoverEventCallBack,
     uint triggerTime)
     : base(triggerTime)
 {
     _baseStation                  = baseStation;
     _data                         = data;
     _blocked                      = blocked;
     _callstart                    = callstart;
     _addNextCallCallBack          = addNextCallCallBack;
     _newCallHangupEventCallBack   = newCallHangupEventCallBack;
     _newCallHandoverEventCallBack = newCallHandoverEventCallBack;
 }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CallEvent"/> class.
        /// </summary>
        /// <param name="baseStation">The base station.</param>
        /// <param name="data">The data.</param>
        /// <param name="blocked">The blocked.</param>
        /// <param name="callstart">The callstart.</param>
        /// <param name="addNextCallCallBack">The add next call call back.</param>
        /// <param name="newCallHangupEventCallBack">The new call hangup event call back.</param>
        /// <param name="newCallHandoverEventCallBack">The new call handover event call back.</param>
        /// <param name="triggerTime">The trigger time.</param>
        public CallEvent(
			Station baseStation,
			CallData data,
			Action blocked,
			Action callstart,
			Action<uint> addNextCallCallBack,
			Action<uint, CallData> newCallHangupEventCallBack,
			Action<uint, CallData> newCallHandoverEventCallBack,
			uint triggerTime )
            : base(triggerTime)
        {
            _baseStation = baseStation;
            _data = data;
            _blocked = blocked;
            _callstart = callstart;
            _addNextCallCallBack = addNextCallCallBack;
            _newCallHangupEventCallBack = newCallHangupEventCallBack;
            _newCallHandoverEventCallBack = newCallHandoverEventCallBack;
        }
Esempio n. 8
0
        public void TestCreateEventActionEnd()
        {
            int blocked = 0;
            int started = 0;
            int created = 0;
            int createdhandover = 0;
            int createdend = 0;

            var data = new CallData( 1, 5, 3, 0 );
            var station = new Station( 2, 0, 0, 10 );

            var e = new CallEvent(
                station,
                data,
                () => { blocked++; },
                () => { started++; },
                ( d ) =>
                {
                    created++;
                    Assert.AreEqual( (uint) 0, d );
                },
                ( d, cd ) =>
                {
                    createdend++;
                    Assert.AreEqual( (uint) 3, d );
                    Assert.AreEqual( data, cd );
                },
                ( d, cd ) =>
                {
                    createdhandover++;
                    Assert.AreEqual( data, cd );
                },
                0 );

            e.Action();

            Assert.AreEqual( 0, blocked );
            Assert.AreEqual( 1, created );
            Assert.AreEqual( 1, started );
            Assert.AreEqual( 1, createdend );
            Assert.AreEqual( 0, createdhandover );
        }
Esempio n. 9
0
 public CallGen( CallData[] datas )
 {
     _count = 0;
     _datas = datas;
 }
Esempio n. 10
0
 static EventQueue CreateQueue( CallData[] data, uint stationcount, uint highwaylength, uint channels, uint reserved )
 {
     return new EventQueue( new DataGathererStub(), new CallGen( data ), stationcount, highwaylength, channels, reserved );
 }
Esempio n. 11
0
 public bool Equals( CallData other )
 {
     if( ReferenceEquals( null, other ) )
         return false;
     if( ReferenceEquals( this, other ) )
         return true;
     return other.Speed == Speed && other.StartPosition == StartPosition && other.Duration == Duration && other.StartTime == StartTime;
 }
Esempio n. 12
0
 /// <summary>
 /// Adds the hangup event.
 /// </summary>
 /// <param name="triggertime">The triggertime.</param>
 /// <param name="data">The data.</param>
 internal void AddHangupEvent( uint triggertime, CallData data )
 {
     // Add the hang up event to queue
     AddEvent(
         triggertime,
         new HangupEvent(
             _stations.GetStationForPosition( data.EndPosition, false ),
             triggertime,
             _dataGatherer.SignalCallHangup // callback for call hangup
             ) );
 }
Esempio n. 13
0
        /// <summary>
        /// Adds the handover event.
        /// </summary>
        /// <param name="triggertime">The triggertime.</param>
        /// <param name="data">The data.</param>
        internal void AddHandoverEvent( uint triggertime, CallData data )
        {
            // get the position of the call at triggertime
            uint currentPosition = data.GetPositionForAbsoluteTime( triggertime );

            // find out which station we handover from, ( modify argument to add a small buffer, in case of rounding errors)
            Station handoverFromStation = _stations.GetStationForPosition( (uint) Math.Abs( currentPosition - ( (long) _stationRangeDiameter / 2 ) ) );

            // find out which station we handover to, ( modify argument to add small buffer in case of rounding errors)
            Station handoverToStation = _stations.GetStationForPosition( currentPosition + ( _stationRangeDiameter / 4 ), true );

            // Add the handover event to queue
            //		if handover is made from last station to first, modify call data to reflect this change. (using data.Wrap())
            AddEvent(
                triggertime,
                new HandoverEvent(
                    handoverFromStation,
                    handoverToStation,
                    _dataGatherer.SignalCallDropped, // callback for if call is dropped
                    AddHangupEvent, // callback to add a hangup event
                    AddHandoverEvent, // callback to add a handover event
                    triggertime,
                    handoverToStation.Equals( _stations.First )
                        ? data.Wrap( triggertime )
                        : data ) );
        }