コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if ((int) Build.VERSION.SdkInt >= 21)
            {
                Window.SetStatusBarColor(new Color(ContextCompat.GetColor(this, Resource.Color.primary_dark)));
                Window.DecorView.SystemUiVisibility = StatusBarVisibility.Visible;
            }


            if (ViewModel == null)
            {
                Finish();
                return;
            }

            SupportActionBar.SetDisplayShowHomeEnabled(false);
            SupportActionBar.SetDisplayHomeAsUpEnabled(false);


            var date = ViewModel.Date.ToLocalTime();
            FindViewById<TextView>(Resource.Id.text_time).Text = ViewModel.TotalTimeDisplay;
            FindViewById<TextView>(Resource.Id.text_date).Text = date.ToString("M") + " " + date.ToString("t");
            FindViewById<TextView>(Resource.Id.text_distance).Text = ViewModel.TotalDistanceDisplay;
            FindViewById<TextView>(Resource.Id.text_max_speed).Text = ViewModel.MaxSpeedDisplay;
            FindViewById<TextView>(Resource.Id.text_fuel_consumption).Text = ViewModel.FuelDisplay;
            FindViewById<TextView>(Resource.Id.text_hard_accelerations).Text = ViewModel.HardAccelerations.ToString();
            FindViewById<TextView>(Resource.Id.text_hard_breaks).Text = ViewModel.HardStops.ToString();

            ViewModel = null;
        }
コード例 #2
0
        public async Task <bool> StopRecordingTrip()
        {
            if (IsBusy || !IsRecording)
            {
                return(false);
            }


            //always will have 1 point, so we can stop.
            CurrentTrip.EndTimeStamp = DateTime.UtcNow;
            try
            {
                if (obdDataProcessor != null)
                {
                    //Disconnect from the OBD device; if still trying to connect, stop polling for the device
                    await obdDataProcessor.DisconnectFromObdDevice();
                }
            }
            catch (Exception ex)
            {
                //22 Logger.Instance.Report(ex);
            }

            /*23
             * List<POI> poiList = new List<POI>();
             * try
             * {
             *  poiList = new List<POI>(await StoreManager.POIStore.GetItemsAsync(CurrentTrip.Id));
             * }
             * catch (Exception ex)
             * {
             *  //Intermittently, Sqlite will cause a crash for WinPhone saying "unable to set temporary directory"
             *  //If this call fails, simply use an empty list of POIs
             *  Logger.Instance.Track("Unable to get POI Store Items.");
             *  Logger.Instance.Report(ex);
             * }
             *
             *
             * CurrentTrip.HardStops = poiList.Where(p => p.POIType == POIType.HardBrake).Count();
             * CurrentTrip.HardAccelerations = poiList.Where(p => p.POIType == POIType.HardAcceleration).Count();
             */

            TripSummary = new TripSummaryViewModel
            {
                TotalTime         = (CurrentTrip.EndTimeStamp - CurrentTrip.RecordedTimeStamp).TotalSeconds,
                TotalDistance     = CurrentTrip.Distance,
                FuelUsed          = CurrentTrip.FuelUsed,
                MaxSpeed          = CurrentTrip.Points.Max(s => s.Speed),
                HardStops         = CurrentTrip.HardStops,
                HardAccelerations = CurrentTrip.HardAccelerations,
                Date = DateTime.UtcNow
            };

            IsRecording = false;
            NeedSave    = true;
            //24 Logger.Instance.Track("StopRecording");
            return(true);
        }
コード例 #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            ViewModel = e.Parameter as TripSummaryViewModel;
            DataContext = this;
            UpdateSummary();
            // Enable back button behavior
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();
            systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;

            //  DrawPath();
        }
