OpticalConfiguration

_AddOptConf, _AddOptConfForFluo, _ApplyObjectivesXYOffset, _BackupOptConf, _DeviceManagerv2, _ExploreOptConf, _JoystickManager, _ListOfPoints, _ManageDevices, _OptConfSelStimulDevice, _ProbesAndFilters, _RestoreOptConf, _ShutterSelStimulDevice, _WritePort, AddOptConf, BackupOptConf, BlockPort, ClearPort, ClosePort, CopyUserData, DeleteLightPathLastUsed, DeleteOptConf, DeleteOptConfs, DeleteUserData, EnablePortCursors, EnableSelectOCFromFilter, GetCurrentLightPathName, GetLightPathCount, GetLightPathIndexName, GetOptConfCount, GetOptConfName, GetSelectedOptConf, Mosaic_SetPattern, OpenPort, ReadPort, ReadPortEx, RestoreOptConf, RestoreOptConfEx, SelectLightPath, SelectOptConf, SelectSetupAndHWConfiguration, SelectSetupAndHWConfigurationNoDialog, SetOpticalConfChanged, SetSaveCameraSetting, SetSaveExposure, SetSaveExposureSetting, ShowDeviceControlDocker, ShowDeviceManagerPad, Stg_ConnectDevice, Stg_DisconnectDevice, Stg_IsStatusStored, Stg_StatusGet, Stg_StatusSet, Stg_StatusStoreAs, SwitchObjectiveAlert, UnblockPort, UnselectOptConf, WaitDeviceTimeOut, WritePort, WritePortAndWait, WritePortEx

AddOptConf

Interactive command to this function: Calibration > New Optical Configuration

Description 

 AddOptConf(
   char *CurrOptConf,
   char *Objective,
   int  NosepieceSetting,
   int  CameraSetting,
   int  MicroscopeSetting,
   int  ShutterType,
   int  ShutterType2
);

This function creates and adds optical configuration to the system. An interactive equivalent of this function is the _AddOptConf function.

Parameters

char *CurrOptConf

Name of the optical configuration to be added to NIS-Elements system optical configurations.

char *Objective

Name of the objective.

int NosepieceSetting

Use current nosepiece position.

TRUE

Use current objective and nosepiece position

FALSE

Do not use nosepiece position

int CameraSetting

Use current camera setting.

TRUE

Use current camera setting

FALSE

Do not use camera setting

int MicroscopeSetting

Use current microscope setting.

TRUE

Use current microscope setting

FALSE

Do not use microscope setting

int ShutterType

Type of active shutter.

-1

Do not use active shutter

0

EPI

1

DIA

2

Camera

3

Unknown

int ShutterType2

Type of second shutter.

See Also 
_AddOptConf, DeleteOptConf

BackupOptConf

Description 

 BackupOptConf(
   char *Filename
);

This function saves settings of the current optical configurations to an XML file.

Parameters

char *Filename

Full path to the XML file. E.g. C:\backup\backup1.xml

See Also 
RestoreOptConf

DeleteOptConf

Description 

 DeleteOptConf(
    CurrOptConf
);

This function deletes the specified optical configuration.

Parameters

CurrOptConf

Name of optical configuration that will be deleted.

Note

Objective of the same name will not be deleted.

See Also 
AddOptConf, DeleteObjective

DeleteOptConfs

Description 

 DeleteOptConfs();

This function deletes all optical configurations.

EnableSelectOCFromFilter

Description 

 EnableSelectOCFromFilter(
   int  Enabled
);

Changes status of the Select corresponding optical configuration when filter changed options within the Edit > Options window.

Parameters

int Enabled

0

Disabled.

1

Enabled.

GetOptConfCount

Description 

int GetOptConfCount();

This function returns a number of defined optical configurations.

Return Values

int

A number of defined optical configurations.

GetOptConfName

