Chronos Plugins 5.4.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
MockJobInspectingTask.cs File Reference

Go to the source code of this file.

Classes

class  MockPlugin.Tasks.JobInspectionDemo
 Shows how to get information about other tasks in the schedule. More...
 

Namespaces

namespace  MockPlugin
 An example Chronos plugin. This plugin demonstrates how to write plugins for Chronos. It should give you a rough idea how different things can be done, and which interfaces are needed to provide funtionality.
 
namespace  MockPlugin.Tasks
 Example task implementations. Since there are lots of things that can be done from a task, the demo was split into many different examples each showing only few facets of what's possible. If you still think this is confusing, please let us know where we could simplify these examples.
 

Variables

Myenabledproperty
 
Task
 

Variable Documentation

◆ Myenabledproperty

$ Myenabledproperty

Definition at line 30 of file MockJobInspectingTask.cs.

31{
32 var prevTask = mJobInspector.CompleteSchedule
33 .TakeWhile(someTaskInfo => someTaskInfo.PluginTask != mJobInspector.CurrentTask.PluginTask).LastOrDefault();
34 if (prevTask?.PluginTask is JobInspectionDemo)
35 {
36 prevTask.Enabled = false;
37 }
38 }
39
40 void ITask.PostValidate()
41 {
42 DisablePreviousTwin();
43 }
44
45 private string GetJitInfo(ITaskInfo someTaskInfo, IAccessProperty somePropInfo)
46 {
47 if(mJitChecker == null)
48 {
49 return "N/A";
50 }
51 return mJitChecker(someTaskInfo.Task,somePropInfo.FullPath) ? "yes" : "no";
52 }
53 void ITask.Execute()
54 {
55 var sb = new StringBuilder();
56 var i = 1;
57 foreach (var someTaskInfo in mJobInspector.JobsTasks)
58 {
59 sb.AppendLine($"Task {i++}");
60 sb.AppendFormat("Class {0}, {1} properties\r\n",
61 someTaskInfo.Task.GetType().Name,
62 someTaskInfo.PropertyAccessInfos.Count());
63 foreach (var somePropInfo in someTaskInfo.PropertyAccessInfos)
64 {
65 sb.AppendFormat("Property {0}: {1}, jit? {2}\r\n",
66 somePropInfo.PropInfo.Name,
67 somePropInfo.PropInfo.GetValue(somePropInfo.BaseObject, null),
68 GetJitInfo(someTaskInfo,somePropInfo));
69 }
70 sb.AppendLine();
71 }
72 System.Windows.Forms.MessageBox.Show(Helpers.Gui.MainWindow, sb.ToString(), "Checked other tasks");
73 }
74
75 string ITask.GetTaskAction()
76 {
77 return "Snooping around";
78 }
79
80 #endregion Normal task methods
81
82 #region Job inspection
83
84 private IInspectJob mJobInspector;
85
86 IInspectJob INeedToInspectOtherTasks.JobInspector
87 {
88 set => mJobInspector = value;
89 }
90
91 #endregion Job inspection
92 #region JIT Check
93
94 private JITCheckerDelegate mJitChecker;
95 public JITCheckerDelegate JITChecker { set => mJitChecker = value; }
96 #endregion
97
98
99 }
100}
delegate bool JITCheckerDelegate(object task, string propertyPath)
The delegate that does the check for you.
IWin32Window MainWindow
If you need to set the owner window yourself or want to show message boxes.
Definition: Helpers.cs:37
Static instance for access to utility functions and resources.
Definition: Helpers.cs:78
static IGuiHelper Gui
Utility functions for window handling.
Definition: Helpers.cs:92
To be implemented by the "task" part of a Chronos plugin. Public properties of the implementing type ...
void Execute()
Do whatever you have to do with your parameters.
void PostValidate()
Called after the schedule construction is completed.
string GetTaskAction()
Description of the tasks's action (for hints/time table)
Gives full access to other tasks's properties.
string FullPath
Full path, as must be given in property reference expressions.
Gives access to a task's implementation and to all user visible properties.
object Task
Task object, Chronos internal type.
Allows to get information about other tasks within our task's job and about other jobs.

◆ Task