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

A task working on a complex parameter set. More...

+ Inheritance diagram for MockPlugin.Tasks.BrewFrappuccino:
+ Collaboration diagram for MockPlugin.Tasks.BrewFrappuccino:

Classes

class  CompositionData
 Let's pretend the composition is really complex and better done with a custom editor. More...
 
class  CompositionEditor
 Provide an editor for our complex parameter set, the standard component model way. More...
 

Public Types

enum  CreamType { Normal , LowFat , Vegan }
 Enum properties result in nice drop-down lists. More...
 

Public Member Functions

override string GetTaskAction ()
 Description of the tasks's action (for hints/time table)
 
 BrewFrappuccino ()
 
override void Execute ()
 Send the recipe to our device.
 
override void PostValidate ()
 Called after the schedule construction is completed.
 
void PropertyEdited (string propName, object propValue)
 The method editor informs us about changed values.
 
- Public Member Functions inherited from MockPlugin.Tasks.CoffeeMachineBaseTask
void SetDevice (IDevice yourDevice)
 
virtual void PreValidate ()
 Called before the schedule construction is completed.
 
virtual void PostValidate ()
 Called after the schedule construction is completed.
 
abstract void Execute ()
 Do whatever you have to do with your parameters.
 
abstract string GetTaskAction ()
 Description of the tasks's action (for hints/time table)
 
void PreValidate ()
 Called before the schedule construction is completed.
 
void PostValidate ()
 Called after the schedule construction is completed.
 
void Execute ()
 Do whatever you have to do with your parameters.
 
string GetTaskAction ()
 Description of the tasks's action (for hints/time table)
 
- Public Member Functions inherited from AxelSemrau.Chronos.Plugin.ITaskForDevice
void SetDevice (IDevice yourDevice)
 Will be called by chronos when building the schedule.
 
void PropertyEdited (string propName, object propValue)
 This will be called as soon as a property was changed in the method editor.
 

Properties

CompositionData Composition [get, set]
 Our extremely complex composition which could in no way be done with normal text-editable properties.
 
uint Volume [get, set]
 
uint CupSize [get, set]
 
int? CalculatedRuntime [get]
 Return some fake runtimes depending on the requested volume.
 
- Properties inherited from MockPlugin.Tasks.CoffeeMachineBaseTask
IConsumableManipulator Consumables [get, set]
 You will get an instance of a helper class that helps your task to find the correct consumable puddle.
 
- Properties inherited from AxelSemrau.Chronos.Plugin.Consumables.IConsumer
IConsumableManipulator Consumables [set]
 You will get an instance of a helper class that helps your task to find the correct consumable puddle.
 
- Properties inherited from AxelSemrau.Chronos.Plugin.IGiveARuntimeHint
int? CalculatedRuntime [get]
 Get an idea of the expected runtime.
 

Events

PropertyChangedEventHandler PropertyChanged
 

Private Member Functions

void RegisterConsumption (CompositionData composition)
 Register consumption of coffee / cream with the consumables tracker.
 

Private Attributes

CompositionData mComposition
 
MockDevice mDevInEditor
 

Additional Inherited Members

- Protected Member Functions inherited from MockPlugin.Tasks.CoffeeMachineBaseTask
void CheckForCoffeeMachine (IDevice yourDevice)
 It makes no sense to use any other "Autosampler" than our fake coffee machine here.
 
- Protected Attributes inherited from MockPlugin.Tasks.CoffeeMachineBaseTask
MockDevice mDevice
 

Detailed Description

A task working on a complex parameter set.

This task has some more complex property which is assumed to be not suitable for simple text editing and token substitution or calculations. Therefore, we have to provide an editor of our own. The property data will be serialized and stored within the Chronos method. The Volume parameter can also be set directly from the method editor like a normal property. Additionally, the task has a rough idea of how long it can take.

Definition at line 140 of file MockUseDeviceTasks.cs.

Member Enumeration Documentation

◆ CreamType

Enum properties result in nice drop-down lists.

Enumerator
Normal 
LowFat 
Vegan 

Definition at line 146 of file MockUseDeviceTasks.cs.

Constructor & Destructor Documentation

◆ BrewFrappuccino()

MockPlugin.Tasks.BrewFrappuccino.BrewFrappuccino ( )

Definition at line 293 of file MockUseDeviceTasks.cs.

294 {
295 Composition = new CompositionData();
296 CupSize = 250;
297 }
CompositionData Composition
Our extremely complex composition which could in no way be done with normal text-editable properties.