Description 

 GetOptConfName(
   int  Index,
   char *CurrOptConf,
   int  ObjectiveNameMaxLength
);

This function returns the pointer to the name of an optical configuration determined by the Index parameter (position of the configuration in the configurations list). It represents one line of a virtual ordered list of the defined optical configurations.

Parameters

int Index

Index number (zero-based).

char *CurrOptConf

The name of the optical configuration according to the Index parameter.

int ObjectiveNameMaxLength

Maximal optical configuration name length. If the name has more characters than defined, it is shortened automatically.

GetSelectedOptConf

Description 

 GetSelectedOptConf(
   char *OptConfObj,
   char *OptConfCam,
   char *OptConfMic,
   int  ObjectiveNameMaxLength
);

This function returns names of active optical configurations that have an objective, camera, or a microscope settings assigned to them.

Parameters

char *OptConfObj

Returns the name of the active optical configuration which has an objective is assigned to.

char *OptConfCam

Returns the name of the active optical configuration which has a camera settings assigned to.

char *OptConfMic

Returns the name of the active optical configuration which has microscope settings assigned to.

int ObjectiveNameMaxLength

Maximal optical configuration name length. If the name has more characters than defined, it is shortened automatically.

RestoreOptConf

Description 

 RestoreOptConf(
   char *Filename
);

This function loads optical configuration settings from an .xml file.

Parameters

char *Filename

Full path to the XML file. E.g. C:\backup\backup1.xml

See Also 
BackupOptConf

RestoreOptConfEx

Description 

 RestoreOptConfEx(
   char *Filename,
   int  Options
);

This function loads optical configuration settings from an .xml file.

Parameters

char *Filename

Full path to the XML file. E.g. C:\backup\backup1.xml

int Options

This parameter specifies how to deal with items which already exist in the software.

0

Opens a dialog window and asks the user what to do.

1

Imports all items from the file. If an item already exists in the software it will be overwritten.

2

Imports only items which do not already exist in the application.

3

Imports all items from the file. If an item already exists in the software, an index number will be appended to its name.

4

Deletes all items in the software and imports all items from the file.

See Also 
BackupOptConf

SelectOptConf

Description 

 SelectOptConf(
   char  OptConf
);

This function selects the specified optical configuration and makes it active.

Parameters

char OptConf

Name of the optical configuration.

See Also 
_ExploreOptConf, _ExploreObjectives

SetOpticalConfChanged

Description 

 SetOpticalConfChanged(
   int  OpticalConf
);

This function corresponds to the Edit > General Options > Appearance > When optical configuration settings changed combo box. Sets the behaviour after changing the settings of the Optical Configuration.

Parameters

int OpticalConf

Action after changing the settings

0

Highlight Optical Configuration button

1

Deselect Optical Configuration

2

Save all changes

See Also 
_GeneralOptions

SetSaveCameraSetting

Description 

 SetSaveCameraSetting(
   int  SaveSetting
);

This function corresponds to the Edit > General Options > General > Save all camera settings to optical configuration automatically check box. Sets a behaviour after changing camera settings.

Parameters

int SaveSetting

Save all camera settings to optical configuration automatically

See Also 
_GeneralOptions

SetSaveExposure

Description 

 SetSaveExposure(
   int  SaveExposure
);

Sets status of the Save brightness to optical configuration automatically option. See Edit > Options .

Parameters

int SaveExposure

0

Enabled

1

Disabled

See Also 
_GeneralOptions

SetSaveExposureSetting

Description 

 SetSaveExposureSetting(
   int  SaveExposure
);

Sets status of the Save brightness to optical configuration automatically option. See Edit > Options .

Parameters

int SaveExposure

0

Enabled

1

Disabled

UnselectOptConf

Description 

 UnselectOptConf(
   char  CurrOptConf
);

This function deactivates an active optical configuration.

Parameters

char CurrOptConf

The name of an active optical configuration to be unselected (deactivated).

