Chronos Plugins 5.4.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
MockPlugin.Consumables.CoffeeConsumableManager Class Reference

Keeps track of all consumables that are associated to our mock coffee machine. More...

+ Inheritance diagram for MockPlugin.Consumables.CoffeeConsumableManager:
+ Collaboration diagram for MockPlugin.Consumables.CoffeeConsumableManager:

Public Member Functions

IManageConsumables Clone ()
 Will be cloned for schedule validation.
 
 CoffeeConsumableManager ()
 
IManageConsumables Clone ()
 Create a copy of yourself for validation purposes.
 

Static Public Member Functions

static string GetLocationIdentifier (MockDevice dev, string ingredientName)
 

Properties

ReadOnlyObservableCollection< IConsumablePoolPools [get]
 List of all consumable pools you manage.
 
IEnumerable< IDeviceConfiguredDevices [set]
 List of IDevice for all configured devices in Chronos.
 
- Properties inherited from AxelSemrau.Chronos.Plugin.Consumables.IManageConsumables
ReadOnlyObservableCollection< IConsumablePoolPools [get]
 List of all consumable pools you manage.
 
- Properties inherited from AxelSemrau.Chronos.Plugin.IDirectDeviceAccess
IEnumerable< IDeviceConfiguredDevices [set]
 List of IDevice for all configured devices in Chronos.
 

Private Member Functions

 CoffeeConsumableManager (CoffeeConsumableManager copyFrom)
 
void UpdateDeviceConsumables ()
 
void PoolsChanged ()
 

Private Attributes

IEnumerable< IDevicemConfiguredDevices
 
readonly ObservableCollection< IConsumablePoolmPools = new ObservableCollection<IConsumablePool>()
 
readonly List< MockDevicemKnownCoffeeMakers = new List<MockDevice>()
 
readonly List< MockConsumablesForCoffeeMakerDevice > mPerDeviceConsumables = new List<MockConsumablesForCoffeeMakerDevice>()
 

Detailed Description

Keeps track of all consumables that are associated to our mock coffee machine.

A real implementation would of course include some warning or error levels.

Definition at line 16 of file CoffeeConsumableManager.cs.

Constructor & Destructor Documentation

◆ CoffeeConsumableManager() [1/2]

MockPlugin.Consumables.CoffeeConsumableManager.CoffeeConsumableManager ( CoffeeConsumableManager  copyFrom)
private

Definition at line 31 of file CoffeeConsumableManager.cs.

31 : this()
32 {
33 mKnownCoffeeMakers = new List<MockDevice>(copyFrom.mKnownCoffeeMakers);
34 mPerDeviceConsumables.AddRange(copyFrom.mPerDeviceConsumables.Select(item => item.Clone(this)));
36 }
readonly List< MockConsumablesForCoffeeMakerDevice > mPerDeviceConsumables

References MockPlugin.Consumables.CoffeeConsumableManager.mKnownCoffeeMakers, MockPlugin.Consumables.CoffeeConsumableManager.mPerDeviceConsumables, and MockPlugin.Consumables.CoffeeConsumableManager.PoolsChanged().

◆ CoffeeConsumableManager() [2/2]

MockPlugin.Consumables.CoffeeConsumableManager.CoffeeConsumableManager ( )

Definition at line 40 of file CoffeeConsumableManager.cs.

41 {
42 Pools = new ReadOnlyObservableCollection<IConsumablePool>(mPools);
43 // looks like we are running in the designer?
44 if (Helpers.Debug == null)
45 {
46 ConfiguredDevices = new[] {new MockDevice() {Name = "Fake 1"}, new MockDevice() {Name = "Fake 2"}};
47 }
48 }
Static instance for access to utility functions and resources.
Definition: Helpers.cs:78
static IDebugHelper Debug
Utility functions for debugging.
Definition: Helpers.cs:97
readonly ObservableCollection< IConsumablePool > mPools
IEnumerable< IDevice > ConfiguredDevices
List of IDevice for all configured devices in Chronos.
ReadOnlyObservableCollection< IConsumablePool > Pools
List of all consumable pools you manage.
A chronos plugin implementation for a fake device. We pretend we are controlling a mixture of coffee ...
Definition: MockDevice.cs:53

