Skip to content

Commit b994417

Browse files
committed
controller now tested
1 parent 3e30568 commit b994417

File tree

11 files changed

+12
-8
lines changed

11 files changed

+12
-8
lines changed

examples/valve-app/controller/__init__.py examples/valve/controller/__init__.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@ class Bottle(StrEnum):
1111
kSourMix = "sour mix"
1212
kSimpleSyrup = "simple syrup",
1313

14-
# One once == approx 12s.
15-
1614

1715
class Oz:
1816
def __init__(self, oz: float):
1917
self.oz = oz
2018

2119
def time(self):
20+
# One oz == approx 12s.
2221
return self.oz * 12
2322

2423

2524
class DrinkMachine:
2625
def __init__(self, devCtrl: ChipDeviceCtrl, node_id: int):
2726
self.dev_ctrl = devCtrl
2827
self.node_id = node_id
29-
# TODO: Should this actually be modelled as an aggregator with bridged nodes so I can have a nodelabel?
28+
# TODO: Should this actually be modelled as an aggregator with bridged nodes so I can have a NodeLabel?
3029
# Right now I'm going to leave this as something on the app side because it's a demo, but it's weird that we don't have writeable labels unless you model it strangely. Spec issue?
3130
self.bottles: dict[Bottle, int] = {Bottle.kBourbon: 1, Bottle.kGin: 2,
3231
Bottle.kCampari: 3, Bottle.kVermouth: 4, Bottle.kSourMix: 5, Bottle.kSimpleSyrup: 6}
@@ -37,6 +36,8 @@ def __init__(self, devCtrl: ChipDeviceCtrl, node_id: int):
3736
self.add_recipe("martini", {Bottle.kGin: Oz(2), Bottle.kVermouth: Oz(0.25)})
3837
self.add_recipe("gimlet", {Bottle.kGin: Oz(2.5), Bottle.kSourMix: Oz(0.5), Bottle.kSimpleSyrup: Oz(0.5)})
3938
self.add_recipe("old fashioned", {Bottle.kBourbon: Oz(2), Bottle.kSimpleSyrup: Oz(0.125)})
39+
self.add_recipe("shot of bourbon", {Bottle.kBourbon: Oz(1.5)})
40+
self.add_recipe("shot of gin", {Bottle.kGin: Oz(1.5)})
4041

4142
def set_bottle_names(self, bottles: dict[Bottle, int]) -> bool:
4243
''' Bottle is a dict of bottle name to endpoint and should contain all 6 endpoints at once'''
@@ -45,7 +46,10 @@ def set_bottle_names(self, bottles: dict[Bottle, int]) -> bool:
4546
self.bottles = bottles
4647

4748
def get_bottle_names(self):
48-
return self.Bottle
49+
return self.bottles
50+
51+
def get_recipes(self):
52+
return self.recipes
4953

5054
def add_recipe(self, name: str, ingredients: dict[Bottle, Oz]):
5155
# TODO: should store somewhere permanent - simplest is to write out to file. In the meanwhile, we have a few pre-populated
@@ -60,7 +64,7 @@ async def dispense(self, recipe: str):
6064
if not required_bottles.issubset(set(self.bottles)):
6165
print('Recipe requires an ingredient that is not loaded into the drink machine')
6266
print(f'Recipe requires: {required_bottles}')
63-
print(f'Availble: {self.bottles}')
67+
print(f'Available: {self.bottles}')
6468
return
6569

6670
ingredients = self.recipes[recipe]
File renamed without changes.

examples/valve-app/linux/BUILD.gn examples/valve/linux/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ executable("valve-app") {
3636

3737
deps = [
3838
"${chip_root}/examples/platform/linux:app-main",
39-
"${chip_root}/examples/valve-app/valve-common",
39+
"${chip_root}/examples/valve/valve-common",
4040
"${chip_root}/src/lib",
4141
]
4242

File renamed without changes.
File renamed without changes.

examples/valve-app/linux/main.cpp examples/valve/linux/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ class PrintOnlyDelegate : public NonLevelControlDelegate
3535
PrintOnlyDelegate(EndpointId endpoint) : mEndpoint(endpoint) {}
3636
CHIP_ERROR HandleOpenValve(ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) override
3737
{
38-
ChipLogProgress(NotSpecified, "VALVE IS OPENING on endpoint %u!!!!!", mEndpoint);
38+
ChipLogError(NotSpecified, "\n\nVALVE IS OPENING on endpoint %u!!!!!\n\n", mEndpoint);
3939
state = ValveStateEnum::kOpen;
4040
currentState = state;
4141
return CHIP_NO_ERROR;
4242
}
4343
ValveStateEnum GetCurrentValveState() override { return state; }
4444
CHIP_ERROR HandleCloseValve(ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) override
4545
{
46-
ChipLogProgress(NotSpecified, "VALVE IS CLOSING on endpoint %u!!!!!", mEndpoint);
46+
ChipLogError(NotSpecified, "\n\nVALVE IS CLOSING on endpoint %u!!!!!\n\n", mEndpoint);
4747
state = ValveStateEnum::kClosed;
4848
currentState = state;
4949
return CHIP_NO_ERROR;
File renamed without changes.

0 commit comments

Comments
 (0)