Note

This function is called when you right click an active optical configuration button and select the Unselect command from the context menu.

_AddOptConf

This function runs the Calibration > New Optical Configuration command.

Description 

 _AddOptConf();

This function opens the New Optical Configuration dialog window.

See Also 
_ExploreOptConf

_AddOptConfForFluo

This function runs the Calibration > New Optical Configuration for Fluorescent Probe command.

Description 

 _AddOptConfForFluo();

It displays a dialog window for creating optical configurations including excitation and emission filter characteristics.

See Also 
_AddOptConf, AddOptConf

_BackupOptConf

Description 

 _BackupOptConf();

This function displays the Export Optical Configurations dialog window. The current set of optical configurations can be saved via this window.

_ExploreOptConf

This function runs the Calibration > Optical Configurations command.

Description 

 _ExploreOptConf();

The function displays the Optical Configurations dialog window.

_OptConfSelStimulDevice

Description 

 _OptConfSelStimulDevice();

This function opens a dialog window which selects an optical configuration used by the stimulation device.

_ProbesAndFilters

This function runs the Devices > Matching Fluorescent Probes and Filters command.

Description 

 _ProbesAndFilters();

_RestoreOptConf

Description 

 _RestoreOptConf();

This function displays the Import Optical Configurations dialog window. Optical configurations previously saved can be loaded via this window.

_ShutterSelStimulDevice

Description 

 _ShutterSelStimulDevice();

Opens the Use Shutter as Stimulation Device window enabling to select which shutters are used as stimulation devices.

Stg_ConnectDevice

Description 

 Stg_ConnectDevice(
   char *PhysicalDeviceName
);

Connects a physical device specified by its full name. The device must exist in the device manager device list and must be currently disconnected.

Parameters

char *PhysicalDeviceName

Full name of physical device to be dis/connected.

Stg_DisconnectDevice

Description 

 Stg_DisconnectDevice(
   char *PhysicalDeviceName
);

Disconnects the physical device specified by its full name. The device must exist in the device manager device list and must be currently connected.

Parameters

char *PhysicalDeviceName

Full name of physical device to be dis/connected.

Stg_IsStatusStored

Description 

 Stg_IsStatusStored(
   char *PhysicalDeviceKey,
   char *LogicalDeviceType,
   char *LogicalDeviceKey,
   char *StatusName
);

Finds out whether the specified status is stored or not.

Parameters

char *PhysicalDeviceKey

Name of the physical device as shown in the Device Manager.

char *LogicalDeviceType

String determining the type of the logical device.

char *LogicalDeviceKey

Name of the logical device as shown in the Device Manager.

char *StatusName

String used for naming, ascertaining, setting the device status.

For an example use case, please see: Stg_StatusStoreAs.

Stg_StatusGet

Description 

 Stg_StatusGet(
   char *PhysicalDeviceKey,
   char *LogicalDeviceType,
   char *LogicalDeviceKey,
   char  Buffer
);

This function can be used to find out which device status was set the last. The status is changed after you call the Stg_StatusSet function. Stg_StatusGet will return "".

Parameters

char *PhysicalDeviceKey

Name of the physical device as shown in the Device Manager.

char *LogicalDeviceType

String determining the type of the logical device.

char *LogicalDeviceKey

Name of the logical device as shown in the Device Manager.

char Buffer

Allocated space for the status name.

For an example use case, please see: Stg_StatusStoreAs.

Stg_StatusSet

Description 

 Stg_StatusSet(
   char *PhysicalDeviceKey,
   char *LogicalDeviceType,
   char *LogicalDeviceKey,
   char *StatusName,
   int  StatusUseCache
);

Loads the status and sets it to the device.

Parameters

char *PhysicalDeviceKey

Name of the physical device as shown in the Device Manager.

char *LogicalDeviceType

String determining the type of the logical device.

char *LogicalDeviceKey

