2using System.ComponentModel;
3using System.Drawing.Design;
5using System.Windows.Forms.Design;
6using System.Xml.Serialization;
9using Ctc.Palplus.Integration.Driver.Entities;
12using MockPlugin.Properties;
37 if (
mDevice ==
null && yourDevice !=
null)
39 throw new ArgumentException(
40 $
"Device type {yourDevice.DisplayedTypeName} is not usable for a {GetType().Name}.");
42 if (yourDevice ==
null)
44 throw new ArgumentException(
"This kind of task needs an autosampler.");
79 public override string Name => LocalizeMockPlugin.CoffeeCategory_Name_Coffee;
90 [ScheduleDiagramColor(
"Sienna")]
121 return LocalizeMockPlugin.BrewCoffee_GetTaskAction_Send_a_message_to_my_device;
127 public string Message {
get;
set; } = LocalizeMockPlugin.BrewCoffee_mMessage_Do_you_want_sugar_;
156 [Editor(typeof(CompositionEditor), typeof(UITypeEditor))]
191 return String.Format(LocalizeMockPlugin.CompositionData_ToString_Cream___0___MuchIce___1___Decaffeinated___2___Size___3__mL,
196 #region Component model UI type editor
208 public override UITypeEditorEditStyle
GetEditStyle(ITypeDescriptorContext context)
211 return UITypeEditorEditStyle.Modal;
221 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider,
object value)
223 var editProvider = (IWindowsFormsEditorService)provider?.GetService(typeof(IWindowsFormsEditorService));
230 editProvider?.ShowDialog(myEditor);
236 #endregion Component model UI type editor
261 RaiseVolumeChanged();
267 return LocalizeMockPlugin.BrewFrappuccino_GetTaskAction_Brew_a_frappuccino__composition__ +
Composition;
271 [DefaultUnit(Units.MilliLiter)]
278 mComposition.Volume = value;
279 RaiseVolumeChanged();
282 internal void RaiseVolumeChanged()
319 var sizeFactor = composition.Volume / 125.0;
322 switch (composition.
Cream)
326 creamName =
"Low Fat Milk";
329 creamName = MockConsumablesForCoffeeMakerDevice.Milk.Name;
332 creamName = MockConsumablesForCoffeeMakerDevice.VeganCream.Name;
353 if (propName == nameof(
Volume))
356 if (propValue is uint u)
362 var conv = TypeDescriptor.GetConverter(
Volume,
true);
363 if (conv.IsValid(propValue))
366 Volume = (uint)conv.ConvertFrom(
null, System.Globalization.CultureInfo.InvariantCulture, propValue);
370 else if (propName ==
"Autosampler")
384 #region Implementation of IGiveARuntimeHint
421 .PretendCoffeeMachineIsBroken_Execute_The_coffee_machine_s_heater_failed_,
SoftStop);
426 return String.Format(LocalizeMockPlugin.PretendCoffeeMachineIsBroken_GetTaskAction_Will_make_the_device_abort_the_schedule_after_a_few_seconds_,
SoftStop);
435 public string ErrorDescription {
get;
set; } =
"Some random error message that is shown to the user";
448 return $
"Raising error type {ErrorType} with description \"{ErrorDescription}\"";
Classes and interfaces that are meant for plugins. The classes and interfaces below this namespace ar...
ErrorType
Lets a device implementing IHaveInteractiveErrorHandling specify which kind of error occurred.
A fake device. This namespace contains the fake device driver and auxiliary classes for settings,...
Example task implementations. Since there are lots of things that can be done from a task,...
The classes in this namespace demonstrate how to define your own sample list column types.
Helps you manipulate the desired consumable, or works as a dummy.
void ModifyLevel(string consumableLocation, Quantity amountDelta)
Change the level of a consumable.
For tasks that intend to modify consumable levels.
To be implemented by the "device driver" part of a Chronos plugin.
To be implemented if the task needs to access a device ("Autosampler" property in Chronos)
If you can calculate your runtime, you should implement this interface.
Implement this interface in your task if you want the method editor to notify it of changed propertie...
Use this if none of the predefined categories fit and you have a better idea than "Misc".
Keeps track of all consumables that are associated to our mock coffee machine.
static string GetLocationIdentifier(MockDevice dev, string ingredientName)
A chronos plugin implementation for a fake device. We pretend we are controlling a mixture of coffee ...
void BrewFrappuccino(BrewFrappuccino.CompositionData composition)
Pretend we are doing some operation on a complex parameter set.
void ShowTheMessage(string messageText)
Let our device set a status message and display some message box instead of doing real work.
string Name
User-selected name for the device instance.
void TriggerAbort(string reason, bool softStop)
This will trigger the AbortSchedule-Event 5 seconds after it was called from a task.
void RaiseError(string errorDescription, ErrorType errType, bool resolved)
"Retry" here means that we don't retry some action, but that we raise the error again.
Just provide a TypeConverter, and Chronos is happy.
Provides an editor for the BrewFrappuccino-Task's "Composition" information.
Base class for our example, just contains some empty default implementations and a check for the righ...
void Execute()
Do whatever you have to do with your parameters.
void SetDevice(IDevice yourDevice)
IConsumableManipulator Consumables
You will get an instance of a helper class that helps your task to find the correct consumable puddle...
void CheckForCoffeeMachine(IDevice yourDevice)
It makes no sense to use any other "Autosampler" than our fake coffee machine here.
string GetTaskAction()
Description of the tasks's action (for hints/time table)
virtual void PostValidate()
Called after the schedule construction is completed.
virtual void PreValidate()
Called before the schedule construction is completed.
Custom category in the method editor for coffee making related tasks.
override string Name
Localization aware category name.
CoffeeCategory(int ranking)
Calls a method of the device class with one if its task parameters.
override void Execute()
Do something with our device: The resulting message box is displayed by the device.
override void PostValidate()
Called after the schedule construction is completed.
void RegisterCoffeeConsumption()
Inform the consumables tracker of the needed coffee amount.
override string GetTaskAction()
Show this task's action in the timetable.
string Message
Trivial property which can be changed in the method editor.
A task working on a complex parameter set.
void RegisterConsumption(CompositionData composition)
Register consumption of coffee / cream with the consumables tracker.
override void PostValidate()
Called after the schedule construction is completed.
PropertyChangedEventHandler PropertyChanged
CompositionData Composition
Our extremely complex composition which could in no way be done with normal text-editable properties.
CreamType
Enum properties result in nice drop-down lists.
void PropertyEdited(string propName, object propValue)
The method editor informs us about changed values.
override string GetTaskAction()
Description of the tasks's action (for hints/time table)
CompositionData mComposition
override void Execute()
Send the recipe to our device.
int? CalculatedRuntime
Return some fake runtimes depending on the requested volume.
Let's pretend the composition is really complex and better done with a custom editor.
override string ToString()
This value will be shown (read only) in the property field, with a button next to it that invokes our...
CompositionData()
Default composition.
Provide an editor for our complex parameter set, the standard component model way.
override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
Which kind of editor should be shown?
override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
Pass the value to edit to our editor dialog and return the changed(?) value.
This task will trigger a timer in our device which will make it complain about an error situation,...
override void Execute()
Do whatever you have to do with your parameters.
override string GetTaskAction()
Description of the tasks's action (for hints/time table)
In contrast to PretendCoffeeMachineIsBroken, this simulates an error that an autosampler could have w...
override void Execute()
Do whatever you have to do with your parameters.
override string GetTaskAction()
Description of the tasks's action (for hints/time table)
bool ResolvedAfterHandling
Should we consider the error fixed after error handling has run?