From 684a61cf4fca257f9edbb676b338e0adfa1bca2d Mon Sep 17 00:00:00 2001 From: Ren Juan Date: Fri, 20 Aug 2021 11:24:38 +0000 Subject: [PATCH] * --- Ejectable/GT2.tsx | 117 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 Ejectable/GT2.tsx diff --git a/Ejectable/GT2.tsx b/Ejectable/GT2.tsx new file mode 100644 index 00000000..3eee0ed5 --- /dev/null +++ b/Ejectable/GT2.tsx @@ -0,0 +1,117 @@ +import * as React from 'react'; +import { Coordinate } from "./Coordinate"; +import { Text, View } from './components/Themed'; +import { StyleSheet } from 'react-native'; + +const styles = StyleSheet.create({ + tripText: { + marginHorizontal: -10, + marginVertical: 60, + textAlign: 'center', + width: "80%", + fontSize: 12, + fontWeight: 'bold', + }}); + +class Chronometer { + + public display:string = ""; + clock:number = 0; + intervalID:any = null; + + tick() {let hours:number = 0, minutes:number = 0, seconds:number = 0; + this.clock++; + hours = this.clock < 3600 ? 0 : (this.clock / 3600); + minutes = this.clock < 60 ? 0 : (this.clock - (hours * 3600)) / 60; + seconds = this.clock % 60; + this.display = hours + ":" + minutes + ":" + seconds; + } + public start() { this.clock = 0; + this.intervalID = setInterval(this.tick, 1000); + } + public resume() { this.intervalID = setInterval(this.tick, 1000); } + public stop() { clearInterval(this.intervalID); } + +} + +export class GT2 { + + displayInterval:any = null; + clock:Chronometer = new Chronometer(); + startPoint:Coordinate = new Coordinate(0,0); + public distance:number = 0.0; + co2Rate:number = 0.0; + currTime:number = 0; + lastTime:number = 0; + loc:Coordinate = new Coordinate(0,0); + public v:number = 0; + public inProgress:boolean = false; + public paused:boolean = false; + public elapsed:number = 0.0; + segments:number = 1; + + public reset() { + + this.startPoint = new Coordinate(0,0); + this.distance = 0.0; + this.co2Rate = 0.0; + this.currTime = 0; + this.lastTime = 0; + this.loc = new Coordinate(0,0); + this.v = 0; + this.inProgress = false; + this.paused = false; + this.elapsed = 0.0; + + } + + public end() { + + this.clock.stop(); + this.inProgress = false; + + } + + public pause() { + + this.clock.stop(); + this.paused = true; + + } + + public resume() { + + this.clock.start(); + this.paused = false; + } + + public start() { + + this.clock.start(); + this.inProgress = true; + } + + + public TripDisplay() { + + if (!thisTrip.inProgress) + return ( + + + {' No trip started yet.\n'} + + ); + else + return ( + + + {'Elapsed - '}{this.clock.display}{'\n'} + {'Geo: '}{'lat: '}{this.loc.mLatitude}{' long: '}{this.loc.mLatitude}{'\n'} + {'Vector: '}{'distance: '}{this.distance}{' velocity: '}{this.v}{'\n'} + + ); + } + +} + +export var thisTrip:GT2 = new GT2();