References MockPlugin.Tasks.BrewFrappuccino.Composition, and MockPlugin.Tasks.BrewFrappuccino.CupSize.

Member Function Documentation

◆ Execute()

override void MockPlugin.Tasks.BrewFrappuccino.Execute ( )
virtual

Send the recipe to our device.

Implements MockPlugin.Tasks.CoffeeMachineBaseTask.

Definition at line 302 of file MockUseDeviceTasks.cs.

303 {
306 }
void BrewFrappuccino(BrewFrappuccino.CompositionData composition)
Pretend we are doing some operation on a complex parameter set.
Definition: MockDevice.cs:96
void RegisterConsumption(CompositionData composition)
Register consumption of coffee / cream with the consumables tracker.

References MockPlugin.Device.MockDevice.BrewFrappuccino(), MockPlugin.Tasks.BrewFrappuccino.Composition, MockPlugin.Tasks.CoffeeMachineBaseTask.mDevice, and MockPlugin.Tasks.BrewFrappuccino.RegisterConsumption().

◆ GetTaskAction()

override string MockPlugin.Tasks.BrewFrappuccino.GetTaskAction ( )
virtual

Description of the tasks's action (for hints/time table)

Implements MockPlugin.Tasks.CoffeeMachineBaseTask.

Definition at line 265 of file MockUseDeviceTasks.cs.

266 {
267 return LocalizeMockPlugin.BrewFrappuccino_GetTaskAction_Brew_a_frappuccino__composition__ + Composition;
268 }

References MockPlugin.Tasks.BrewFrappuccino.Composition.

◆ PostValidate()

override void MockPlugin.Tasks.BrewFrappuccino.PostValidate ( )
virtual

Called after the schedule construction is completed.

Reimplemented from MockPlugin.Tasks.CoffeeMachineBaseTask.

Definition at line 308 of file MockUseDeviceTasks.cs.

309 {
311 }

References MockPlugin.Tasks.BrewFrappuccino.Composition, and MockPlugin.Tasks.BrewFrappuccino.RegisterConsumption().

◆ PropertyEdited()

void MockPlugin.Tasks.BrewFrappuccino.PropertyEdited ( string  propName,
object  propValue 
)

The method editor informs us about changed values.

Parameters
propName
propValue

It is possible that the given propValue can not be converted to our property type - for example, if there is a calculation or a reference to a different task's property in the method editor field.

Implements AxelSemrau.Chronos.Plugin.IWantEditorUpdates.

Definition at line 351 of file MockUseDeviceTasks.cs.

352 {
353 if (propName == nameof(Volume))
354 {
355 // the uint32 converter can't convert from uint32 to uint32 but throws an exception.
356 if (propValue is uint u)
357 {
358 Volume = u;
359 }
360 else
361 {
362 var conv = TypeDescriptor.GetConverter(Volume, true);
363 if (conv.IsValid(propValue))
364 {
365 // ReSharper disable once PossibleNullReferenceException
366 Volume = (uint)conv.ConvertFrom(null, System.Globalization.CultureInfo.InvariantCulture, propValue);
367 }
368 }
369 }
370 else if (propName == "Autosampler")
371 {
372 mDevInEditor = MockDevice.Instances.FirstOrDefault(someDev => someDev.Name == propValue?.ToString());
373 if (mComposition != null)
374 {
375 mComposition.DevInEditor = mDevInEditor;
376 }
377 }
378 }
A chronos plugin implementation for a fake device. We pretend we are controlling a mixture of coffee ...
Definition: MockDevice.cs:53

References MockPlugin.Tasks.BrewFrappuccino.mComposition, MockPlugin.Tasks.BrewFrappuccino.mDevInEditor, and MockPlugin.Tasks.BrewFrappuccino.Volume.

◆ RegisterConsumption()

void MockPlugin.Tasks.BrewFrappuccino.RegisterConsumption ( CompositionData  composition)
private

Register consumption of coffee / cream with the consumables tracker.

Parameters
composition

Definition at line 317 of file MockUseDeviceTasks.cs.

