summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-06-07 08:30:35 -0500
committertom barrett <spalf0@gmail.com>2018-06-07 08:30:35 -0500
commit11b51897dda7609b5a22a490bfb8cd2c269b5969 (patch)
tree2df89c71305de020e1f8a59d7fdfbf18979387a5 /src/modules
parente70f4e4a41a0acf7ef812220113dff703280f75a (diff)
-added crude refinery methods
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/mod.rs1
-rw-r--r--src/modules/refinery.rs52
-rw-r--r--src/modules/types.rs3
3 files changed, 55 insertions, 1 deletions
diff --git a/src/modules/mod.rs b/src/modules/mod.rs
index 0c19156..61e8133 100644
--- a/src/modules/mod.rs
+++ b/src/modules/mod.rs
@@ -2,4 +2,5 @@ pub mod mining;
pub mod engines;
pub mod dashboard;
pub mod navigation;
+pub mod refinery;
pub mod types;
diff --git a/src/modules/refinery.rs b/src/modules/refinery.rs
new file mode 100644
index 0000000..733fcd4
--- /dev/null
+++ b/src/modules/refinery.rs
@@ -0,0 +1,52 @@
+use std::time::SystemTime;
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct Refinery {
+ time : u64,
+ start : Option<SystemTime>,
+ pub status : bool,
+ pub ready : bool,
+}
+
+impl Refinery {
+ pub fn new() -> Refinery {
+ Refinery {
+ time : 5,
+ start : None,
+ status : false,
+ ready : false,
+ }
+ }
+
+ pub fn process(&mut self) {
+ match self.start.clone() {
+ Some(timer) => {
+ if timer.elapsed().unwrap().as_secs() > self.time {
+ self.start = Some(SystemTime::now());
+ self.ready = true;
+ }
+ }
+ _ => (),
+ }
+ if !self.status {
+ self.start = None;
+ self.ready = false;
+ }
+ }
+
+ pub fn toggle(&mut self) {
+ self.status = !self.status;
+ self.start = match self.status {
+ true => Some(SystemTime::now()),
+ false => None,
+ };
+ }
+
+ pub fn off(&mut self) {
+ self.status = false;
+ }
+
+ pub fn take(&mut self) {
+ self.ready = false;
+ }
+}
diff --git a/src/modules/types.rs b/src/modules/types.rs
index 1af99d6..48b3473 100644
--- a/src/modules/types.rs
+++ b/src/modules/types.rs
@@ -1,7 +1,8 @@
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum ModuleType {
- Navigation,
Mining,
Engines,
+ Refinery,
Dashboard,
+ Navigation,
}