bms.rs 564 B

123456789101112131415161718192021222324252627
  1. use crate::ems::service::Service;
  2. use anyhow::Error;
  3. use std::time::Duration;
  4. use tokio::task::JoinHandle;
  5. use tokio::time::sleep;
  6. pub struct Bms {}
  7. impl Bms {
  8. /// 初始化BMS
  9. pub fn new() -> Self {
  10. println!("Bms初始化成功");
  11. Bms {}
  12. }
  13. }
  14. impl Service for Bms {
  15. fn run(&self) -> Result<JoinHandle<()>, Error> {
  16. let handle = tokio::spawn(async {
  17. loop {
  18. println!("bms");
  19. tokio::time::sleep(Duration::from_secs(1)).await;
  20. }
  21. });
  22. Ok(handle)
  23. }
  24. }