Creating a New Project

To create a new CFHEADER .NET project in Visual Studio, simply follow these steps:

  1. Open Visual Studio and select “Create a new project”.<html><p>&nbsp;</p></html>
  2. Select the project type from one of the project templates. <html><p>&nbsp;</p></html>
  3. Give the project a name. <html><p>&nbsp;</p></html>
  4. Select additional project options. <html><p>&nbsp;</p></html>
  5. Right-click on the project node and select “Manage Nuget Packages…”. <html><p>&nbsp;</p></html>
  6. Install the ComfileTech.Cfnet.Cfheader Nuget package. <html><p>&nbsp;</p></html>
  7. Write code.
    <html><p>&nbsp;</p></html> Try the following example:
    using ComfileTech.Cfnet.Cfheader;
     
    var cfheader0 = Cfheader.Instances[0];
    var digitalOutputModule0 = cfheader0.DigitalOutputModules[0];
     
    cfheader0.Open();
     
    while (true)
    {
        // Blink each output in increasing order
        foreach (var channel in digitalOutputModule0.Channels)
        {
            channel.Blink();
        }
     
        // Blink each output in decreasing order
        foreach (var channel in digitalOutputModule0.Channels.Reverse())
        {
            channel.Blink();
        }
    }
     
    static class Extensions
    {
        public static void Blink(this DigitalOutputModule.Channel channel)
        {
            // Toggle the channel's state
            channel.Toggle();
     
            // Delay for 50ms
            Thread.Sleep(50);
     
            // Toggle the channel's state again
            channel.Toggle();
        }
     
        public static void Toggle(this DigitalOutputModule.Channel channel)
        {
            // Toggle state
            channel.State = !channel.State;
     
            // Write the state to the module
            channel.Module.Header.Sync();
        }
    }

CFHEADER - USB Interface to CFNET IO Modules