/// <summary> /// Creates a new TrackerUpdateEventArgs /// </summary> /// <param name="state">The current state of the update</param> /// <param name="response">The response of the tracker (if any)</param> public TrackerStateChangedEventArgs(TorrentManager manager, Tracker tracker, TrackerState oldState, TrackerState newState) : base(manager) { this.tracker = tracker; this.oldState = oldState; this.newState = newState; }
void Start() { vuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager(); for (int i = 0; i <= MAX_TRACKER_ID; i++) { trackers[i] = new TrackerState(i); } vuMarkManager.RegisterVuMarkDetectedCallback(target => { // If necessary, here we can access the new VuMarkTarget (determine ID). // But the VuMarkBehavior is not available yet. var tracker = GetTrackerFromTarget(target); if (tracker != null && tracker.id == centerTrackerId) { // Center tracker is automatically registered to the origin. tracker.isRegistered = true; tracker.knownWorldPosition = Vector3.zero; } }); vuMarkManager.RegisterVuMarkBehaviourDetectedCallback(behavior => { // If necessary, here we can access the assigned VuMarkBehavior. // But the VuMarkTarget is not available yet. }); }
/// <summary> /// Creates a new TrackerUpdateEventArgs /// </summary> /// <param name="manager">The manager.</param> /// <param name="tracker">The tracker.</param> /// <param name="oldState">The old state.</param> /// <param name="newState">The new state.</param> public TrackerStateChangedEventArgs(TorrentManager manager, Tracker.Tracker tracker, TrackerState oldState, TrackerState newState) : base(manager) { Tracker = tracker; OldState = oldState; NewState = newState; }
public ScrapeResponse( TrackerState state, int?complete = null, int?incomplete = null, int?downloaded = null, string warningMessage = null, string failureMessage = null ) : base(state, complete, incomplete, downloaded, warningMessage, failureMessage) { }
/// <summary> /// Get the input state of input device identified by handle. /// </summary> public static int GetInputState(int which, ref TrackerState state) { System.IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TrackerState))); int ret = NativeMethods.XDeviceGetInputState(which, ptr); if (ret == 0) { NativeMethods.TrackerStateFromPtr(ref state, ptr); } Marshal.FreeHGlobal(ptr); return(ret); }
/// <summary> /// Construct a new tracker with a default smoothing value. /// </summary> /// <param name="iSmoothSize">The smoothing value.</param> /// <param name="iID">The unique session ID for this tracker.</param> public SpatioTemporalTracker(int iSmoothSize, ulong iID)//, double fMinRadius, double fMaxRadius, double fRadiusExpansion) { // Build a smoothing buffer. this.SmoothingBuffer = new SmoothingBuffer(iSmoothSize); // Save the ID. this.ID = iID; // Save the state. this.eTrackerState = TrackerState.Discover; this.PredictionScale = 100; }
protected TrackerResponse( TrackerState state, int?complete = null, int?incomplete = null, int?downloaded = null, string warningMessage = null, string failureMessage = null ) { State = state; Complete = complete ?? 0; Incomplete = incomplete ?? 0; Downloaded = downloaded ?? 0; WarningMessage = warningMessage ?? ""; FailureMessage = failureMessage ?? ""; }
public AnnounceResponse( TrackerState state, IList <PeerInfo> peers = null, TimeSpan?minUpdateInterval = null, TimeSpan?updateInterval = null, int?complete = null, int?incomplete = null, int?downloaded = null, string warningMessage = null, string failureMessage = null ) : base(state, complete, incomplete, downloaded, warningMessage, failureMessage) { Peers = peers ?? Array.Empty <PeerInfo> (); MinUpdateInterval = minUpdateInterval ?? TimeSpan.FromMinutes(3); UpdateInterval = updateInterval ?? TimeSpan.FromMinutes(30); }
/// <summary> /// Construct a new tracker with a default smoothing value. /// </summary> /// <param name="iSmoothSize">The smoothing value.</param> /// <param name="iID">The unique session ID for this tracker.</param> public SpatioTemporalTracker(int iSmoothSize, ulong iID)//, double fMinRadius, double fMaxRadius, double fRadiusExpansion) { // Build a smoothing buffer. this.SmoothingBuffer = new SmoothingBuffer(iSmoothSize); // Save the ID. this.ID = iID; this.primaryScreen = DeviceUtils.DeviceUtil.GetScreen(Settings.Default.primaryMonitor); Settings.Default.PropertyChanged += SettingsChanged; SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; // Save the state. this.eTrackerState = TrackerState.Discover; this.PredictionScale = Math.Max(primaryScreen.Bounds.Width, primaryScreen.Bounds.Height); }
/// <summary> /// Get the input state of input device identified by handle. /// </summary> public static int GetInputState(int which, ref TrackerState state) { return(NativeMethods.XDeviceGetInputState(which, ref state)); }
public static extern int XDeviceGetInputState(int which, ref TrackerState state);
public static extern int TrackerStateFromPtr(ref TrackerState state, System.IntPtr ptr);
private TrackerState MergeWithExistingData( TrackerState result, out bool needContinue ) { bool needUpdate = false; bool prevTrackExisted = this.prevPagesTrack != null; Data.TrackPointData[] mergedTrack; if ( this.prevPagesTrack == null ) { if ( result.Position == null ) { // this should be ResponseHasNoData - ok, it's really no data then. needContinue = false; return result; } mergedTrack = result.Position.FullTrack; } else { needUpdate = true; if ( result.Position == null ) // i.e. it's ResponseHasNoData for N'th page. mergedTrack = prevPagesTrack; else mergedTrack = this.prevPagesTrack .Union( result.Position.FullTrack ) .OrderByDescending( point => point.ForeignTime ) .Distinct( ) // e.g. page 2 can start with a message that is ending for page 1 (e.g. if a new point passed through to the SPOT server after page 1 retrieved) .ToArray( ); } if ( mergedTrack.Length == 0 ) { // should never happen because this method called for succ.request end only, but let's check anyway Log.ErrorFormat( "mergedResult.Length == 0" ); needContinue = false; return result; } Data.TrackPointData oldestRequestedPoint = mergedTrack.Last( ); Data.TrackPointData newestExistingTrackPoint = null; if ( RequestParams.ExistingTrack != null ) newestExistingTrackPoint = RequestParams.ExistingTrack.FirstOrDefault( ); if ( // no pre-loaded track: newestExistingTrackPoint == null || // there is a gap between just loaded and pre-loaded track - this hardly would happen but let's check: oldestRequestedPoint.ForeignTime > newestExistingTrackPoint.ForeignTime ) { double mergedTrackTotalHours = ( mergedTrack.First( ).ForeignTime - mergedTrack.Last( ).ForeignTime ).TotalHours; needContinue = result.Error == null // check that it's not 50 messages on one page and "no data" on the next one. && result.Position.FullTrack.Length == MaxFeedLength // check that page just loaded by the request is full - hence "result", not "mergedTrack" && mergedTrackTotalHours < LocationRequest.FullTrackPointAgeToIgnore && this.currentRequest.Page < 5; // we need to stop somewhere this.prevPagesTrack = mergedTrack; } else { needContinue = false; Data.TrackPointData[] mergedWithExisting = mergedTrack .Union( RequestParams.ExistingTrack ) .OrderByDescending( point => point.ForeignTime ) .Distinct( ) // tracks would mostly overlap, normally except the newest point (if it's there at all) .ToArray( ); if ( mergedWithExisting.Length != mergedTrack.Length ) { mergedTrack = mergedWithExisting; needUpdate = true; } } if ( needUpdate ) { #region Logging only if ( result.Error != null && ( result.Error.Type != Data.ErrorType.ResponseHasNoData || this.currentRequest.Page == 0 || mergedTrack == null || mergedTrack.Length != MaxFeedLength ) ) // should never happen because here TrackerState is after succ.request, but let's check { string trackStat; if ( mergedTrack == null ) trackStat = "null"; else if ( mergedTrack.Length == 0 ) trackStat = "none"; else trackStat = string.Format( "{0} ## {1} ## {2}", mergedTrack.Length, mergedTrack.First( ), mergedTrack.Last( ) ); Log.ErrorFormat( "result.Error != null: {0} \\ {1}\r\nPage={2}\r\nprevTrackExisted={3}\r\nId2={4}\r\ntrack={5}", Id, result, this.currentRequest.Page, prevTrackExisted, this.currentRequest.TrackerForeignId, trackStat ); } #endregion DateTime thresholdDateTime = mergedTrack.First( ).ForeignTime.AddHours( -FullTrackPointAgeToIgnore ); result = new TrackerState( mergedTrack .Where( point => point.ForeignTime > thresholdDateTime ), result.Tag ); } return result; }
private void LogFailedRequestEnd( AsyncChainedState<TrackerState> asyncChainedState, TrackerState result ) { if ( result.Error.Type == Data.ErrorType.ResponseHasNoData || result.Error.Type == Data.ErrorType.BadTrackerId ) { ErrorHandlingLog.DebugFormat( "Request for {0}, page {1}, lrid {2} failed: {3}", this.Id, this.currentRequest.Page, asyncChainedState.Id, result.Error ); } else { bool shouldReportProblem = true; int consequentErrorsCount = 1; if ( this.consequentErrorsCounter != null ) { consequentErrorsCount = this.consequentErrorsCounter.RequestsErrorsCounter.Increment( out shouldReportProblem ); } string message = string.Format ( "Request for {0}, page {1}, lrid {2} failed: {3}. That's a consequent request error #{4}", this.Id, this.currentRequest.Page, asyncChainedState.Id, result.Error, consequentErrorsCount ); if ( shouldReportProblem ) ErrorHandlingLog.Error( message ); else ErrorHandlingLog.Info( message ); } }
private void locationRequest_ReadLocationFinished( LocationRequest locationRequest, TrackerState result ) { if ( result.Error != null ) return; try { lock ( this.statSync ) { if ( this.succTime == null || this.succTime.Value < result.CreateTime ) { this.succTime = result.CreateTime; } } } catch ( Exception exc ) { // don't really expect an exception here, but just to be on the safe side: LogManager.GetLogger( GetType( ) ).Error( exc ); } }
void Start() { tcp = new TCPTestClient(); trackerState = new TrackerState(); }