318 {
319 var sizeFactor = composition.Volume / 125.0;
320 Consumables.ModifyLevel(CoffeeConsumableManager.GetLocationIdentifier(mDevice,MockConsumablesForCoffeeMakerDevice.Coffee.Name),new Quantity(-7*sizeFactor, Units.Gram));
321 string creamName;
322 switch (composition.Cream)
323 {
324 case CreamType.LowFat:
325 // intentionally picked name of a component that is not tracked. Results just in a log entry, not visible on tracker's page.
326 creamName = "Low Fat Milk";
327 break;
328 case CreamType.Normal:
329 creamName = MockConsumablesForCoffeeMakerDevice.Milk.Name;
330 break;
331 case CreamType.Vegan:
332 creamName = MockConsumablesForCoffeeMakerDevice.VeganCream.Name;
333 break;
334 default:
335 creamName = "";
336 break;
337 }
338 Consumables.ModifyLevel(CoffeeConsumableManager.GetLocationIdentifier(mDevice, creamName),new Quantity(-10*sizeFactor,Units.MilliLiter));
339 }
void ModifyLevel(string consumableLocation, Quantity amountDelta)
Change the level of a consumable.
Keeps track of all consumables that are associated to our mock coffee machine.
static string GetLocationIdentifier(MockDevice dev, string ingredientName)
string Name
User-selected name for the device instance.
Definition: MockDevice.cs:87
IConsumableManipulator Consumables
You will get an instance of a helper class that helps your task to find the correct consumable puddle...
CreamType
Enum properties result in nice drop-down lists.

References MockPlugin.Tasks.CoffeeMachineBaseTask.Consumables, MockPlugin.Tasks.BrewFrappuccino.CompositionData.Cream, MockPlugin.Consumables.CoffeeConsumableManager.GetLocationIdentifier(), MockPlugin.Tasks.CoffeeMachineBaseTask.mDevice, AxelSemrau.Chronos.Plugin.Consumables.IConsumableManipulator.ModifyLevel(), and MockPlugin.Device.MockDevice.Name.

Referenced by MockPlugin.Tasks.BrewFrappuccino.Execute(), and MockPlugin.Tasks.BrewFrappuccino.PostValidate().

Member Data Documentation

◆ mComposition

CompositionData MockPlugin.Tasks.BrewFrappuccino.mComposition
private

◆ mDevInEditor

MockDevice MockPlugin.Tasks.BrewFrappuccino.mDevInEditor
private

Property Documentation

◆ CalculatedRuntime

int? MockPlugin.Tasks.BrewFrappuccino.CalculatedRuntime
get

Return some fake runtimes depending on the requested volume.

Implements AxelSemrau.Chronos.Plugin.IGiveARuntimeHint.

Definition at line 389 of file MockUseDeviceTasks.cs.

390 {
391 get
392 {
393 if (Volume > 250)
394 {
395 return 30;
396 }
397
398 if (Volume > 100)
399 {
400 return 15;
401 }
402
403 return 10;
404 }
405 }

◆ Composition

CompositionData MockPlugin.Tasks.BrewFrappuccino.Composition
getset

Our extremely complex composition which could in no way be done with normal text-editable properties.

Definition at line 244 of file MockUseDeviceTasks.cs.

245 {
246 get
247 {
248 if (mComposition != null && mComposition.DevInEditor == null)
249 {
250 mComposition.DevInEditor = mDevInEditor;
251 }
252 return mComposition;
253 }
254 set
255 {
256 mComposition = value;
257 if (mComposition != null)
258 {
259 mComposition.DevInEditor = mDevInEditor;
260 }
261 RaiseVolumeChanged();
262 }
263 }

Referenced by MockPlugin.Tasks.BrewFrappuccino.BrewFrappuccino(), MockPlugin.Tasks.BrewFrappuccino.Execute(), MockPlugin.Tasks.BrewFrappuccino.GetTaskAction(), and MockPlugin.Tasks.BrewFrappuccino.PostValidate().

◆ CupSize

uint MockPlugin.Tasks.BrewFrappuccino.CupSize
getset

Definition at line 287 of file MockUseDeviceTasks.cs.

288 {
289 get;
290 set;
291 }

Referenced by MockPlugin.Tasks.BrewFrappuccino.BrewFrappuccino().

◆ Volume

uint MockPlugin.Tasks.BrewFrappuccino.Volume
getset

Definition at line 272 of file MockUseDeviceTasks.cs.

273 {
274 get => mComposition.Volume;
275 set
276 {
277 if(mComposition.Volume == value) return;
278 mComposition.Volume = value;
279 RaiseVolumeChanged();
280 }
281 }

Referenced by MockPlugin.Tasks.FrappuccinoCompositionEditor.CopyDataToGui(), and MockPlugin.Tasks.BrewFrappuccino.PropertyEdited().

Event Documentation

◆ PropertyChanged

PropertyChangedEventHandler MockPlugin.Tasks.BrewFrappuccino.PropertyChanged

Definition at line 382 of file MockUseDeviceTasks.cs.


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