Chronos Plugins 5.11.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 ()

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.

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 19 of file CoffeeConsumableManager.cs.

Constructor & Destructor Documentation

◆ CoffeeConsumableManager() [1/2]

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

Definition at line 34 of file CoffeeConsumableManager.cs.

34 : this()
35 {
36 mKnownCoffeeMakers = new List<MockDevice>(copyFrom.mKnownCoffeeMakers);
37 mPerDeviceConsumables.AddRange(copyFrom.mPerDeviceConsumables.Select(item => item.Clone(this)));
38 PoolsChanged();
39 }

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

Referenced by CoffeeConsumableManager().

◆ CoffeeConsumableManager() [2/2]

MockPlugin.Consumables.CoffeeConsumableManager.CoffeeConsumableManager ( )

Definition at line 43 of file CoffeeConsumableManager.cs.

44 {
45 Pools = new ReadOnlyObservableCollection<IConsumablePool>(mPools);
46 // looks like we are running in the designer?
47 if (Helpers.Debug == null)
48 {
49 ConfiguredDevices = new[] {new MockDevice(null) {Name = "Fake 1"}, new MockDevice(null) {Name = "Fake 2"}};
50 }
51 }

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

Referenced by Clone().

Member Function Documentation

◆ Clone()

IManageConsumables MockPlugin.Consumables.CoffeeConsumableManager.Clone ( )

Will be cloned for schedule validation.

Returns

Implements AxelSemrau.Chronos.Plugin.Consumables.IManageConsumables.

Definition at line 29 of file CoffeeConsumableManager.cs.

30 {
31 return new CoffeeConsumableManager(this);
32 }

References CoffeeConsumableManager().

◆ GetLocationIdentifier()

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

Definition at line 89 of file CoffeeConsumableManager.cs.

90 {
91 return $"{dev.Name}:{ingredientName}";
92 }

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

◆ PoolsChanged()

void MockPlugin.Consumables.CoffeeConsumableManager.PoolsChanged ( )
private

Definition at line 80 of file CoffeeConsumableManager.cs.

81 {
82 mPools.Clear();
83 foreach (var somePool in mPerDeviceConsumables.SelectMany(item => item.Pools))
84 {
85 mPools.Add(somePool);
86 }
87 }

References mPerDeviceConsumables, and mPools.

Referenced by CoffeeConsumableManager(), and UpdateDeviceConsumables().

◆ UpdateDeviceConsumables()

void MockPlugin.Consumables.CoffeeConsumableManager.UpdateDeviceConsumables ( )
private

Definition at line 65 of file CoffeeConsumableManager.cs.

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

References mConfiguredDevices, mKnownCoffeeMakers, mPerDeviceConsumables, and PoolsChanged().

Member Data Documentation

◆ mConfiguredDevices

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

Definition at line 21 of file CoffeeConsumableManager.cs.

Referenced by UpdateDeviceConsumables().

◆ mKnownCoffeeMakers

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

Definition at line 62 of file CoffeeConsumableManager.cs.

Referenced by CoffeeConsumableManager(), and UpdateDeviceConsumables().

◆ mPerDeviceConsumables

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

◆ mPools

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

Definition at line 22 of file CoffeeConsumableManager.cs.

Referenced by CoffeeConsumableManager(), and PoolsChanged().

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 53 of file CoffeeConsumableManager.cs.

54 {
55 set
56 {
57 mConfiguredDevices = value;
58 UpdateDeviceConsumables();
59 }
60 }

Referenced by 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 23 of file CoffeeConsumableManager.cs.

23{ get; }

Referenced by CoffeeConsumableManager().


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