Learn more about our scanners at: https://joescan.com

Page tree
Skip to end of metadata
Go to start of metadata

Once you have connected to the scanner head(s), you are ready to scan. However, in most cases, the heads are not yet configured to your requirements. This example looks at the procedure for configuring a scan head.

Best Practice

Even though the scanner head will retain configuration information in its non-volatile memory, it is recommended best practice to send the configuration every time you connect.

The configuration parameters are stored in a simple text format that is documented in the Parameter Reference.

 

using System;
using System.IO;
using System.Net;
using JoeScan.JCamNet;

namespace Examples
{
    class Program
    {
        static void Main(string[] args)
        {
            IPAddress baseIpAddress = new IPAddress(new byte[] { 192, 168, 1, 150 });
            // the scanner we want to configure
            Scanner scanner = Scanner.Connect(baseIpAddress, 0);
            
            TextReader parametersReader;
            // Make sure your application can find the parameters file. In Visual Studio, 
            // you can add the file to your project, and use the "Copy to Output Directory" property,
            // forcing Visual Studio to copy the file to your output directory every time you build. 
            using (parametersReader = File.OpenText("param.dat"))
            {
                // the parameters are passed as one long string
                string parametersString = parametersReader.ReadToEnd();
                try
                {
                    // send the configuration parameters, and tell the head to store it permanently
                    scanner.SetParameters(parametersString, true);
                    Console.WriteLine("Scanner {0}:{1} was successfully configured!",
                       scanner.IPAddress.ToString(), scanner.CableID);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Scanner {0}:{1} did not accept configuration parameters!",
                        scanner.IPAddress.ToString(), scanner.CableID);
                }
            }
        }
    }
}

The parameters are passed as a simple string, containing the entire file at once. Depending on your application, you can provide this string any way you'd like (e.g., retrieve it from a database, read it from a file, or build it 'on the fly'). 

Unicode Text

Be aware that some text editors change the encoding of the file and store it as 'UTF-8', in which case the SetParameters() function may fail.

  • No labels