Name of the logical device as shown in the Device Manager.

char *StatusName

String used for naming, ascertaining, setting the device status.

int StatusUseCache

0

The device is set using all settings.

1

The device is set using only changed setting values.

For an example use case, please see: Stg_StatusStoreAs.

Stg_StatusStoreAs

Description 

 Stg_StatusStoreAs(
   char *PhysicalDeviceKey,
   char *LogicalDeviceType,
   char *LogicalDeviceKey,
   char *StatusName
);

Stores the device status into C:\ProgramData\Laboratory Imaging\Platform\DeviceStatusStorage.bin.

Parameters

char *PhysicalDeviceKey

Name of the physical device as shown in the Device Manager.

char *LogicalDeviceType

String determining the type of the logical device.

char *LogicalDeviceKey

Name of the logical device as shown in the Device Manager.

char *StatusName

String used for naming, ascertaining, setting the device status.

Example use case showing dynamic changing of the XY stage settings:

char buffer[1000];
int buffer_size;
// Nikon / Prior stage versions:
char *physDevKey = "Nikon Ti"; //"ProScan III";
char *logDevType = "XY";       //"XY";
char *logDevKey = "XYDrive";   //"XY Drive";
// You can store status for the given (physDevKey, logDevType, logDevKey) using Stg_StatusStoreAs(physDevKey, logDevType, logDevKey,"SLOW");
if(1 == Stg_IsStatusStored(physDevKey, logDevType, logDevKey,"SLOW"))
{
   // 1 means cache will be used if available -> only differences are set and the function executes faster:
   Stg_StatusSet(physDevKey, logDevType, logDevKey,"SLOW",1); 
   StgMoveXY(1000.00000,1000.00000,1);
}
if(1 == Stg_IsStatusStored(physDevKey, logDevType, logDevKey,"FAST"))
{
   // You can find out which device status was set last by using:
   Stg_StatusGet(physDevKey, logDevType, logDevKey, buffer);
   // Please note that if the status is changed after you call Stg_StatusSet, StgStatusGet will return ""
   Int_CreateWindow(1, "Current status", WP_TOPLEFT, 0, 0, 800, 400, buffer, 1, 1, 0, 1, 1, 1, "Courier,,10");
   if(strcpy(buffer,"FAST")) // not equal
   {
      Stg_StatusSet(physDevKey, logDevType, logDevKey,"FAST",1); // use cache again
   }
   StgMoveXY(-1000.00000,-1000.00000,1);
}    
SwitchObjectiveAlert

Description 

 SwitchObjectiveAlert();

If turned on (default state), a message box with a warning text is displayed when switching between oil and water/air objectives.

_ApplyObjectivesXYOffset

This function runs the Devices > Apply Objectives XY Offset command.

Description 

 _ApplyObjectivesXYOffset();

Applies XY offsets between objectives based on the values set in the Objective XY Offset dialog window.

_DeviceManagerv2

This function runs the Devices > Device Manager command.

Description 

 _DeviceManagerv2(
   int  OverviewMode
);

Opens the Device Manager dialog window.

Parameters

int OverviewMode

Turns on/off the system overview.

0

Overview mode OFF.

1

Overview mode ON.

_JoystickManager

Description 

 _JoystickManager();

Opens the Device Manager dialog window displaying all connected joysticks and foot pedals together with their plugins shown in the combo box. Move the joystick/pedal to highlight it in the list.

This function is supported by the Filter Particle Analysis application.

_ListOfPoints

This function runs the Devices > List of Points command.

Description 

 _ListOfPoints();

This function displays the list of points for Multipoint Acquisition.

_ManageDevices

Description 

TRUE _ManageDevices();

Displays a dialog box allowing the user to manage the installed devices.

Return Values

TRUE (1)

Dialog was shown

FALSE (0)

Dialog could not be created

See Also 
Stg_IsLightPresent, Stg_IsFilterPresent, Stg_IsShutterPresent, Stg_IsNosepiecePresent

