C# - OBAFGKM https://www.obafgkm.ca/category/c/ Astro/Geo/Data Tue, 21 Apr 2020 21:16:34 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.4 https://i0.wp.com/www.obafgkm.ca/wp-content/uploads/2022/04/cropped-RMS-headbadge-colour-notext.png?fit=32%2C32&ssl=1 C# - OBAFGKM https://www.obafgkm.ca/category/c/ 32 32 204991942 Setting up an ASCOM driver project https://www.obafgkm.ca/2020/04/21/setting-up-an-ascom-driver-project/?utm_source=rss&utm_medium=rss&utm_campaign=setting-up-an-ascom-driver-project https://www.obafgkm.ca/2020/04/21/setting-up-an-ascom-driver-project/#respond Tue, 21 Apr 2020 21:16:34 +0000 http://orebits.ca/?p=504 What follows is simply a step-by-step guide to setting up an ASCOM driver project with Visual Studio 2019 – mainly so that I don’t forget how to do it myself… Creating from an ASCOM template Install ASCOM and developer components. Start Visual Studio as admin Click on ‘Create a new project’ Search for ‘ascom’ in the search field and choose ‘ASCOM Device Driver (C#)’ Give the project a sensical name and Create… The ASCOM Driver Project Wizard will then appear. Select a driver class and choose another sensical name. Click ‘Create’. The Visual Studio solution should appear with a document to be read. Follow the instructions by trying to build the solution and, if successful, adding a new project. Add a new project by right-clicking on the solution in Solution Explorer and then Add -> New Project… In the new dialog, choose an ‘ASCOM Test Console Application (C#)’ and click ‘Next’ Now, choose a name. Maybe just add ‘Console’ to…

The post Setting up an ASCOM driver project first appeared on OBAFGKM.

The post Setting up an ASCOM driver project appeared first on OBAFGKM.

]]>
What follows is simply a step-by-step guide to setting up an ASCOM driver project with Visual Studio 2019 – mainly so that I don’t forget how to do it myself…

Creating from an ASCOM template

  1. Install ASCOM and developer components.
  2. Start Visual Studio as admin
  3. Click on ‘Create a new project’
  4. Search for ‘ascom’ in the search field and choose ‘ASCOM Device Driver (C#)’
  5. Give the project a sensical name and Create…
  6. The ASCOM Driver Project Wizard will then appear. Select a driver class and choose another sensical name. Click ‘Create’.
  7. The Visual Studio solution should appear with a document to be read. Follow the instructions by trying to build the solution and, if successful, adding a new project.

  8. Add a new project by right-clicking on the solution in Solution Explorer and then Add -> New Project…
  9. In the new dialog, choose an ‘ASCOM Test Console Application (C#)’ and click ‘Next’
  10. Now, choose a name. Maybe just add ‘Console’ to the end of the first project name  and  click  ‘Create’

  11. The ASCOM Driver Project Wizard appears again. Choose the correct Device Class and use the same Device Name/Model as in the previous project. Click ‘Create’.
  12. Select the solution in Solution Explorer and then go down to Properties and set the startup project to be the console project.
  13. CTRL+F5 should start things without debugging. The device chooser will appear.  Select  the  new  driver  by  name.

  14. Select ‘Properties…’ to view the setup dialog.

  15. That’s about it. A skeleton driver has been created and is ready for customization.

Setting up the ASCOM settings provider

  1. The first thing to do is to strip out unnecessary code from SetupDialogForm.cs and driver.cs. This will be the code that is attached to elements in the setup dialog. In the default template it is the ‘Comm Port’ selection, the ‘Trace’ check box, and the OK button. Remove the circled code shown below,  and  add  some  comments  to  make  sure  that  you  come  back  and  add  the  appropriate  code  for reading  and  writing  the  settings.  Also  delete  the  entire  ReadProfile()  and  WriteProfile()  methods.

  2. In the setup dialog select a field such as the default ‘Comm Port’ drop-down box and then click on the PropertyBinding setting in ApplicationSettings

  3. Click the ellipsis to the right of PropertyBinding and a pop-up should appear

  4. Click the drop-down menu to the right of text and then click on (New…). Another pop-up window should appear.

  5. Give it a name, leave scope as user and click OK. Click OK once more.

  6. Repeat for all other settings elements in the setup dialog
  7. In driver.cs find the section where WriteProfile was removed and add a line as shown…

  8. Add a bit more code after this to reload the settings if the cancel button was clicked

  9. Anywhere that the old ‘comPort’ variable is used in the code can now be changed to Properties.Settings.Default.PortName

  10. Double-click on properties for the project

  11. Click on ‘View Code’ to generate a settings.cs file

  12. Add using System.Configuration; to the top of settings.cs if it’s not already there. Add the following settings provider attribute to settings.cs

  13. Change deviceID and driverDescription definitions to public const in driver.cs

  14. Add the following to settings.cs

  15. More to come…

Setting up for FLI cameras

  1. Import FliUtils project
  2. Add LibFliProNative.cs and FliPro.cs to driver project
  3. Add reference in driver project to FliUtils
  4. Look for errors and add additional references to resolve them

The post Setting up an ASCOM driver project first appeared on OBAFGKM.

The post Setting up an ASCOM driver project appeared first on OBAFGKM.

]]>
https://www.obafgkm.ca/2020/04/21/setting-up-an-ascom-driver-project/feed/ 0 504