コード例 #4
0
        public async Task <bool> StopRecordingTrip()
        {
            if (IsBusy || !IsRecording)
            {
                return(false);
            }


            //always will have 1 point, so we can stop.
            CurrentTrip.EndTimeStamp = DateTime.UtcNow;
            try
            {
                if (obdDataProcessor != null)
                {
                    //Disconnect from the OBD device; if still trying to connect, stop polling for the device
                    await obdDataProcessor.DisconnectFromObdDevice();
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Report(ex);
            }

            List <POI> poiList = new List <POI>(await StoreManager.POIStore.GetItemsAsync(CurrentTrip.Id));

            CurrentTrip.HardStops         = poiList.Where(p => p.POIType == POIType.HardBrake).Count();
            CurrentTrip.HardAccelerations = poiList.Where(p => p.POIType == POIType.HardAcceleration).Count();

            TripSummary = new TripSummaryViewModel
            {
                TotalTime         = (CurrentTrip.EndTimeStamp - CurrentTrip.RecordedTimeStamp).TotalSeconds,
                TotalDistance     = CurrentTrip.Distance,
                FuelUsed          = CurrentTrip.FuelUsed,
                MaxSpeed          = CurrentTrip.Points.Max(s => s.Speed),
                HardStops         = CurrentTrip.HardStops,
                HardAccelerations = CurrentTrip.HardAccelerations,
                Date = DateTime.UtcNow
            };

            IsRecording = false;
            NeedSave    = true;
            Logger.Instance.Track("StopRecording");
            return(true);
        }
コード例 #5
0
        public TripSummaryView()
        {
            InitializeComponent();
            ViewModel = new TripSummaryViewModel();

            TotalDistanceTab.Title1 = "Total";
            TotalDistanceTab.Title2 = "DISTANCE";


            TotalTimeTab.Title1 = "Total";
            TotalTimeTab.Title2 = "TIME";

            MaxSpeedTab.Title1 = "Max";
            MaxSpeedTab.Title2 = "SPEED";

            FuelConsumptionTab.Title1 = "Total";
            FuelConsumptionTab.Title2 = "FUEL USED";

            HardBreaksTab.Title1 = "Hard";
            HardBreaksTab.Title2 = "STOPS";

            HardAccelerationsTab.Title1 = "Hard";
            HardAccelerationsTab.Title2 = "ACCELERATIONS";
        }
コード例 #6
0
        public async Task<bool> StopRecordingTrip()
        {
            if (IsBusy || !IsRecording)
                return false;


            //always will have 1 point, so we can stop.
            CurrentTrip.EndTimeStamp = DateTime.UtcNow;
            try
            {
                if (obdDataProcessor != null)
                {
                    //Disconnect from the OBD device; if still trying to connect, stop polling for the device
                    await obdDataProcessor.DisconnectFromObdDevice();
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Report(ex);
            }

            List<POI> poiList = new List<POI>();
            try
            {
                poiList = new List<POI>(await StoreManager.POIStore.GetItemsAsync(CurrentTrip.Id));
            }
            catch (Exception ex)
            {
                //Intermittently, Sqlite will cause a crash for WinPhone saying "unable to set temporary directory"
                //If this call fails, simply use an empty list of POIs
                Logger.Instance.Track("Unable to get POI Store Items.");
                Logger.Instance.Report(ex);
            }
           
            CurrentTrip.HardStops = poiList.Where(p => p.POIType == POIType.HardBrake).Count();
            CurrentTrip.HardAccelerations = poiList.Where(p => p.POIType == POIType.HardAcceleration).Count();

            TripSummary = new TripSummaryViewModel
            {
                TotalTime = (CurrentTrip.EndTimeStamp - CurrentTrip.RecordedTimeStamp).TotalSeconds,
                TotalDistance = CurrentTrip.Distance,
                FuelUsed = CurrentTrip.FuelUsed,
                MaxSpeed = CurrentTrip.Points.Max(s => s.Speed),
                HardStops = CurrentTrip.HardStops,
                HardAccelerations = CurrentTrip.HardAccelerations,
                Date = DateTime.UtcNow
            };

            IsRecording = false;
            NeedSave = true;
            Logger.Instance.Track("StopRecording");
            return true;
        }