- Software Products
- Trial Software
- CAD Translation
- Testimonials
- Overview
- Pricing
- Knowledge Base
- Contact Us -
- Languages
There is a Remote Application Programming Interface (API) available for the Unisoft software that allows it to be controlled by external applications.
This Remote API effectively turns Unisoft into an automation engine that can be integrated into larger engineering, test, or manufacturing workflows, enabling precise and repeatable control without manual interaction.
In practical terms, it is a programmatic interface for the Unisoft PCB/CAD viewer/editor that allows other software to operate Unisoft directly without user input.
It is designed for automation, system
integration, and batch processing from scripts, test systems, MES/ERP
platforms, or custom-developed applications.
The API is exposed through
header/interface files (such as API.H) that are installed locally, typically
located at:
C:\Program Files
(x86)\Unisoft\RemoteAPI\API
What it lets you do. The API provides command-level control over
Unisoft’s core functions, including:
1. File & Data Control
Open
boards (CAD, F2B, etc.)
Set working directories
Import / clear BOMs
Import / clear annotation overlays
Export boards to multiple formats
2. Display & View Control
Zoom, rotate, flip boards
Switch between
top / bottom / schematic views
Resize and reposition windows
Change or
focus panes
Show or hide layers, nets, components, vias
3. Search
& Navigation
Find components
Find nets
Find pins and vias
Automatically center or highlight results
How it’s typically used
Manufacturing automation (ICT, flying probe, AOI workflows)
MES or
test-system integration
Custom viewers or “one-click” engineering tools
Batch processing (open → zoom → export → close)
Hands-free operation from
another application
Functions available per API.H is located by default in directories c:\program files (x86)\unisoft\remoteapi\api or c:\program files (x86)\unisoft\remoteapi\api.
Some operations are:
Below is a minimal, concrete example of how a typical FindComponents call
would look when using the Unisoft Remote API from a C/C++ style application.
Because the API is exposed via API.H, this is written in the expected
native style.
Example: FindComponents call (C/C++)
#include
"api.h"
/*
Finds and displays one or more components on the
currently open board
*/
int result;
result =
FindComponents(
"R1,R5,U12", // Component reference designators
(comma-separated)
TRUE // Display / highlight the components
);
if (result != 0)
{
// Handle error
}
Typical
Parameters (conceptual)
While exact signatures can vary slightly by
build, FindComponents generally accepts:
Parameter Purpose
Component list One or more refdes values (e.g., R1, U12)
Display flag
Whether to zoom/highlight results
Optional view Target pane (top, bottom,
schematic)
Example: single component
FindComponents("U3", TRUE);
Example: search without changing view
FindComponents("C10,C11,C12",
FALSE);
Expected behavior
Components are located
Display centers
and highlights them (if enabled)
Existing view state remains otherwise
unchanged
Notes
Board must already be opened via OpenBoard()
View
focus may optionally be set first using SetCurView()
Errors are typically
returned as non-zero integers
ReadMe.txt instructions located at: \unisoft\RemoteApi\RAPI_Test
========================================================================
This file presents explanations on
how to use Unisoft ProntoVIEW-MARKUP
remote managment API
(C) Copyright 1995-2026 Unisoft Corp.
========================================================================
1) To build your project:
You should have:
- Api.dll - This file
is a key to remote management. You can use it from your "C/C++"
code
using WIN32 API functions "LoadLibrary" and "GetProcAddress". Additionally,
you can use it from different tools like "LabView" where you can call
function the
"DllLoad" etc.
- Api.lib - If you want not to use WIN32
API functions "LoadLibrary" and
"GetProcAddress", for calling the API
directly, you will need this file
for the link step of your project
building.
- Api.h - If you use direct calls (that is, Api.lib) you need
this file to include
into your source files, It is a good idea to take a
look at this file
because it has full a explanation (in comments) on how
to use the remote management
API.
2) To run your project:
-
Put Api.dll in the same place where your project executable is supposed to
be
located. Or, Windows directory, or any directory which is declared as
part of
environment variable PATH (that your application can find this a
dll).
- Run Unisoft ProntoVIEW-MARKUP, version v5.10 or higher, on the
same machine. If you do
not run Unisoft ProntoVIEW-MARKUP then any
remote management API call will return "NO
TRANSPORT".
3) Helpful
information:
- Take a look at all comments in Api.h . You can find there
explanations on how to
call each API function.
- Project
"RAPI_Test.dsp" is a working example how to use the remote managment API.
This project is a consol application which accepts from user commands as a
string,
parses it and calls appropriate API function. Run RAPI_Test.exe
and give commands
"help" and "help help". To build by yourself
RAPI_Test.exe you need the next:
- RAPI_Test.c - main file;
- utils.c
- file contains functions to convert input string into right
parameters.
- util.h - prototypes of functions to convert input string into right
parameters.
- ..\Api\Api.h - API prototypes;
- Api.lib - file for link
step;
- You can use any Windows compiler to build RAPI_Test.exe, but if
you have
VC++ 6 or newer, you can open project RAPI_Test.dsp and just
push the button to "build". Do not
forget to put Api.h file into
directory "..\Api\" or change "include" directive in
RAPI_Test.c which
states [#include "..\\Api\\Api.h"].
4) RAPI_Test.exe works also as a
utility. This means it can be invoked from batch file with
parameters.
For example, the next command will invoke RAPI_Test.exe which in turn will
force Unisoft ProntoVIEW-MARKUP to open the board and RAPI_Test will end
execution
(return control to consol): "PARI_Test OpenBoard MyBoard.f2b"
Two batch files show how to use this feature - test.bat and test1.bat
Two
new commands:
- SetCurViewSize <PERCENT> - Make the current view to
occupy main window as
<PERCENT> percents; <PERCENT> can be from range
5-95;
- SetBoardDir <PATH> - Makes Unisoft ProntoVIEW-MARKUP remember
where to look for the
board file. After this command is done the user
can do command "OpenBoard" with
a relative path name. Regardless of this
command user still can use ABSOLUTE path
name. Unisoft ProntoVIEW-MARKUP
will understand whether or not the parameter
of "OpenBoard" is the
absolute path. You need to make this command just once.
Unisoft
ProntoVIEW-MARKUP will remember the board path until the next
"SetBoardDir" command or until closing Unisoft ProntoVIEW-MARKUP itself.
The files test.bat and test1.bat use command SetBoardDir and
OpenBoard with two CAD examples.
Feel free to change it.
Thank
you!
Api.h code at
located at:
\unisoft\RemoteApi\Api
// The
following ifdef block is the standard way of creating macros which make
exporting
// from a DLL simpler. All files within this DLL are compiled
with the API_EXPORTS
// symbol defined on the command line. this symbol
should not be defined on any project
// that uses this DLL. This way any
other project whose source files include this file see
// API_API
functions as being imported from a DLL, wheras this DLL sees symbols
//
defined with this macro as being exported.
#ifdef API_EXPORTS
#define
API_API __declspec(dllexport)
#else
#define API_API
__declspec(dllimport)
#endif
/////////////////////////////////////////////////////////////
// Errors
the API may return
/////////////////////////////////////////////////////////////
enum
RAPI_Errors
{
RAPI_ERROR_SUCCESS //It means that command has been
passed to Markup
//successfully. But Markup may not to perform the
//command due to it's internal state. For example,
//board, recently
opened, has been opened in
//shareware mode, which means, no any action
is allowed
, RAPI_ERROR_BUSY //Most likely, Markup is processing previous
message right now
, RAPI_ERROR_NO_TRANSPORT //Most likely, Markup is not
running
, RAPI_ERROR_BAD_PARAM //Most likely, One or more parameters have
wrong value
};
/////////////////////////////////////////////////////////////
// The
enumeration presents values for parameter "WHAT"
// for cmd "Show"
/////////////////////////////////////////////////////////////
enum
CmdWhatToShow{
CMD_SHOW_HIDDEN_OBJECTS = 1
, CMD_SHOW_PINS
,
CMD_SHOW_TRACES
, CMD_SHOW_SILK_SCREEN
, CMD_SHOW_VIAS
,
CMD_SHOW_COMPONENT_OUTLINES
, CMD_SHOW_SMD_COMPONENTS
,
CMD_SHOW_TEST_NAILS
, CMD_SHOW_LABELS
, CMD_SHOW_ANNOTATIONS
,
CMD_SHOW_NO_CMD
};
/////////////////////////////////////////////////////////////
// The
enumeration presents values for parameter "HOW"
// for cmd "Show"
/////////////////////////////////////////////////////////////
enum
CmdHowToShow{
CMD_SHOW_HOW_SHOW
, CMD_SHOW_HOW_HIDE
,
CMD_SHOW_HOW_NO_CMD
};
/////////////////////////////////////////////////////////////
// The
enumeration presents values for parameter "AS_WHAT"
// for cmd
"ShowCurView"
/////////////////////////////////////////////////////////////
enum
CmdHowToShowCurView{
CMD_SHOW_CUR_VIEW_TOP = 1
,
CMD_SHOW_CUR_VIEW_BOTTOM
, CMD_SHOW_CUR_VIEW_SCHEMATIC
,
CMD_SHOW_CUR_VIEW_NO_CMD
};
/////////////////////////////////////////////////////////////
// The
enumeration presents values for parameter "HOW"
// for cmd "ZoomCurView"
/////////////////////////////////////////////////////////////
enum
CmdHowToZoomCurView{
CMD_ZOOM_CUR_VIEW_FIT = 1
,
CMD_ZOOM_CUR_VIEW_IN_TWICE
, CMD_ZOOM_CUR_VIEW_OUT_TWICE
,
CMD_ZOOM_CUR_VIEW_HOW_MANY
, CMD_ZOOM_CUR_VIEW_NO_CMD
};
//If
you include this "H" file into C++ source file then
//make sure the
"__cplusplus" macro is defined.
//If you use Microsoft VC++ and your file
has extension "cpp"
//the macro is defined by default.
#ifdef
__cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////
//Return
value of all functions below can any from
//enum RAPI_Errors. See
explanations in comments above,
//in enum RAPI_Errors
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//
Function Name: OpenBoard
// Parameters:
// char *FileName - path name
of file which contains
// board description. It is recomended
// to
set the parameter as FULL PATH NAME
// char *pAdditionalParams - Some
importers request from user
// addittonal parameters to open board.
//
You can set the parameter as NULL. In that
// case, importer will use
"Markup" user interface
// to ask user (You) additional parameters.
//
Now, two importers only support additional parameters
// One is for "neu"
CAD file. It needs additional
// file name which contains traces
description. In "neu"
// case the parameter should be full path of the
file
// which contains traces description. Second is "356"
//
importer. In that case additional parameter is a
// string which actually
contains numeric value from range
// "1" - "5"
//Descriptions:
//
Sends command to markup to open CAD file
////////////////////////////////////////////////////////////////
API_API
int OpenBoard(char *FileName, char *pAdditionalParams);
////////////////////////////////////////////////////////////////
//
Function Name: SetCurView
// Parameters:
// char *ViewRorL - Allowed
parameter values are:
// "L" or "l" Left view (pane) is supposed to be
// current (have a focus)
// "R" or "r" Right view (pane) is supposed to
be
// current (have a focus)
//Descriptions:
// Sends command to
markup to set focus on particular view (pane).
// To call this function
to set a focus is NOT mandatory.
// After you open a board the left view
is current.
////////////////////////////////////////////////////////////////
API_API
int SetCurView(char *ViewRorL);
////////////////////////////////////////////////////////////////
//
Function Name: Show
// Parameters:
// int What - Allowed parameter
values are from enum CmdWhatToShow
// See enum CmdWhatToShow above
//
int How - Allowed parameter values are from enum CmdHowToShow
// See enum
CmdHowToShow above
//Descriptions:
// Sends command to markup to show
or hide different elements
// of previously opened CAD file
////////////////////////////////////////////////////////////////
API_API
int Show(int What, int How);
////////////////////////////////////////////////////////////////
//
Function Name: ShowCurView
// Parameters:
// int AsWhat - Allowed
parameter values are from enum CmdHowToShowCurView
// See enum
CmdHowToShowCurView above
//Descriptions:
// Sends command to markup
to show in current view (pane) board's
// top, bottom or schematic. To
set view as current (have a focus)
// use SetCurView function
////////////////////////////////////////////////////////////////
API_API
int ShowCurView(int AsWhat);
////////////////////////////////////////////////////////////////
//
Function Name: ZoomCurView
// Parameters:
// int How - Allowed
parameter values are from enum CmdHowToZoomCurView
// See enum
CmdHowToZoomCurView above
// int HowMany - If first parameter is
CMD_ZOOM_CUR_VIEW_HOW_MANY then
// you should set this parameter as
persent of zoom.
// Allowed values from range 10-1000
//Descriptions:
// Sends command to markup to zoom current view (pane)
// To set view as
current (have a focus) use SetCurView function
////////////////////////////////////////////////////////////////
API_API
int ZoomCurView(int How, int HowMany);
////////////////////////////////////////////////////////////////
//
Function Name: Rotate
// Parameters: None
//Descriptions:
// Sends
command to markup to Rotate all views
////////////////////////////////////////////////////////////////
API_API
int Rotate();
////////////////////////////////////////////////////////////////
//
Function Name: Flip
// Parameters:
// int How - Allowed parameter
values are:
// "1" - Horizontal Direction
// "2" - Verttical Direction
//Descriptions:
// Sends command to markup to flip all views
////////////////////////////////////////////////////////////////
API_API
int Flip(int How);
////////////////////////////////////////////////////////////////
//
Function Name: MoveCurView
// Parameters:
// int HShift - Movement
shift in horizontal directions
// int VShift - Movement shift in vertical
directions
// Any "Shift" parameter may have value as positive so
//
negative. Mesurement is in pixels
//Descriptions:
// Sends command to
markup to move current view as described
// in parameters
////////////////////////////////////////////////////////////////
API_API
int MoveCurView(int HShift, int VShift);
////////////////////////////////////////////////////////////////
//
Function Name: ClearBom
// Parameters: None
//Descriptions:
//
Sends command to markup to clear BOM information
////////////////////////////////////////////////////////////////
API_API
int ClearBom();
////////////////////////////////////////////////////////////////
//
Function Name: ClearAnnotation
// Parameters: None
//Descriptions:
// Sends command to markup to clear annotations
////////////////////////////////////////////////////////////////
API_API
int ClearAnnotation();
////////////////////////////////////////////////////////////////
//
Function Name: ImportBom
// Parameters:
// char *FileName - Name of
file where BOM information is found
//Descriptions:
// Sends command
to markup to import BOM information
////////////////////////////////////////////////////////////////
API_API
int ImportBom(char *FileName);
////////////////////////////////////////////////////////////////
//
Function Name: ImportAnnotation
// Parameters:
// char *FileName -
Name of file where Annotation information is found
//Descriptions:
//
Sends command to markup to import Annotation information
////////////////////////////////////////////////////////////////
API_API
int ImportAnnotation(char *FileName);
////////////////////////////////////////////////////////////////
//
Function Name: FindComponents
// Parameters:
// int zoom_in - Allowed
values are:
// "1" Yes. if component is found then zoom it in
// char
*Comp1Name - Name of component to be found. Component name
// may contain
"pin" information. Component name
// and "pin" information are divided by
dot (".").
// For example, "C1.1". If you put "pin" information
//
then traces will be displayed
// char *Comp2Name - Same as Comp1Name. One
difference.
// This parameter can be NULL.
//Descriptions:
// Sends
command to markup to find component and display according to
//
parameters. To find component in Schematic view, before this call,
// use
call ShowCurView(CMD_SHOW_CUR_VIEW_SCHEMATIC);
////////////////////////////////////////////////////////////////
API_API
int FindComponents(int zoom_in, char *Comp1Name, char *Comp2Name);
////////////////////////////////////////////////////////////////
//
Function Name: FindNets
// Parameters:
// char *Net1Name - Name of Net
to be found.
// char *Net2Name - Same as Net1Name. One difference.
//
This parameter can be NULL.
//Descriptions:
// Sends command to markup
to find net(s) and display it (them)
// To find net in Schematic view,
before this call,
// use call ShowCurView(CMD_SHOW_CUR_VIEW_SCHEMATIC);
////////////////////////////////////////////////////////////////
API_API
int FindNets(char *Net1Name, char *Net2Name);
////////////////////////////////////////////////////////////////
//
Function Name: SetCurViewSize
// Parameters:
// int Percent - size (in
percent of main window).
//Descriptions:
// Sends command to markup to
occupy "Percent" percents
// of main window by current view
////////////////////////////////////////////////////////////////
API_API
int SetCurViewSize(int Percent);
////////////////////////////////////////////////////////////////
//
Function Name: SetBoardDir
// Parameters:
// char *pPath - Path, where
boards' CAD files are located.
// If pPath == NULL then it is considered
like "" (empty string)
//Descriptions:
// Sends command to markup to
set boards' current dir
// of main window by current view
////////////////////////////////////////////////////////////////
API_API
int SetBoardDir(char *pPath);
////////////////////////////////////////////////////////////////
//
Function Name: ExportBoard
// Parameters:
// char *sFileType - export
file type
// char *sFileName - path name of file which is to contain
// the exported board. It is recomended
// to set the parameter as FULL
PATH NAME
//Descriptions:
// Sends command to markup to export CAD
file
////////////////////////////////////////////////////////////////
API_API int ExportBoard(char *sFileType, char *sFileName
/*, char
*pAdditionalParams*/);
////////////////////////////////////////////////////////////////
//
Function Name: FindPinVia
// Parameters:
// int zoom_in - Allowed
values are:
// "1" Yes. iI pin/via is found then zoom in on it.
//
char *PinViaName - Name of pin/via to be found. A pin name may
// contain
"component" information. Component name
// and "pin" information are
divided by a dot (".").
// For example, "C1.1".
//Descriptions:
//
Sends command to markup to find pin or via and display according
// to
zoom parameter. To find pin/via in Schematic view, before this
// call,
use call ShowCurView(CMD_SHOW_CUR_VIEW_SCHEMATIC);
////////////////////////////////////////////////////////////////
API_API
int FindPinVia(int zoom_in, char *PinViaName);
////////////////////////////////////////////////////////////////
//
Function Name: SetWindowSizeLocation
// Parameters:
// int top - Top
location of Markup window in pixels
// int left - Left location of Markup
window in pixels
// int height - Height of Markup window in pixels
//
int width - Width of Markup window in pixels
//Descriptions:
// Sends
command to markup to position and size window
////////////////////////////////////////////////////////////////
API_API
int SetWindowSizeLocation(int top, int left, int height, int width);
#ifdef __cplusplus
}
#endif
RAPI_Test.c
code located at: \unisoft\RemoteApi\RAPI_Test
//
RAPI_Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string.h>
#include <conio.h>
#include <stdio.h>
#include <stdarg.h>
#include "..\\Api\\Api.h"
#include "utils.h"
#ifndef MAX_PATH
#define MAX_PATH _MAX_PATH
#endif
char g_ConsolPrintfBuf[1024];
char g_Prompt[80];
#define
DEFAULT_PROMPT "Enter>"
void ConsolPrintf( const char* fmt, ... )
{
int iStrSize ;
va_list ConsolPrintfList ;
va_start(
ConsolPrintfList, fmt );
iStrSize = vsprintf(g_ConsolPrintfBuf, fmt,
ConsolPrintfList );
va_end( ConsolPrintfList );
printf("\r\n");
printf(g_ConsolPrintfBuf);
}
///////////////////////////////////////////////////////
// CMD "help"
///////////////////////////////////////////////////////
void helpHelp()
{
ConsolPrintf("help or help [command]");
}
int helpCmd(char
*pParam, int len);
///////////////////////////////////////////////////////
// CMD "bye"
///////////////////////////////////////////////////////
void byeHelp()
{
ConsolPrintf("bye. Exit from the test");
}
///////////////////////////////////////////////////////
// CMD
"OpenBoard"
///////////////////////////////////////////////////////
void OpenBoardHelp()
{
ConsolPrintf("OpenBoard FILENAME
ADITIONAL_PARAM");
ConsolPrintf(" Where FILENAME - file name which
contains board description");
ConsolPrintf(" ADDITIONAL_PARAM -
Additional parameter for importer");
ConsolPrintf(" This parameter is not
mandatory and");
ConsolPrintf(" it's nature depends on importer");
ConsolPrintf(" NOTE: If any file name contains spaces you should enclose
it");
ConsolPrintf(" in quotation marks. For example:");
ConsolPrintf(" [OpenBoard \"c:\\My file.txt\"]");
ConsolPrintf(" It is
recommended to put full pathname");
}
///////////////////////////////////////////////////////
// CMD
"SetCurView"
///////////////////////////////////////////////////////
void SetCurViewHelp()
{
ConsolPrintf("SetCurView L or R");
ConsolPrintf(" Where L - Left View");
ConsolPrintf(" R - Right View");
}
///////////////////////////////////////////////////////
// CMD
"ShowCurView"
///////////////////////////////////////////////////////
void ShowCurViewHelp()
{
ConsolPrintf("ShowCurView AS_WHAT");
ConsolPrintf(" Where AS_WHAT:");
ConsolPrintf(" \"1\" - Top");
ConsolPrintf(" \"2\" - Bottom");
ConsolPrintf(" \"3\" - Schematic");
}
///////////////////////////////////////////////////////
// CMD
"SetCurView"
///////////////////////////////////////////////////////
void ShowHelp()
{
ConsolPrintf("Show WHAT HOW");
ConsolPrintf("
Where WHAT:");
ConsolPrintf(" \"1\" - Hidden Objects");
ConsolPrintf("
\"2\" - Pins");
ConsolPrintf(" \"3\" - Traces");
ConsolPrintf(" \"4\"
- Silk Screen");
ConsolPrintf(" \"5\" - Vias");
ConsolPrintf(" \"6\" -
Component Outlines");
ConsolPrintf(" \"7\" - SMD Components");
ConsolPrintf(" \"8\" - Test Nails");
ConsolPrintf(" \"9\" - Labels");
ConsolPrintf(" \"10\" - Annotations");
ConsolPrintf(" Where HOW:");
ConsolPrintf(" \"1\" - Show");
ConsolPrintf(" \"0\" - Hide");
}
///////////////////////////////////////////////////////
// CMD
"ZoomCurView"
///////////////////////////////////////////////////////
void ZoomCurViewHelp()
{
ConsolPrintf("ZoomCurView HOW HOW_MANY");
ConsolPrintf(" Where HOW:");
ConsolPrintf(" \"1\" - Zoom To Fit");
ConsolPrintf(" \"2\" - Zoom In Twice");
ConsolPrintf(" \"3\" - Zomm Out
Twice");
ConsolPrintf(" \"4\" - Zomm HOW_MANY");
ConsolPrintf(" Where
HOW_MANY is percent. Available Value is in a range 10-10000");
}
///////////////////////////////////////////////////////
// CMD "Rotate"
///////////////////////////////////////////////////////
void RotateHelp()
{
ConsolPrintf("Rotate (no parameters)");
}
///////////////////////////////////////////////////////
// CMD "Flip"
///////////////////////////////////////////////////////
void FlipHelp()
{
ConsolPrintf("Rotate HOW");
ConsolPrintf(" Where HOW:");
ConsolPrintf(" \"1\" - Horizontal Direction");
ConsolPrintf(" \"2\" -
Verttical Direction");
}
///////////////////////////////////////////////////////
// CMD
"MoveCurView"
///////////////////////////////////////////////////////
void MoveCurViewHelp()
{
ConsolPrintf("MoveCurView H_SHIFT V_SHIFT");
ConsolPrintf(" Where H_SHIFT is integer, horizontal direction shift");
ConsolPrintf(" Where V_SHIFT is integer, vertical direction shift");
}
///////////////////////////////////////////////////////
// CMD
"ClearBom"
///////////////////////////////////////////////////////
void ClearBomHelp()
{
ConsolPrintf("ClearBom (no parameters)");
}
///////////////////////////////////////////////////////
// CMD
"ClearAnnotation"
///////////////////////////////////////////////////////
void ClearAnnotationHelp()
{
ConsolPrintf("ClearAnnotation (no
parameters)");
}
///////////////////////////////////////////////////////
// CMD
"ImportBom"
///////////////////////////////////////////////////////
void ImportBomHelp()
{
ConsolPrintf("ImportBom FILE_NAME");
}
///////////////////////////////////////////////////////
// CMD
"ImportAnnotation"
///////////////////////////////////////////////////////
void
ImportAnnotationHelp()
{
ConsolPrintf("ImportAnnotation FILE_NAME");
}
///////////////////////////////////////////////////////
// CMD
"FindComponents"
///////////////////////////////////////////////////////
void FindComponentsHelp()
{
ConsolPrintf("FindComponents ZOOM_IN COMP1
COMP2");
ConsolPrintf(" Where ZOOM_IN:");
ConsolPrintf(" \"1\" -
YES");
ConsolPrintf(" \"2\" - NO");
ConsolPrintf(" Where COMP1 is name
of componet to be found");
ConsolPrintf(" The name may be followed by
\".\" and PIN number");
ConsolPrintf(" Where COMP2 is name of other
componet.");
ConsolPrintf(" This field is not mandatory.");
ConsolPrintf(" The name may be followed by \".\" and PIN number");
}
///////////////////////////////////////////////////////
// CMD
"FindNets"
///////////////////////////////////////////////////////
void FindNetsHelp()
{
ConsolPrintf("FindNets NET1 NET2");
ConsolPrintf(" Where NET1 is name of net to be found");
ConsolPrintf("
Where NET2 is name of net to be found");
ConsolPrintf(" This field is not
mandatory.");
}
///////////////////////////////////////////////////////
// CMD
"SetCurViewSize"
///////////////////////////////////////////////////////
void SetCurViewSizeHelp()
{
ConsolPrintf("SetCurViewSize PERCENT");
ConsolPrintf(" Where PERCENT is from range 5-95");
}
///////////////////////////////////////////////////////
// CMD
"SetBoardDir"
///////////////////////////////////////////////////////
void SetBoardDirHelp()
{
ConsolPrintf("SetBoardDir DIRECTORY");
ConsolPrintf(" Where DIRECTORY is boards' path location without trailing
backslash");
}
///////////////////////////////////////////////////////
// CMD
"FindPinVia"
///////////////////////////////////////////////////////
void FindPinViaHelp()
{
ConsolPrintf("FindPinVia ZOOM_IN PIN");
ConsolPrintf(" Where ZOOM_IN:");
ConsolPrintf(" \"1\" - YES");
ConsolPrintf(" \"2\" - NO");
ConsolPrintf(" Where PIN is name of pin or
via to be found");
//ConsolPrintf(" The name may be followed by \".\" and
PIN number");
}
///////////////////////////////////////////////////////
// CMD
"SetWindowSizeLocation"
///////////////////////////////////////////////////////
void
SetWindowSizeLocationHelp()
{
ConsolPrintf("SetWindowSizeLocation TOP
LEFT HEIGHT WIDTH");
ConsolPrintf(" Where TOP is top position in pixels
of Markup window");
ConsolPrintf(" Where LEFT is left position in pixels
of Markup window");
ConsolPrintf(" Where HEIGHT is height in pixels of
Markup window");
ConsolPrintf(" Where WIDTH is width in pixels of Markup
window");
}
///////////////////////////////////////////////////////
// Supported CMDs
///////////////////////////////////////////////////////
char
*PCBMarkupCmdName[] =
{
"help"
, "bye"
, "OpenBoard"
,
"SetCurView"
, "Show"
, "ShowCurView"
, "ZoomCurView"
, "Rotate"
, "Flip"
, "MoveCurView"
, "ClearBom"
, "ClearAnnotation"
,
"ImportBom"
, "ImportAnnotation"
, "FindComponents"
, "FindNets"
, "SetCurViewSize"
, "SetBoardDir"
, "FindPinVia"
,
"SetWindowSizeLocation"
};
int g_PCBMarkupCmdAmount =
sizeof(PCBMarkupCmdName)/sizeof(char*);
typedef void (*HelpFunc)();
HelpFunc PCBMarkupCmdHelp[] =
{
helpHelp
, byeHelp
,
OpenBoardHelp
, SetCurViewHelp
, ShowHelp
, ShowCurViewHelp
,
ZoomCurViewHelp
, RotateHelp
, FlipHelp
, MoveCurViewHelp
,
ClearBomHelp
, ClearAnnotationHelp
, ImportBomHelp
,
ImportAnnotationHelp
, FindComponentsHelp
, FindNetsHelp
,
SetCurViewSizeHelp
, SetBoardDirHelp
, FindPinViaHelp
,
SetWindowSizeLocationHelp
};
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
// Variables and Functions for Test application
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
#define INPUT_BUFFER_LEN 256
char g_InputBuffer[INPUT_BUFFER_LEN];
//g_InputBuffer[0] = 128 - max length of expected string
//g_InputBuffer[1] will contain actual length of input string
//&g_InputBuffer[2] will contain start of actual string
void
Usage()
{
ConsolPrintf("Unisoft PCB-Markup(TM) Test API");
ConsolPrintf("(C) Copyright 1995-2015 Unisoft Corp.\r\n");
ConsolPrintf("Type \"help\" or \"help [command]\".");
ConsolPrintf("To
exit type \"bye\" or ctrl+C.");
}
int GetLine(char *pInputBuffer)
{//_kbhit
pInputBuffer[1] = 5;
pInputBuffer[3] = 0x7F;
printf("\r\n");
printf(g_Prompt);
_cgets(pInputBuffer);
if(!pInputBuffer[1]){
if(pInputBuffer[3] == 0x7F){//Ctrl+C
return 0;
}
}
return 1;
}
int DoCmd(int cmdIndex, char *pParam, int
paramLen);
////////////////////////////////////////////
// Test API
engine
////////////////////////////////////////////
int ParseLine(char
*pInputBuffer)
{
char *pCmd = &pInputBuffer[2];
int len =
pInputBuffer[1];
if(len > 0){
int i = 0;
int cmdLen;
for(;i <
g_PCBMarkupCmdAmount; i++){
cmdLen = strlen(PCBMarkupCmdName[i]);
if(strnicmp(pCmd, PCBMarkupCmdName[i], cmdLen) == 0){
if(
(len ==
cmdLen)
|| (' ' == pCmd[cmdLen])
){
pCmd = pCmd + cmdLen;
len =
len - cmdLen;
return DoCmd(i, pCmd, len);
}
}
}
//Just to be
safe
if(len > 40){
len = 40;
}
pInputBuffer[len] = '\0';
ConsolPrintf("Unknown command (%s)",pCmd);
}
return 0;
}
int
main(int argc, char* argv[])
{
int j;
ConsolPrintf("Test API %d
params:", argc);
for(j = 0; j < argc; j++){
ConsolPrintf("-%s-",
argv[j]);
}
if(argc <= 1){
strcpy(g_Prompt, DEFAULT_PROMPT);
Usage();
g_InputBuffer[0] = (char)128;
while(GetLine(g_InputBuffer)){
if(ParseLine(g_InputBuffer)){
break;
}
}
ConsolPrintf("Test API is ready to die");
ConsolPrintf("Press any button");
while(!_kbhit()){
}
} else {
int Ok = 1;
int i = 1;
int inpStrLen = 0;
char *pLine =
&g_InputBuffer[2];
*pLine = '\0';
for(;i < argc; i++){
if(INPUT_BUFFER_LEN <= strlen(argv[i]) + inpStrLen + 1){
Ok = 0;
break;
} else {
strcat(pLine, argv[i]);
strcat(pLine, " ");
inpStrLen = strlen(pLine);
}
}
if(Ok){
g_InputBuffer[1] =
(char)inpStrLen;
if(g_InputBuffer[1] == inpStrLen){// Could be overflow
ParseLine(g_InputBuffer);
} else {
ConsolPrintf("Input line is too
big");
}
} else {
ConsolPrintf("Input line is too big");
}
}
return 0;
}
typedef struct Param
{
char *m_pParam;
int m_ParamLen;
} CParam;
void DoCmdShowCurView(CParam
*pParamAsWhat)
{
int paramAsWhat;
if(ConvertToInt(pParamAsWhat->m_pParam, pParamAsWhat->m_ParamLen,
¶mAsWhat)){
if( (paramAsWhat > 0) && (paramAsWhat <
CMD_SHOW_CUR_VIEW_NO_CMD)){
int retValue;
retValue =
ShowCurView(paramAsWhat);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("ShowCurView success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("ShowCurView, Transport busy");
break;
case
RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("ShowCurView, No Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("ShowCurView, Bad
parameter");
break;
default:
ConsolPrintf("ShowCurView, Unknown
return value: %d", retValue);
break;
};
} else {
ConsolPrintf("\"AS_WHAT\" parameter is out of range");
}
} else {
ConsolPrintf("Bad \"AS_WHAT\" parameter");
}
}
void
DoCmdShow(CParam *pParamWhat, CParam *pParamHow)
{
int cmdWhat;
if(ConvertToInt(pParamWhat->m_pParam, pParamWhat->m_ParamLen, &cmdWhat)){
if( (cmdWhat > 0) && (cmdWhat < CMD_SHOW_NO_CMD)){
int cmdHow;
if(ConvertToInt(pParamHow->m_pParam, pParamHow->m_ParamLen, &cmdHow)){
if( (cmdHow >= 0) && (cmdHow < CMD_SHOW_HOW_NO_CMD)){
int retValue;
retValue = Show(cmdWhat, cmdHow);
switch(retValue){
case
RAPI_ERROR_SUCCESS:
ConsolPrintf("Show success");
break;
case
RAPI_ERROR_BUSY:
ConsolPrintf("Show, Transport busy");
break;
case
RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("Show, No Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("Show, Bad parameter");
break;
default:
ConsolPrintf("Show, Unknown return value: %d", retValue);
break;
};
} else {
ConsolPrintf("\"HOW\" parameter is out of
range");
}
} else {
ConsolPrintf("Bad \"HOW\" parameter");
}
} else {
ConsolPrintf("\"WHAT\" parameter is out of range");
}
}
else {
ConsolPrintf("Bad \"WHAT\" parameter");
}
}
void
DoCmdZoom(CParam *pParamHow, CParam *pParamHowMany)
{
int cmdHow;
if(ConvertToInt(pParamHow->m_pParam, pParamHow->m_ParamLen, &cmdHow)){
if( (cmdHow > 0) && (cmdHow < CMD_SHOW_NO_CMD)){
int cmdHowMany;
if(ConvertToInt(pParamHowMany->m_pParam, pParamHowMany->m_ParamLen,
&cmdHowMany)){
if(
(cmdHowMany >= 10) && (cmdHowMany <= 10000)
||
(cmdHowMany == 0) && (CMD_ZOOM_CUR_VIEW_HOW_MANY != cmdHow)
){
int
retValue;
retValue = ZoomCurView(cmdHow, cmdHowMany);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("ZoomCurView
success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("ZoomCurView,
Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("ZoomCurView, No Transport");
break;
case
RAPI_ERROR_BAD_PARAM:
ConsolPrintf("ZoomCurView, Bad parameter");
break;
default:
ConsolPrintf("Show, Unknown return value: %d",
retValue);
break;
};
} else {
ConsolPrintf("\"HOW_MANY\"
parameter is out of range");
}
} else {
ConsolPrintf("Bad
\"HOW_MANY\" parameter");
}
} else {
ConsolPrintf("\"HOW\"
parameter is out of range");
}
} else {
ConsolPrintf("Bad \"HOW\"
parameter");
}
}
void DoCmdFlip(CParam *pParamHow)
{
int
cmdHow;
if(ConvertToInt(pParamHow->m_pParam, pParamHow->m_ParamLen,
&cmdHow)){
if( (cmdHow > 0) && (cmdHow < 3)){
int retValue;
retValue = Flip(cmdHow);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("Flip success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("Flip, Transport busy");
break;
case
RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("Flip, No Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("Flip, Bad parameter");
break;
default:
ConsolPrintf("Show, Unknown return value: %d", retValue);
break;
};
} else {
ConsolPrintf("\"HOW\" parameter is out of
range");
}
} else {
ConsolPrintf("Bad \"HOW\" parameter");
}
}
void DoCmdMoveCurView(CParam *pParamHShift, CParam *pParamVShift)
{
int cmdHShift;
if(ConvertToInt(pParamHShift->m_pParam,
pParamHShift->m_ParamLen, &cmdHShift)){
if( (cmdHShift > -1000) &&
(cmdHShift < 1000)){
int cmdVShift;
if(ConvertToInt(pParamVShift->m_pParam, pParamVShift->m_ParamLen,
&cmdVShift)){
if( (cmdVShift > -1000) && (cmdVShift < 1000)){
int
retValue;
retValue = MoveCurView(cmdHShift, cmdVShift);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("MoveCurView
success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("MoveCurView,
Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("MoveCurView, No Transport");
break;
case
RAPI_ERROR_BAD_PARAM:
ConsolPrintf("MoveCurView, Bad parameter");
break;
default:
ConsolPrintf("MoveCurView, Unknown return value: %d",
retValue);
break;
};
} else {
ConsolPrintf("\"V_SHIFT\"
parameter is out of range");
}
} else {
ConsolPrintf("Bad
\"V_SHIFT\" parameter");
}
} else {
ConsolPrintf("\"H_SHIFT\"
parameter is out of range");
}
} else {
ConsolPrintf("Bad
\"H_SHIFT\" parameter");
}
}
void DoCmdImportBom(CParam
*pParamFileName)
{
int retValue;
retValue =
ImportBom(pParamFileName->m_pParam);
switch(retValue){
case
RAPI_ERROR_SUCCESS:
ConsolPrintf("ImportBom success");
break;
case
RAPI_ERROR_BUSY:
ConsolPrintf("ImportBom, Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("ImportBom, No Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("ImportBom, Bad
parameter");
break;
default:
ConsolPrintf("ImportBom, Unknown
return value: %d", retValue);
break;
};
}
void
DoCmdImportAnnotation(CParam *pParamFileName)
{
int retValue;
retValue = ImportAnnotation(pParamFileName->m_pParam);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("ImportAnnotation success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("ImportAnnotation, Transport
busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("ImportAnnotation, No Transport");
break;
case
RAPI_ERROR_BAD_PARAM:
ConsolPrintf("ImportAnnotation, Bad parameter");
break;
default:
ConsolPrintf("ImportAnnotation, Unknown return value:
%d", retValue);
break;
};
}
void DoCmdFindComponents(CParam
*pParamZoomIn, CParam *pParamComp1, CParam *pParamComp2)
{
int
cmdZoomIn;
if(ConvertToInt(pParamZoomIn->m_pParam,
pParamZoomIn->m_ParamLen, &cmdZoomIn)){
if( (cmdZoomIn == 1) ||
(cmdZoomIn == 2)){
int retValue;
if(pParamComp2->m_ParamLen <= 0){
pParamComp2->m_pParam = "";
}
retValue = FindComponents(cmdZoomIn,
pParamComp1->m_pParam, pParamComp2->m_pParam);
switch(retValue){
case
RAPI_ERROR_SUCCESS:
ConsolPrintf("FindComponents success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("FindComponents, Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("FindComponents, No
Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("FindComponents, Bad parameter");
break;
default:
ConsolPrintf("FindComponents, Unknown return value: %d", retValue);
break;
};
} else {
ConsolPrintf("\"ZOOM_IN\" parameter is out of
range");
}
} else {
ConsolPrintf("Bad \"ZOOM_IN\" parameter");
}
}
void DoCmdFindNets(CParam *pParamNet1, CParam *pParamNet2)
{
int retValue;
retValue = FindNets(pParamNet1->m_pParam,
pParamNet2->m_pParam);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("FindNets success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("FindNets, Transport busy");
break;
case
RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("FindNets, No Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("FindNets, Bad
parameter");
break;
default:
ConsolPrintf("FindNets, Unknown return
value: %d", retValue);
break;
};
}
void
DoCmdSetCurViewSize(CParam *pParamPercent)
{
int retValue;
int
cmdSizePercent;
if(ConvertToInt(pParamPercent->m_pParam,
pParamPercent->m_ParamLen, &cmdSizePercent)){
if((cmdSizePercent >= 5) &&
(cmdSizePercent <= 95)){
retValue = SetCurViewSize(cmdSizePercent);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("SetCurViewSize success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("SetCurViewSize, Transport busy");
break;
case
RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("SetCurViewSize, No Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("SetCurViewSize, Bad
parameter");
break;
default:
ConsolPrintf("SetCurViewSize, Unknown
return value: %d", retValue);
break;
};
} else {
ConsolPrintf("Parameter \"PERCENT\" is out of range(5-95): %d",
cmdSizePercent);
}
} else {
ConsolPrintf("Bad \"PERCENT\"
parameter");
}
}
void DoCmdSetBoardDir(CParam *pParamPath)
{
int retValue;
retValue = SetBoardDir(pParamPath->m_pParam);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("DoCmdSetBoardDir success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("DoCmdSetBoardDir, Transport busy");
break;
case
RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("DoCmdSetBoardDir, No Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("DoCmdSetBoardDir, Bad
parameter");
break;
default:
ConsolPrintf("DoCmdSetBoardDir,
Unknown return value: %d", retValue);
break;
};
}
void
DoCmdFindPinVia(CParam *pParamZoomIn, CParam *pParamComp1)
{
int
cmdZoomIn;
if (ConvertToInt(pParamZoomIn->m_pParam,
pParamZoomIn->m_ParamLen, &cmdZoomIn))
{
if ((cmdZoomIn == 1) ||
(cmdZoomIn == 2))
{
int retValue;
retValue =
FindPinVia(cmdZoomIn, pParamComp1->m_pParam);
switch(retValue)
{
case RAPI_ERROR_SUCCESS:
ConsolPrintf("FindPinVia success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("FindPinVia, Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("FindPinVia, No
Transport");
break;
case RAPI_ERROR_BAD_PARAM:
ConsolPrintf("FindPinVia, Bad parameter");
break;
default:
ConsolPrintf("FindPinVia, Unknown return value: %d", retValue);
break;
};
}
else
{
ConsolPrintf("\"ZOOM_IN\" parameter is out of
range");
}
}
else
{
ConsolPrintf("Bad \"ZOOM_IN\"
parameter");
}
}
void DoCmdSetWindowSizeLocation(CParam
*pParamTop, CParam *pParamLeft,
CParam *pParamHeight, CParam
*pParamWidth)
{
int cmdTop;
int cmdLeft;
int cmdHeight;
int
cmdWidth;
if (ConvertToInt(pParamTop->m_pParam,
pParamTop->m_ParamLen, &cmdTop) &&
ConvertToInt(pParamLeft->m_pParam,
pParamLeft->m_ParamLen, &cmdLeft) &&
ConvertToInt(pParamHeight->m_pParam,
pParamHeight->m_ParamLen, &cmdHeight) &&
ConvertToInt(pParamWidth->m_pParam, pParamWidth->m_ParamLen, &cmdWidth))
{
int retValue;
retValue =
SetWindowSizeLocation(cmdTop,
cmdLeft, cmdHeight, cmdWidth);
switch(retValue)
{
case
RAPI_ERROR_SUCCESS:
ConsolPrintf("SetWindowSizeLocation success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("SetWindowSizeLocation,
Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("SetWindowSizeLocation, No Transport");
break;
case
RAPI_ERROR_BAD_PARAM:
ConsolPrintf("SetWindowSizeLocation, Bad
parameter");
break;
default:
ConsolPrintf("SetWindowSizeLocation,
Unknown return value: %d", retValue);
break;
};
}
else
{
ConsolPrintf("Bad non-integerj parameter");
}
}
int DoCmd(int
cmdIndex, char *pParam, int paramLen)
{
CParam paramHandle;
paramHandle.m_ParamLen = paramLen;
paramHandle.m_pParam = pParam;
paramHandle.m_pParam = GetToken(paramHandle.m_pParam,
¶mHandle.m_ParamLen);
if(!paramHandle.m_pParam){
paramHandle.m_ParamLen = 0;
}
if(paramHandle.m_ParamLen > 0){
paramHandle.m_pParam[paramHandle.m_ParamLen] = '\0';
paramLen = paramLen
- (paramHandle.m_pParam - pParam) - paramHandle.m_ParamLen;
}
switch(cmdIndex)
{
case 0://Help
if(paramHandle.m_ParamLen <= 0){
int i = 0;
for(; i < g_PCBMarkupCmdAmount; i++){
ConsolPrintf(PCBMarkupCmdName[i]);
}
} else {
int i = 0;
int
cmdLen;
for(; i < g_PCBMarkupCmdAmount; i++){
cmdLen =
strlen(PCBMarkupCmdName[i]);
if(strnicmp(paramHandle.m_pParam,
PCBMarkupCmdName[i], cmdLen) == 0){
if(cmdLen == paramHandle.m_ParamLen){
PCBMarkupCmdHelp[i]();
break;
}
}
}
if(i ==
g_PCBMarkupCmdAmount){
ConsolPrintf("Unknown command %s",
paramHandle.m_pParam);
}
}
break;
case 1://bye
return
1;//exit
case 2://OpenBoard
if(paramHandle.m_ParamLen > 0){
CParam
paramHandle1;
int retValue;
paramLen--;
if(paramLen>0){
paramHandle1.m_pParam = paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_ParamLen = paramLen;
paramHandle1.m_pParam =
GetToken(paramHandle1.m_pParam, ¶mHandle1.m_ParamLen);
if(paramHandle1.m_ParamLen > 0){
paramHandle1.m_pParam[paramHandle1.m_ParamLen] = '\0';
}
} else {
paramHandle1.m_pParam = NULL;
}
retValue =
OpenBoard(paramHandle.m_pParam, paramHandle1.m_pParam);
switch(retValue){
case RAPI_ERROR_SUCCESS:
ConsolPrintf("OpenBoard success");
break;
case RAPI_ERROR_BUSY:
ConsolPrintf("OpenBoard, Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("OpenBoard, No
Transport");
break;
default:
ConsolPrintf("OpenBoard, Unknown
return value: %d", retValue);
break;
};
} else {
ConsolPrintf("No \"FILENAME\" parameter");
}
break;
case 3: //
SetCurView
if(paramHandle.m_ParamLen > 0){
if(
(0 !=
stricmp(paramHandle.m_pParam, "R"))
&& (0 !=
stricmp(paramHandle.m_pParam, "r"))
&& (0 !=
stricmp(paramHandle.m_pParam, "L"))
&& (0 !=
stricmp(paramHandle.m_pParam, "l"))
){
ConsolPrintf("Wrong \"VIEW\"
parameter - %s", paramHandle.m_pParam);
} else {
int retValue =
SetCurView(paramHandle.m_pParam);
switch(retValue){
case
RAPI_ERROR_SUCCESS:
ConsolPrintf("SetCurView success");
break;
case
RAPI_ERROR_BUSY:
ConsolPrintf("SetCurView, Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("SetCurView, No Transport");
break;
default:
ConsolPrintf("SetCurView, Unknown return value: %d",
retValue);
break;
};
}
} else {
ConsolPrintf("No \"VIEW\"
parameter");
}
break;
case 4: //Show
if(paramHandle.m_ParamLen >
0){
paramLen--;
if(paramLen > 0){
CParam paramHandle1;
paramHandle1.m_pParam = paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_ParamLen = paramLen;
paramHandle1.m_pParam =
GetToken(paramHandle1.m_pParam, ¶mHandle1.m_ParamLen);
if(paramHandle1.m_ParamLen > 0){
paramHandle1.m_pParam[paramHandle1.m_ParamLen] = '\0';
DoCmdShow(¶mHandle, ¶mHandle1);
} else {
ConsolPrintf("No
\"HOW\" parameter");
}
} else {
ConsolPrintf("No \"HOW\"
parameter");
}
} else {
ConsolPrintf("No \"WHAT\" parameter");
}
break;
case 5: //ShowCurView
if(paramHandle.m_ParamLen > 0){
DoCmdShowCurView(¶mHandle);
} else {
ConsolPrintf("No \"AS_WHAT\"
parameter");
}
break;
case 6: //ZoomCurView
if(paramHandle.m_ParamLen > 0){
CParam paramHandle1;
paramLen--;
if(paramLen > 0){
paramHandle1.m_ParamLen = paramLen;
paramHandle1.m_pParam = paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_pParam = GetToken(paramHandle1.m_pParam,
¶mHandle1.m_ParamLen);
if(paramHandle1.m_ParamLen > 0){
paramHandle1.m_pParam[paramHandle1.m_ParamLen] = '\0';
} else {
paramHandle1.m_pParam = paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_pParam[0] = '0';
paramHandle1.m_pParam[1] = '\0';
paramHandle1.m_ParamLen = 1;
}
} else {
paramHandle1.m_pParam =
paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_pParam[0] = '0';
paramHandle1.m_pParam[1] = '\0';
paramHandle1.m_ParamLen = 1;
}
DoCmdZoom(¶mHandle, ¶mHandle1);
} else {
ConsolPrintf("No \"How\" parameter");
}
break;
case 7:
//Rotate
{
int retValue = Rotate();
switch(retValue){
case
RAPI_ERROR_SUCCESS:
ConsolPrintf("SetCurView success");
break;
case
RAPI_ERROR_BUSY:
ConsolPrintf("SetCurView, Transport busy");
break;
case RAPI_ERROR_NO_TRANSPORT:
ConsolPrintf("SetCurView, No Transport");
break;
default:
ConsolPrintf("SetCurView, Unknown return value: %d",
retValue);
break;
};
}
break;
case 8: //Flip
if(paramHandle.m_ParamLen > 0){
DoCmdFlip(¶mHandle);
} else {
ConsolPrintf("No \"How\" parameter");
}
break;
case 9:
//MoveCurView
if(paramHandle.m_ParamLen > 0){
CParam paramHandle1;
paramLen--;
paramHandle1.m_ParamLen = paramLen;
paramHandle1.m_pParam
= paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_pParam = GetToken(paramHandle1.m_pParam,
¶mHandle1.m_ParamLen);
if(paramHandle1.m_ParamLen > 0){
DoCmdMoveCurView(¶mHandle, ¶mHandle1);
} else {
ConsolPrintf("No \"V_SHIFT\" parameter");
}
} else {
ConsolPrintf("No \"H_SHIFT\" parameter");
}
break;
case 10:
//ClearBom
ClearBom();
break;
case 11: //ClearAnnotation
ClearAnnotation();
break;
case 12: //ImportBom
if(paramHandle.m_ParamLen > 0){
DoCmdImportBom(¶mHandle);
} else {
ConsolPrintf("No \"FILE_NAME\" parameter");
}
break;
case 13:
//ImportAnnotation
if(paramHandle.m_ParamLen > 0){
DoCmdImportAnnotation(¶mHandle);
} else {
ConsolPrintf("No
\"FILE_NAME\" parameter");
}
break;
case 14: //FindComponents
if(paramHandle.m_ParamLen > 0){
CParam paramHandle1;
paramLen--;
paramHandle1.m_ParamLen = paramLen;
paramHandle1.m_pParam =
paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_pParam
= GetToken(paramHandle1.m_pParam, ¶mHandle1.m_ParamLen);
if(paramHandle1.m_ParamLen > 0){
CParam paramHandle2;
paramHandle1.m_pParam[paramHandle1.m_ParamLen] = '\0';
paramLen =
paramLen
- (paramHandle1.m_pParam - (paramHandle.m_pParam +
paramHandle.m_ParamLen + 1))
- paramHandle1.m_ParamLen;
if(paramLen >
0){
paramHandle2.m_ParamLen = paramLen;
paramHandle2.m_pParam =
paramHandle1.m_pParam + paramHandle1.m_ParamLen + 1;
paramHandle2.m_pParam = GetToken(paramHandle2.m_pParam,
¶mHandle2.m_ParamLen);
} else {
paramHandle2.m_pParam = "";
}
DoCmdFindComponents(¶mHandle, ¶mHandle1, ¶mHandle2);
} else {
ConsolPrintf("No \"COMP1\" parameter");
}
} else {
ConsolPrintf("No
\"ZOOM_IN\" parameter");
}
break;
case 15: //FindNets
if(paramHandle.m_ParamLen > 0){
CParam paramHandle1;
paramLen--;
paramHandle1.m_ParamLen = paramLen;
paramHandle1.m_pParam =
paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_pParam
= GetToken(paramHandle1.m_pParam, ¶mHandle1.m_ParamLen);
DoCmdFindNets(¶mHandle, ¶mHandle1);
} else {
ConsolPrintf("No
\"NET1\" parameter");
}
break;
case 16: //SetCurViewSize
if(paramHandle.m_ParamLen > 0){
DoCmdSetCurViewSize(¶mHandle);
}
else {
ConsolPrintf("No \"PERCENT\" parameter");
}
break;
case
17: //SetBoardDir
if(paramHandle.m_ParamLen > 0){
DoCmdSetBoardDir(¶mHandle);
} else {
ConsolPrintf("No
\"DIRECTORY\" parameter");
}
break;
case 18: //FindPinVia
if(paramHandle.m_ParamLen > 0)
{
CParam paramHandle1;
paramLen--;
paramHandle1.m_ParamLen = paramLen;
paramHandle1.m_pParam =
paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_pParam
= GetToken(paramHandle1.m_pParam, ¶mHandle1.m_ParamLen);
if(paramHandle1.m_ParamLen > 0)
{
CParam paramHandle2;
paramHandle1.m_pParam[paramHandle1.m_ParamLen] = '\0';
paramLen =
paramLen
- (paramHandle1.m_pParam - (paramHandle.m_pParam +
paramHandle.m_ParamLen + 1))
- paramHandle1.m_ParamLen;
if(paramLen >
0)
{
paramHandle2.m_ParamLen = paramLen;
paramHandle2.m_pParam =
paramHandle1.m_pParam + paramHandle1.m_ParamLen + 1;
paramHandle2.m_pParam = GetToken(paramHandle2.m_pParam,
¶mHandle2.m_ParamLen);
}
else
{
paramHandle2.m_pParam = "";
}
DoCmdFindPinVia(¶mHandle, ¶mHandle1);
}
else
{
ConsolPrintf("No \"PINVIA\" parameter");
}
}
else
{
ConsolPrintf("No \"ZOOM_IN\" parameter");
}
break;
case 19:
//SetWindowSizeLocation
if(paramHandle.m_ParamLen > 0)
{
CParam
paramHandle1;
paramLen--;
paramHandle1.m_ParamLen = paramLen;
paramHandle1.m_pParam = paramHandle.m_pParam + paramHandle.m_ParamLen + 1;
paramHandle1.m_pParam = GetToken(paramHandle1.m_pParam,
¶mHandle1.m_ParamLen);
if(paramHandle1.m_ParamLen > 0)
{
CParam
paramHandle2;
paramHandle1.m_pParam[paramHandle1.m_ParamLen] = '\0';
paramLen = paramLen
- (paramHandle1.m_pParam - (paramHandle.m_pParam +
paramHandle.m_ParamLen + 1))
- paramHandle1.m_ParamLen;
if(paramLen >
0)
{
paramHandle2.m_ParamLen = paramLen;
paramHandle2.m_pParam =
paramHandle1.m_pParam + paramHandle1.m_ParamLen + 1;
paramHandle2.m_pParam = GetToken(paramHandle2.m_pParam,
¶mHandle2.m_ParamLen);
if (paramHandle2.m_ParamLen > 0)
{
CParam paramHandle3;
paramHandle2.m_pParam[paramHandle2.m_ParamLen] =
'\0';
paramLen = paramLen
- (paramHandle1.m_pParam -
(paramHandle.m_pParam + paramHandle.m_ParamLen + 1))
-
paramHandle1.m_ParamLen
- (paramHandle2.m_pParam - (paramHandle1.m_pParam
+ paramHandle1.m_ParamLen + 1))
- paramHandle2.m_ParamLen;
if
(paramLen > 0)
{
paramHandle3.m_ParamLen = paramLen + 1;
paramHandle3.m_pParam = paramHandle2.m_pParam + paramHandle2.m_ParamLen + 1;
paramHandle3.m_pParam = GetToken(paramHandle3.m_pParam,
¶mHandle3.m_ParamLen);
DoCmdSetWindowSizeLocation(¶mHandle,
¶mHandle1, ¶mHandle2, ¶mHandle3);
}
else
{
ConsolPrintf("No \"WIDTH\" parameter");
}
}
}
else
{
ConsolPrintf("No \"HEIGHT\" parameter");
}
}
else
{
ConsolPrintf("No \"LEFT\" parameter");
}
}
else
{
ConsolPrintf("No \"TOP\" parameter");
}
break;
default:
ConsolPrintf("Unknown cmd Index - %d", cmdIndex);
}
return 0;
}
RAPI_Test.dsp code located at:
\unisoft\RemoteApi\RAPI_Test
# Microsoft
Developer Studio Project File - Name="RAPI_Test" - Package Owner=<4>
#
Microsoft Developer Studio Generated Build File, Format Version 6.00
# **
DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=RAPI_Test - Win32 Debug
!MESSAGE This is not a valid makefile. To
build this project using NMAKE,
!MESSAGE use the Export Makefile command
and run
!MESSAGE
!MESSAGE NMAKE /f "RAPI_Test.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by
defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "RAPI_Test.mak" CFG="RAPI_Test - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "RAPI_Test - Win32 Release" (based on "Win32 (x86) Console
Application")
!MESSAGE "RAPI_Test - Win32 Debug" (based on "Win32 (x86)
Console Application")
!MESSAGE
# Begin Project
# PROP
AllowPerConfigDependencies 0
# PROP Scc_ProjName
""$/Markup/MkVrVer/RemoteApi/RAPI_Test", MICAAAAA"
# PROP Scc_LocalPath
"."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "RAPI_Test - Win32
Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries
0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
#
PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D
"NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo
/W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
#
SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC
/l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
#
ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib
user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib
user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo
/subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console
/machine:I386
!ELSEIF "$(CFG)" == "RAPI_Test - Win32 Debug"
#
PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE
Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE
Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP
Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP
Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3
/Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS"
/Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32"
/D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
/Yc /Yu
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d
"_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32
/nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console
/debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console
/debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Cmds=copy ..\Api\Debug\Api.dll
Debug\Api.dll
# End Special Build Tool
!ENDIF
# Begin
Target
# Name "RAPI_Test - Win32 Release"
# Name "RAPI_Test -
Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter
"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\RAPI_Test.c
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
#
Begin Source File
SOURCE=.\utils.c
# End Source File
# End
Group
# Begin Group "Header Files"
# PROP Default_Filter
"h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\StdAfx.h
# End
Source File
# Begin Source File
SOURCE=.\utils.h
# End Source
File
# End Group
# Begin Group "Resource Files"
# PROP
Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End
Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project
utils.c code located at:
\unisoft\RemoteApi\RAPI_Test
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "utils.h"
char
* GetToken(char *pLine, int *pLen)
{
if(*pLen > 0){
char Delimiter
= ' ';
char *pTokenEnd;
char *l_Line = pLine;
int l_len = *pLen;
l_Line = TrimLeadWS(l_Line, &l_len);
if(!(*l_Line)){
*pLen = 0;
return NULL;
}
if(('\'' == *l_Line)||('"' == *l_Line)){
Delimiter = *l_Line;
l_len--;
l_Line++;
}
pTokenEnd = l_Line;
while(l_len && (*pTokenEnd) &&(Delimiter != *pTokenEnd)){
l_len--;
pTokenEnd++;
}
*pLen = pTokenEnd - l_Line;
return l_Line;
} else
{
*pLen = 0;
return NULL;
}
};
char * TrimLeadWS(char
*pLine, int *pLen)
{
char *pNewLine = pLine;
while(*pLen > 0){
if(
(' ' == (*pNewLine))
|| ('\0' == (*pNewLine))
){
pNewLine++;
(*pLen)--;
} else {
break;
}
}
return pNewLine;
}
char * TrimTrailWS(char *pLine, int *pLen)
{
char *pNewLine = pLine +
*pLen;
pNewLine--;
while(pNewLine >= pLine){
if(' ' ==
(*pNewLine)){
*pNewLine = '\0';
pNewLine--;
(*pLen)--;
} else {
break;
}
}
return pLine;
}
int ConvertToInt(char
*pIntStr, int len, int *pInt)
{
int retValue = 0;
int l_Int = 0;
pIntStr = TrimLeadWS(pIntStr, &len);
TrimTrailWS(pIntStr, &len);
if(len > 0){
int sign = 1;
retValue = 1;
if('-' == *pIntStr){
len--;
pIntStr++;
sign = -1;
}
while((len > 0) &&(*pIntStr)){
if(isdigit(*pIntStr)){
l_Int = l_Int * 10 + (*pIntStr - '0');
len--;
pIntStr++;
} else {
retValue = 0;
break;
}
}
l_Int = l_Int
* sign;
}
if(retValue){
*pInt = l_Int;
}
return retValue;
}
char g_UtilBuf[128];
int ConvertStrIP_ToUL(char *pIpStr, int
len, unsigned long *pIp)
{
strncpy(g_UtilBuf, pIpStr, len);
g_UtilBuf[len] = '\0';
pIpStr = TrimLeadWS(g_UtilBuf, &len);
if(len >
0){
unsigned long lIp = 0;
int part = 0;
int dotCount = 0;
char
*pDot = strstr(pIpStr, ".");
while((dotCount < 3) && pDot){
*pDot =
'\0';
dotCount++;
len = strlen(pIpStr);
pIpStr =
TrimLeadWS(pIpStr, &len);
pIpStr = TrimTrailWS(pIpStr, &len);
if(ConvertToInt(pIpStr, len, &part)){
if((part >= 0) && (part < 255)){
lIp = (lIp << 8) | (part & 0x000000FF);
} else {
dotCount = 0;
break;
}
} else {
dotCount = 0;
break;
}
pIpStr =
pDot+1;
pDot = strstr(pIpStr, ".");
}
if(dotCount == 3){
len =
strlen(pIpStr);
pIpStr = TrimLeadWS(pIpStr, &len);
pIpStr =
TrimTrailWS(pIpStr, &len);
if(ConvertToInt(pIpStr, len, &part)){
if((part > 0) && (part < 255)){
lIp = (lIp << 8) | (part & 0x000000FF);
*pIp = lIp;
return 1;
}
}
}
}
return 0;
}
utils.h code located at:
\unisoft\RemoteApi\RAPI_Test
#ifndef
_REMOTE_API_UTILS_H_
#define _REMOTE_API_UTILS_H_
char *
GetToken(char *pLine, int *pLen);
char * TrimLeadWS(char *pLine, int
*pLen);
char * TrimTrailWS(char *pLine, int *pLen);
int
ConvertToInt(char *pIntStr, int len, int *pInt);
int
ConvertStrIP_ToUL(char *pIpStr, int len, unsigned long *pIp);
#endif
Please contact Unisoft with any questions.