Mosaic_SetPattern

Description 

 Mosaic_SetPattern(
   char  Mosaic_pwsPath
);

Sets the illumination pattern for Andor Mosaic.

Parameters

char Mosaic_pwsPath

Path to the pattern file.

CopyUserData

Description 

 CopyUserData(
   char *UserName,
   char *UserNameDestination
);

Copies the user settings such as OCs, other user settings and visibility of modality buttons.

Parameters

char *UserName

User name.

char *UserNameDestination

User name to which the settings are copied.

DeleteLightPathLastUsed

Description 

 DeleteLightPathLastUsed(
   char *Name
);

Deletes the last used light path.

Parameters

char *Name

Name of the light path.

DeleteUserData

Description 

 DeleteUserData(
   char *UserName
);

Deletes all device manager data for the specified user.

Parameters

char *UserName

User name.

GetLightPathCount

Description 

 GetLightPathCount();

Retrieves the number of light paths used.

GetLightPathIndexName

Description 

 GetLightPathIndexName(
   int  Index,
   char *Name,
   int  MaxTextLength
);

Retrieves the name of the light path specified by the index.

Parameters

int Index

Index number (zero-based).

char *Name

Name of the light path.

int MaxTextLength

Maximum text length for the light path name.

GetCurrentLightPathName

Description 

 GetCurrentLightPathName(
   char *Name,
   int  MaxTextLength
);

Retrieves the name of the currently selected light path.

Parameters

char *Name

Name of the light path.

int MaxTextLength

Maximum text length for the light path name.

SelectLightPath

Description 

 SelectLightPath(
   char *Name
);

Selects the light path specified by its name.

Parameters

char *Name

Name of the light path.

SelectSetupAndHWConfiguration

This function runs the Devices > Select HW Configuration command.

Description 

 SelectSetupAndHWConfiguration();

Opens the Setup and Configuration dialog enabling the user to select a hardware configuration or Offline Analysis.

SelectSetupAndHWConfigurationNoDialog

Description 

 SelectSetupAndHWConfigurationNoDialog(
   char *SetupName,
   char *HWConfigName
);

Selects the specified Hardware Setup and Hardware Configuration without showing the Setup and Configuration dialog window.

Parameters

char *SetupName

Name of the hardware setup as it is shown in the Device Manager tab.

char *HWConfigName

Name of the hardware configuration shown in the Device Manager tab when selecting Rename. If the user uses the same name for two hardware configurations each of them having a different camera, the function cannot be used.

ShowDeviceControlDocker

Description 

 ShowDeviceControlDocker(
   int  Show
);

This function is not used.

Parameters

int Show

Index of the element which should be shown or hidden.

0

Hide the pane.

1

Show the pane.

ShowDeviceManagerPad

This function runs the Devices > Show Lightpath Scheme command.

Description 

 ShowDeviceManagerPad(
   int  Show
);

Opens the Lightpath Scheme.

Parameters

int Show

Index of the element which should be shown or hidden.

0

Hide the pane.

1

Show the pane.

BlockPort

Description 

 BlockPort(
   int  SerialPort
);

This function stops the application-to-device default communication on the defined port. This makes the port free to be used by macro applications.

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

See Also 
UnblockPort

ClearPort

Description 

 ClearPort(
   int  SerialPort
);

This function clears the input and output COM buffers.

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

See Also 
WritePort, ReadPort, OpenPort, ClosePort, _WritePort

ClosePort

Description 

 ClosePort(
   int  SerialPort
);

This function closes the opened serial port.

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

Note

If the port is opened, you can close it. If you use scanning stage or light control unit with LIM drivers, these ports are opened automatically when you start NIS-Elements and it is strongly recommended not to close them manually.

See Also 
WritePort, ReadPort, OpenPort, ClearPort, _WritePort

EnablePortCursors

Description 

 EnablePortCursors(
   int  Enabled
);

This function shows/hides cursor, when calling Read/WritePortEx functions.

Parameters

int Enabled

0

Disabled.

1

Enabled.

Return Values

The function returns TRUE.

See Also 
ReadPortEx, WaitDeviceTimeOut, WritePortEx

OpenPort

Description 

 OpenPort(
   int  SerialPort,
   int  BaudRate,
   int  DataBits,
   char *Parity,
   int  StopBits
);

This function sets the port parameters and opens it.

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

int BaudRate

150, 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 38400, 57600, 115200

int DataBits

Data bits.

7

8

char *Parity

N

None

E

Even

O

Odd

int StopBits

1

1 stop bit

2

2 stop bits

Return Values

1, TRUE

port successfully opened

-1725

(-ERR_BADPORTOPEN) - error opening port (e.g. port is already opened or invalid parameters)

See Also 
WritePort, ReadPort, ClosePort, ClearPort, _WritePort

ReadPort

Description 

 ReadPort(
   int  SerialPort,
   int  OutString,
   int  Length
);

This function reads a string from a serial port. Fixed timeout period is 500 ms.

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

int OutString

Buffer for string to be received.

int Length

Buffer length.

Return Values

-1

(DR_UNKNOWNERROR) any error occurred while reading from the port

0

no characters received (timeout)

>0

length of string readed from serial port buffer

-1726

(-ERR_BADPORTOPENWRITE) - invalid handle (e.g. port is not opened)

See Also 
WritePort, OpenPort, ClosePort, ClearPort

ReadPortEx

Description 

int ReadPortEx(
   int  comm,
   char *buf,
   int  toRead,
   int  terminated,
   int  timeout
);

This function reads a string from a serial port. Ending character and timeout can be specified.

Parameters

int comm

Number of a serial port.

char *buf

Buffer for string to be received.

int toRead

Length of the buffer.

int terminated

13 for CR, 10 for LF, -1 for non-terminated

int timeout

Timeout in milliseconds.

Return Values

int

-1

(DR_UNKNOWNERROR) any error occurred while reading from the port or timeout (timeout - if terminated)

0

no characters received (timeout - if no terminated)

>0

length of string readed from serial port buffer

-1726

(-ERR_BADPORTOPENWRITE) - invalid handle (e.g. port is not opened)

See Also 
WritePortEx, WaitDeviceTimeOut

UnblockPort

Description 

 UnblockPort(
   int  SerialPort
);

This function restores the application-to-device default communication on the defined port. The communication may have been stopped by the BlockPort function.

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

See Also 
BlockPort

WaitDeviceTimeOut

Description 

 WaitDeviceTimeOut(
   int  TimeOutEx
);

This function sets up the time-out duration when writing/reading to the serial port.

Parameters

int TimeOutEx

Specifies the duration, in milliseconds, of the time-out period, for WritePort, WritePortEx, ReadPort functions.

Return Values

The function returns TRUE.

Note

This function is called from Write Command to Serial Port dialog box (menu Macro, Write to Port).

See Also 
WritePortEx, ReadPortEx

WritePort

Interactive command to this function: Macro > Write to Port

Description 

 WritePort(
   int  SerialPort,
   char *OutString,
   int  CR_Terminated,
   int  WaitForDevice
);

This function sends a string to a serial port, and optionally waits for answer. The port must be opened before calling this function. An interactive equivalent is the _WritePort function.

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

char *OutString

OutString is a buffer that typically includes text characters but sometimes also non text characters (e.g. line feed or carriage return). For these cases it is possible to use a special notation, both decimal and hexadecimal inside this OutString.

Decimal notation
\ddd, where d is 0-9
Hexadecimal notation
\xhh, where h is 0-9 or A-D or a-f
Examples of decimal and hexadecimal notation
LF: \010, \x0d, \x0D
CR: \013, \x0a, \x0A
int CR_Terminated

If CR_Terminated==1, CR character (carriage return, 13 decimally) is appended to the end of the string. Most devices communicate with commands separated by CR.

0

CR is not appended ()

1

CR character (carriage return, 13 decimally) is appended

int WaitForDevice

If WaitForDevice==1, the system is waiting for answer from the device. If CR_Terminated==1, then the system is waiting for the CR character. If CR_Terminated==0, the system is waiting for the string of characters terminated by 250 ms gap. If there is no answer from the device after time-out, (by default 1 s), it stops and returns error value. You can change the time-out value by double clicking the bottom line of the Write Command to Serial Port dialog box or using the function WaitDeviceTimeOut.

0

Returned immediately after OutString is send.

1

The system is waiting for answer from the device.

Return Values

-1

Timeout expired - no characters returned (if waiting for answer is performed)

1, TRUE

Characters successfully send (if waiting for answer is not performed)

>=1

Length of answer from the device

-1726

(-ERR_BADPORTOPENWRITE) - invalid handle (e.g. port is not opened or error during clearing the port)

-1729

(-ERR_BADPORTWRITE) - error writing to the port (e.g. timeout expired during writing characters)

Examples:
1) ASI MS2000 - switch ZMotor to left
WritePortAndWait(port, "EP Z=-1\013", 13);
WritePortAndWait(port, "SS Z\013", 13);
WritePortAndWait(port, "RESET\013", 13);
or
WritePort(port, "EP Z=-1", 13, 1, null);
WritePort(port, "SS Z", 13, 1);
WritePort(port, "RESET", 13, 1);
2) Sutter LambdaSC - open/close
WritePortAndWait(port, "\xaa", 13); //open
WritePortAndWait(port, "\xac", 13); //close
3) Prior Proscan/Optiscan
WritePortAndWait(port, "7 1 1\013", 13); //set filter 1 position 1
4) Conex Polarizer - set position
WritePortAndWait(port, "xxPA00\013", 13); //move absolute (xx=deviceid)
5) Uniblitz shutter - open/close
WritePort(port, "\x40", 0, 0); //open shutter
WritePort(port, "\x41", 0, 0); //close

See Also 
WritePortEx, WritePortAndWait, WaitDeviceTimeOut, ReadPort

WritePortAndWait

Description 

 WritePortAndWait(
   int  SerialPort,
   char *OutString,
   int  EndChar
);

This function is a simplified version of WritePortEx function. It sends character string OutString to serial port and waits for the response terminated by EndChar. The waiting for EndChar is limited by timeout specified by the function WaitDeviceTimeOut (default value is 1s).

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

char *OutString

OutString is a buffer that typically includes text characters but sometimes also non text characters (e.g. line feed or carriage return). For these cases it is possible to use a special notation, both decimal and hexadecimal inside this OutString.

Decimal notation
\ddd, where d is 0-9
Hexadecimal notation
\xhh, where h is 0-9 or A-D or a-f
Examples of decimal and hexadecimal notation
LF: \010, \x0d, \x0D
CR: \013, \x0a, \x0A
int EndChar

Single character that terminates the response (e.g.: CR or LF).

Example EndChar:
Char colon: ';'
Dedicated EndChar LF (Line Feed) or CR (Carriage Return) is LF = 13, CR = 10

Return Values

Response can be read using ReadPort.

-1

timeout expired - no characters returned (if waiting for answer is performed)

1, TRUE

characters successfully send (if waiting for answer is not performed)

>=1

length of answer from the device

-1726

(-ERR_BADPORTOPENWRITE) - invalid handle (e.g. port is not opened or error during clearing the port)

-1729

(-ERR_BADPORTWRITE) - error writing to the port (e.g. timeout expired during writing characters)