References MockPlugin.Consumables.CoffeeConsumableManager.ConfiguredDevices, AxelSemrau.Chronos.Plugin.Helpers.Debug, MockPlugin.Consumables.CoffeeConsumableManager.mPools, AxelSemrau.Chronos.Plugin.Name, and MockPlugin.Consumables.CoffeeConsumableManager.Pools.

Referenced by MockPlugin.Consumables.CoffeeConsumableManager.Clone().

Member Function Documentation

◆ Clone()

IManageConsumables MockPlugin.Consumables.CoffeeConsumableManager.Clone ( )

◆ GetLocationIdentifier()

static string MockPlugin.Consumables.CoffeeConsumableManager.GetLocationIdentifier ( MockDevice  dev,
string  ingredientName 
)
static

Definition at line 86 of file CoffeeConsumableManager.cs.

87 {
88 return $"{dev.Name}:{ingredientName}";
89 }

Referenced by MockPlugin.Tasks.BrewCoffee.RegisterCoffeeConsumption(), and MockPlugin.Tasks.BrewFrappuccino.RegisterConsumption().

◆ PoolsChanged()

void MockPlugin.Consumables.CoffeeConsumableManager.PoolsChanged ( )
private

◆ UpdateDeviceConsumables()

void MockPlugin.Consumables.CoffeeConsumableManager.UpdateDeviceConsumables ( )
private

Definition at line 62 of file CoffeeConsumableManager.cs.

63 {
64 var currentDevs = mConfiguredDevices.OfType<MockDevice>().ToList();
65 var removedDevs = mKnownCoffeeMakers.Except(currentDevs).ToList();
66 mPerDeviceConsumables.RemoveAll(item => removedDevs.Contains(item.ForDevice));
67 var newDevs = currentDevs.Except(mKnownCoffeeMakers).ToList();
68 mPerDeviceConsumables.AddRange(newDevs.Select(someDev => new MockConsumablesForCoffeeMakerDevice(someDev,this)));
69 mKnownCoffeeMakers.Clear();
70 mKnownCoffeeMakers.AddRange(currentDevs);
71 if (newDevs.Any() || removedDevs.Any())
72 {
74 }
75 }

References MockPlugin.Consumables.CoffeeConsumableManager.mConfiguredDevices, MockPlugin.Consumables.CoffeeConsumableManager.mKnownCoffeeMakers, MockPlugin.Consumables.CoffeeConsumableManager.mPerDeviceConsumables, and MockPlugin.Consumables.CoffeeConsumableManager.PoolsChanged().

Member Data Documentation

◆ mConfiguredDevices

IEnumerable<IDevice> MockPlugin.Consumables.CoffeeConsumableManager.mConfiguredDevices
private

◆ mKnownCoffeeMakers

readonly List<MockDevice> MockPlugin.Consumables.CoffeeConsumableManager.mKnownCoffeeMakers = new List<MockDevice>()
private

◆ mPerDeviceConsumables

readonly List<MockConsumablesForCoffeeMakerDevice> MockPlugin.Consumables.CoffeeConsumableManager.mPerDeviceConsumables = new List<MockConsumablesForCoffeeMakerDevice>()
private

◆ mPools

readonly ObservableCollection<IConsumablePool> MockPlugin.Consumables.CoffeeConsumableManager.mPools = new ObservableCollection<IConsumablePool>()
private

Property Documentation

◆ ConfiguredDevices

IEnumerable<IDevice> MockPlugin.Consumables.CoffeeConsumableManager.ConfiguredDevices
set

List of IDevice for all configured devices in Chronos.

Use with caution!

Implements AxelSemrau.Chronos.Plugin.IDirectDeviceAccess.

Definition at line 50 of file CoffeeConsumableManager.cs.

Referenced by MockPlugin.Consumables.CoffeeConsumableManager.CoffeeConsumableManager().

◆ Pools

ReadOnlyObservableCollection<IConsumablePool> MockPlugin.Consumables.CoffeeConsumableManager.Pools
get

List of all consumable pools you manage.

A consumable pool consists of one or more locations where a named consumable can be found.

Implements AxelSemrau.Chronos.Plugin.Consumables.IManageConsumables.

Definition at line 20 of file CoffeeConsumableManager.cs.

20{ get; }

Referenced by MockPlugin.Consumables.CoffeeConsumableManager.CoffeeConsumableManager(), and MockPlugin.Consumables.CoffeeConsumableViewModel.RebuildLists().


The documentation for this class was generated from the following file: