JoeScan
  home
our story
news  and events
contact us
    our products
how it works
applications support service

Tutorial for Snapshot Scanning

You just want to get some data from the scanner quickly. Here's how:

  1. Call jsInitialize() if the Joescan API is statically linked.
  2. Open a connection using jsOpenConnection().
  3. Save the parameters using jsSendParameterFileToScanner() in case a scanner has been swapped out.
  4. Get profiles using jsGetProfile().
  5. Close the connection using jsCloseConnection().

#define JCAM_STATIC_LIB
#include <string>
#include <stdio.h>
#include "jcam_dll.h"

using namespace joescan;

int main(int argc, char **argv)
{
    if(jsInitialize() == FALSE)
    {
        printf("Could not initialize TCP\IP communications.\n");
        return -1;
    }

    std::string ip("192.168.1.205");
    if(argc > 1)
        ip = argv[1];

    JCONNECTION jc = jsOpenConnection(ip.c_str());
    if(jc == 0)
    {
        printf("Could not open connection to %s.\n", ip.c_str());
        return -1;
    }

    switch(jsSendParameterFileToScanner(jc, "param.dat"))
    {
        case SCANNER_FAILURE:
            printf("Lost connection.\n");
            jsCloseConnection(jc);
            jc = 0;
            return -1;
        case OPERATION_FAILURE:
            for(i = 0; i < jsGetNumberOfErrorMessages(jc); i++)
                printf("%s\n", jsGetErrorMessage(jc, i));
            jsCloseConnection(jc);
            jc = 0;
            return -1;
        default:
            printf("Sent parameters successfully.\n");
    }

    jsProfile profile;

    while(PLC.isLogVisible())
    {
        switch(jsGetProfile(jc, &profile))
        {
            case 0:
                logModel.addProfile(profile);
                break;
            case PROFILE_UNAVAILABLE:
                //In normal mode, this return value is impossible.
                printf("PROFILE_UNAVAILABLE\n");
                break;
            case INVALID_PARAMETER:
                printf("INVALID_PARAMETER\n");
                jsCloseConnection(jc);
                jc = 0;
                return -1;
            case SCANNER_FAILURE:
                printf("SCANNER_FAILURE\n");
                jsCloseConnection(jc);
                jc = 0;
                return -1;
        }
    }

    optimizer.fullyOptimize(logModel);
    jsCloseConnection(jc);
    jc = 0;
    return 0;
}