You have just created the skeleton of a $safeprojectname$ Constraint plug-in for ACP Scheduler
You must do the following in order to complete your implementation:
- BEFORE BUILDING! Show the project properties, Application tab. Change the assembly name to
$safeprojectname$Constraint. This could not be
automated in the template.
- In both the Debug and Release configurations, if you are using Visual Studio 2008, set the project to use .NET Framework 2.0.
- The project has a post-build event that copies the just-built constraint plug in
to the Scheduler's ConstraintPlugins folder. This is all that is needed for the
Scheduler to recognize the new constraint. If you on a 64-bit system, or if you
did not install Scheduler in the normal location C:\Program Files\ACP Scheduler
then you will need to edit this to match your non-standard installation location.
- Again, if you on a 64-bit system, or if you installed Scheduler to a non-standard location, the reference to
ConstraintInterfaceAssembly will be broken, and your project will not build. Look
in the References for a yellow "caution" icon on the reference to ConstraintInterfaceAssembly.
Delete the reference, then re-add it using the Browse tab of the References window,
select ConstraintInterfaceAssembly.dll in the Scheduler install folder. Once you
get this done, the project should build.
- Switch to the Debug configuration and build the template now. It should build without
errors.
- Open the AssemblyInfo.cs and Constraint.cs files, then show the Task List and select Comments. This
will show you the places where you need to add or change things for your constraint. Tasks include
implementing the required properties and methods. If no TODO tasks show (sometimes in VS2008??) search these two files for "TODO" and note what it says there.
- Now implement your constraint logic. The template contains commented sample code for the horizon constraint. This should give you enough info to figure out how the constraints are supposed to work.
- Remove the three lines at the bottom of the Allowable() method. This code was provided so the constraint would build without errors after creating the new constraint project from the template.
Vital Next Steps
- You must start the Scheduler before starting the Browser after you first build the new constraint. See the next note.
- Think carefully about the parameters your constraint needs and decide before starting to test the constraint. Once the Scheduler has been started with the new constraint (see previous note), the database will be altered to add a new table xxx_Constraint. If you change your mind, you'll have to either start with a fresh SchedulerData.mdb or if you have Microsoft Access, remove the xxx_Constraint table, and start the scheduler again after your changes to create a new one with the changed constraint parameters.
Testing and Debugging the Constraint
You can debug and test the constraint right in the Visual Studio debugger. Recall in Note 1 above that each time you build the constraint, a copy of the assembly is placed into the Scheduler's ConstraintPlugins folder.
- Create a test project with targets appropriate to your test. Be sure to enable the new constraint in the Browser's Observation page for each Observation in the test plan. Also be sure you set the targets' coordinates for an appropriate date/time (and the lat/long of the observatory) so they will be evaluated in your constraint for the conditions you wish to test. Finally, Resubmit the plan so it is active. Leave the Browser running (see 7d below).
- Build the constraint in VS. Leave VS running.
- Start the Scheduler. Leave the Dispatcher disabled. Put it into Simulation mode and select your chosen date/time for your test.
- In VS, Debug menu, select Attach to Process. Pick the Scheduler.exe process. This will attach the VS debugger to the running scheduler.
- In VS, constraint.cs, put a breakpoint at the first executable line in the Allowable() method.
- Now start the Dispatcher in the Scheduler, wait for it to do the simulates Open Up, and you should see the Scheduler stop at your breakpoint. You're now in control, with the constraint code "live". You can see the data passed into the constraint by expanding the "this" node in the debugger's Locals tab. You can use the Immediate Window to call back into the scheduler via the documented callbacks. For example try typing m_host.HoursToSunrise into the Immediate Window, and see it print the value.
- When finished debugging, in order to force the Scheduler to re-load the Constraint plug ins
- Stop the Dispatcher
- Detach the VS debugger from Scheduler.exe (Debug menu, detach all processes)
- Exit the Scheduler
- In the Browser, Resubmit your test plan for the next test.
- Now you can loop back to step 2 after making any changes to the Constraint code.
It's important that you understand how Constraints are used, so read the Scheduler paper. |