Examples:
1) ASI MS2000
// Z Motor is attached to the left knob
// RESET command is an exeptional one, it replies the char : 
WritePortAndWait(port, "EP Z=-1\013", 13);
WritePortAndWait(port, "SS Z\013", 13);
WritePortAndWait(port, "RESET\013", ':');
or
WritePort(port, "EP Z=-1", 13, 1, null);
WritePort(port, "SS Z", 13, 1);
WritePort(port, "RESET\013", ':', 1);
2) Sutter LambdaSC - open/close
//open shutter
WritePortAndWait(port, "\xaa", 13); 
//close shutter
WritePortAndWait(port, "\xac", 13); 
3) Prior Proscan/Optiscan
//set FW #1 to the position #2
WritePortAndWait(port, "7 1 2\013", 13); 
4) Conex Polarizer 
// set position, xx means deviceID
WritePortAndWait(port, "xxPA00\013", 13); //move absolute 
5) Uniblitz shutter 
This device does not reply to the commands open/close,
Elements does not wait for the reply, 
a simplified function WritePort is used.
//open shutter
WritePort(port, "\x40", 0, 0); 
//close
WritePort(port, "\x41", 0, 0); 

See Also 
WritePort, WritePortEx, WaitDeviceTimeOut, ReadPort

WritePortEx

Description 

 WritePortEx(
   int  SerialPort,
   char *OutString,
   int  CR_Terminated,
   int  WaitForDevice,
   char *outbuff,
   int  append
);

This function sends a string to a serial port, and optionally waits for answer. The port must be opened before calling this function. An interactive equivalent is the _WritePort function.

Parameters

int SerialPort

Specifies the port number

1

COM1

2

COM2

3

COM3

N

COMN

N = 1-99

COM ports with number >9 are supported too (typically virtual COM ports)

char *OutString

OutString is a buffer that typically includes text characters but sometimes also non text characters (e.g. line feed or carriage return). For these cases it is possible to use a special notation, both decimal and hexadecimal inside this OutString.

Decimal notation
\ddd, where d is 0-9
Hexadecimal notation
\xhh, where h is 0-9 or A-D or a-f
Examples of decimal and hexadecimal notation
LF: \010, \x0d, \x0D
CR: \013, \x0a, \x0A
int CR_Terminated

If terminated >=0 or <-1, it is appended to the end of the string. If terminated=-1, nothing is appended, only the string is send.

>=0

The value is appended to the end of the string.

<-1

The negative value is appended to the end of the string.

-1

The string is send alone. Nothing is appended.

int WaitForDevice

If wait==1, the system is waiting for answer from the device. If terminated >=0, then the system is waiting for the "terminated" value. If terminated <-1, the system is waiting for the absolute value of the "terminated" parameter. If terminated==-1, the system is waiting for the string of characters terminated by 250 ms gap. If there is no answer from the device after a time-out (1 s by default), it stops and displays an error message.

0

The function is performed immediately.

1

See above.

char *outbuff

Buffer, where receiving string from the device can be stored. This parameter is used only, if wait==1.

int append

Append/Copy the string that has been read from the device to the Buffer. This parameter is used only, if wait==1.

Return Values

-1

timeout expired - no characters returned (if waiting for answer is performed)

1, TRUE

characters successfully send (if waiting for answer is not performed)

>=1

length of answer from the device

-1726

(-ERR_BADPORTOPENWRITE) - invalid handle (e.g. port is not opened or error during clearing the port)

-1729

(-ERR_BADPORTWRITE) - error writing to the port (e.g. timeout expired during writing characters)

Note

This function is typically called, when you invoke the Write to Port command (Macro menu). An interactive equivalent is _WritePort.

See Also 
WritePort, WritePortAndWait, WaitDeviceTimeOut, ReadPort

_WritePort

This function runs the Macro > Write to Port command.

Description 

 _WritePort();

This function displays the Write Command to Serial Port dialog box.

See Also 
WritePort, ReadPort, OpenPort, ClosePort, ClearPort