From dffd53f23b19e0adec5dd96d4e9576e4c09371e2 Mon Sep 17 00:00:00 2001 From: clint156 <57494808+clint156@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:06:31 -0500 Subject: [PATCH] 107 bug laundry appliance status is reported incorrectly (#108) * add unknown status from laundryview * update change log for laundryview change --- CHANGELOG.md | 4 ++++ core/model/uiuc/laundryview.go | 12 +++++++++--- driven/uiucadapters/laundryadapter.go | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78e134cd..1d6838d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unpublished] - 2024-08-26 +### Changed +- Based on data coming back from LaundryView, uiuc laundry adapter now reutrns unknown as a status when the machine is offline and the out for service flag is 0. [#107]https://github.com/rokwire/gateway-building-block/issues/107 + ## [2.10.3] - 2024-06-28 ### Changed - Added markers and highlites parameters to floor plans endpoint to allow client to set default state. [#103](https://github.com/rokwire/gateway-building-block/issues/103) diff --git a/core/model/uiuc/laundryview.go b/core/model/uiuc/laundryview.go index 4b4d2f89..9cd9b264 100644 --- a/core/model/uiuc/laundryview.go +++ b/core/model/uiuc/laundryview.go @@ -93,7 +93,7 @@ func NewLaundryRoom(id int, name string, status string, location *model.LaundryD } // NewAppliance returns an app formatted appliance ojbect from campus data -func NewAppliance(id string, appliancetype string, cycletime int, status string, timeremaining string, label string) *model.Appliance { +func NewAppliance(id string, appliancetype string, cycletime int, status string, timeremaining string, label string, outofserviceflag string) *model.Appliance { var finalStatus string switch status { @@ -101,11 +101,17 @@ func NewAppliance(id string, appliancetype string, cycletime int, status string, finalStatus = "available" case "In Use": finalStatus = "in_use" + case "Offline": + if outofserviceflag == "1" { + finalStatus = "out_of_service" + } else { + finalStatus = "unknown" + } default: - finalStatus = "out_of_service" + finalStatus = "unknown" } - if finalStatus == "available" || finalStatus == "out_of_service" { + if finalStatus == "available" || finalStatus == "out_of_service" || finalStatus == "unknown" { appl := model.Appliance{ID: id, ApplianceType: appliancetype, AverageCycleTime: cycletime, Status: finalStatus, Label: label} return &appl } diff --git a/driven/uiucadapters/laundryadapter.go b/driven/uiucadapters/laundryadapter.go index 418dd125..b17867a5 100644 --- a/driven/uiucadapters/laundryadapter.go +++ b/driven/uiucadapters/laundryadapter.go @@ -111,7 +111,7 @@ func (lv *CSCLaundryView) GetLaundryRoom(roomid string, conf *model.EnvConfigDat for i, appl := range lr.Appliances { avgCycle, _ := strconv.Atoi(appl.AvgCycleTime) - rd.Appliances[i] = uiuc.NewAppliance(appl.ApplianceKey, appl.ApplianceType, avgCycle, appl.Status, appl.TimeRemaining, appl.Label) + rd.Appliances[i] = uiuc.NewAppliance(appl.ApplianceKey, appl.ApplianceType, avgCycle, appl.Status, appl.TimeRemaining, appl.Label, appl.OutOfService) } if len(lv.laundryAssets) > 0 {