esi-labxbridge

A library for communicating with the LabXBridge.

Requirements

A working Installation of LabX Bridge is required.

Dependencies

library version inmation core library

dkjson

2.5.0

yes

socket

3.0.0

yes

esi-variables

1.0.0

yes

esi-tool

1.0.5

yes

Documentation

CHANGERPOSITIONORIGINS

CHANGERPOSITIONORIGINS returns the list with all values of ChangerPositionOrigin enumeration.

Usage

local lib = require("esi-labxbridge")

local result = lib:CHANGERPOSITIONORIGINS()
return result

Return Values

["DetectSample","Relative","Absolute","Undefined"]

DATETIMEINPUTKINDS

DATETIMEINPUTKINDS returns the list with all values of DateTimeInputKind enumeration.

Usage

local lib = require("esi-labxbridge")

local result = lib:DATETIMEINPUTKINDS()
return result

Return Values

["DateTime","Time","Date"]

INSTRUMENTSUMMARYCONNECTIONSTATES

INSTRUMENTSUMMARYCONNECTIONSTATES returns the list with all values of InstrumentSummaryConnectionState enumeration.

Usage

local lib = require("esi-labxbridge")

local result = lib:INSTRUMENTSUMMARYCONNECTIONSTATES()
return result

Return Values

["Unavailable","EmergencyStop","Connected","Ready","Disconnected","Blocked","Undefined","Connecting"]

OVERALLSTATES

OVERALLSTATES returns the list with all values of OverallState enumeration.

Usage

local lib = require("esi-labxbridge")

local result = lib:OVERALLSTATES()
return result

Return Values

["Undefined","Ok","Uncertain","NotOk"]

RELEASESTATES

RELEASESTATES returns the list with all values of ReleaseState enumeration.

Usage

local lib = require("esi-labxbridge")

local result = lib:RELEASESTATES()
return result

Return Values

["Released","Proposed","Obsolete"]

TASKSTATETYPES

TASKSTATETYPES returns the list with all values of TaskStateType enumeration.

Usage

local lib = require("esi-labxbridge")

local result = lib:TASKSTATETYPES()
return result

Return Values

["Maintained","Running","Created","Starting","Waiting","Completed","Paused","Aborted","Suspended"]

INSTRUMENTTYPES

INSTRUMENTTYPES returns the list with all values of InstrumentType enumeration.

Usage

local lib = require("esi-labxbridge")

local result = lib:INSTRUMENTTYPES()
return result

Return Values

["DeReExcellence","TVExcellence","BalanceExcellence","Undefined","Titrator","PeripheralDevice","PHExcellence"]

SETCONNECTION

SETCONNECTION configures TCP connection settings.

It should be called before any other LabX Bridge function.

Parameters

args

Lua table containing the following parameters.

.debugoption (optional)

If set as true then library creates children items containing dubug information, default false

.host (optional)

LabX Bridge hostname or IP, default 127.0.0.1

.port (optional)

LabX Bridge portnumber, default 8989

.timeout (optional)

TCP timeout in seconds, default 60

.buffersize (optional)

TCP buffer size (have to be the same as configured for LabX Bridge), default 2048

Usage

local lib = require("esi-labxbridge")
local connection = {}
connection.host = "127.0.0.1"
connection.port = 8989
connection.timeout = 60
connection.buffersize = 2048
lib:SETCONNECTION(connection)

TESTCONNECTION

TESTCONNECTION tests connection with LabX Bridge Server.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
result = lib:TESTCONNECTION()
return result

Return Values

{"Connected":true}

CLOSECONNECTION

CLOSECONNECTION closes existing TCP connection.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local result = lib:GETSTATUS()
result = lib:CLOSECONNECTION()
return result

Return Values

{"res":{"WasConnected":false,"ConnectionClosed":true}}
or
{"res":{"WasConnected":true,"ConnectionClosed":true}}

GETSTATUS

GETSTATUS returns information about LabX Bridge service.

Returns

  • status["Version"] - the version of the LabX Bridge Service.

  • status[".NET Version"] - the .NET version of the LabX Bridge Service.

  • status["BufferSize"] - the buffer size used to send data to the client.

  • status["TCPPortClient"] - the TCP port used by clients.

  • status["MaxTCPConnectionQueues"] - the maximum length of the pending TCP connections queue.

  • status["TCPEndOfTransmissionSignal"] - the client and the server are sending this string at the end of the command.

  • status["ServiceName"] - the name of the LabX Bridge service.

  • status["ServiceDisplayName"] - the display name of the LabX Bridge service.

  • status["EndpointAddress"] - the address of the LabX Bussines Server endpoint.

  • status["ClientBaseAddress"] - the IP address of client PC where your client app is running, also called Callback point.

  • status["SecurityMode"] - the security mode for wsDualHttpBinding (the used WCF protocol between LabX Bridge and LabX Server).

  • status["KeepAliveIntervalSeconds"] - a periodical method call is executed to keep the LabX Server session open. KeepAliveIntervalSeconds parameter defines this period in seconds.

  • status["SubscriptionMaxItemsCount"] - the maximum number of notifications being buffered.

  • status["SubscriptionMaxReturnedItemsCount"] - the maximum number of notifications retrieved with one GETNOTIFICATIONS() Lua call.

  • status["SubscriptionMaxGetEventsIntervalSeconds"] - the maximum time in seconds that the notifications buffer will be held in memory without the Connector retrieving data.

Usage

local lib = require("esi-labxbridge")
local connection = {}
connection.host = "127.0.0.1"
connection.port = 8989
connection.timeout = 3
connection.buffersize = 2048
lib:SETCONNECTION(connection)
local res, err = lib:GETSTATUS()
return (require "esi-string"):STRING({res=res,err=err})

GETALLRELEASEDMETHODS

GETALLRELEASEDMETHODS returns all released method versions currently available in the LabX database. Methods which are not valid are not returned.

Parameters

args

Lua table containing the following parameters.

.MaxNumberOfRecords (optional)

Maximal number of records returned. Default value is defined by LabX Bridge Server configuration. If this parameter is not set then default is used.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.MaxNumberOfRecords = 1000
local result, exception = lib:GETALLRELEASEDMETHODS(args)
if exception then
	return (require "esi-string"):STRING({ex=exception})
else
	if result.MoreItems then
			local cargs = {}
			cargs.ContinuationKey = result.ContinuationKey
		while true do
			local lresult, exception = lib:GETCONTINUATION(cargs)
			if exception then
				return (require "esi-string"):STRING({ex=exception})
			end

			for ii=1,#lresult.farg do
				result.farg[#result.farg+1] = lresult.farg[ii]
			end

			if  not lresult.MoreItems then
				break
			end
		end
	end
end

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
    "func": "GetAllReleasedMethods",
    "farg": [
        {
            "MethodId": "Weighing (Result)",
            "Name": "Simple Weighing (with Result)",
            "InternalId": "M12",
            "ReleaseState": "Released",
            "BusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
            "Comment": ""
        },
        {
            "MethodId": "Sample scope only",
            "Name": "Sample scope only",
            "InternalId": "M13",
            "ReleaseState": "Released",
            "BusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
            "Comment": ""
        }
    ],
    "MoreItems": false
}
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETTHISMETHOD

GETTHISMETHOD returns the basic method information of a method (specified by its GUID).

Parameters

args

Lua table containing the following parameters.

.BusinessId

BusinessId of the method

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.BusinessId = "2e71a556-957d-4ef2-99a2-a0f254c5aaa7"
local result, exception = lib:GETTHISMETHOD(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{ "res": {
        "farg": {
            "BusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
            "MethodId": "Weighing (Result)",
            "InternalId": "M12",
            "Comment": "",
            "ReleaseState": "Released",
            "Name": "Simple Weighing (with Result)"
        },
        "func": "GetThisMethod"
    }
}
or, if the the method does not exist
{
    "res": {
        "farg": {},
        "func": "GetThisMethod"
    }
}

Exceptions

{"ex": [{"Exception":false,"msg":"'2e71a556-957d-4ef2-99a2-a0f254c5aaa7n' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETTHISMETHODBYUSERDEFINEDID

GETTHISMETHODBYUSERDEFINEDID returns the basic method information from a method with its user defined method ID (=ID in the method properties in the LabX method editor).

Parameters

args

Lua table containing the following parameters.

.UserDefinedMethodId

MethodId of the method

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.UserDefinedMethodId = "Weighing (Result)"
local result, exception = lib:GETTHISMETHODBYUSERDEFINEDID(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
    "farg": {
        "BusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
        "Comment": "",
        "MethodId": "Weighing (Result)",
        "Name": "Simple Weighing (with Result)",
        "InternalId": "M12",
        "ReleaseState": "Released"
    },
    "func": "GetThisMethodByUserDefinedId"
}
}
or, if the method does not exist
{"res": {
    "farg":{},
	"func":"GetThisMethodByUserDefinedId"
}
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETMETHODMETADATA

GETMETHODMETADATA returns the meta data of the method.

Parameters

args

Lua table containing the following parameters.

.BusinessId

BusinessId of the method

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.BusinessId = "2e71a556-957d-4ef2-99a2-a0f254c5aaa7"
local result, exception = lib:GETMETHODMETADATA(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
    "farg": {
        "Scopes": [
            {
                "SampleChangerPosition": {
                    "Position": 0,
                    "ChangerPositionOrigin": "Relative"
                },
                "MethodParameters": [],
                "ScopeName": "Samplescope1",
                "SampleId": {
                    "SampleId4": {
                        "Label": "Sample ID 4",
                        "IsMandatory": false,
                        "DefaultValue": ""
                    },
                    "SampleId1": {
                        "Label": "Sample ID",
                        "IsMandatory": true,
                        "DefaultValue": ""
                    },
                    "SampleId3": {
                        "Label": "Sample ID 3",
                        "IsMandatory": false,
                        "DefaultValue": ""
                    },
                    "SampleId6": {
                        "Label": "Sample ID 6",
                        "IsMandatory": false,
                        "DefaultValue": ""
                    },
                    "SampleId5": {
                        "Label": "Sample ID 5",
                        "IsMandatory": false,
                        "DefaultValue": ""
                    },
                    "SampleId2": {
                        "Label": "Sample ID 2",
                        "IsMandatory": false,
                        "DefaultValue": ""
                    }
                }
            }
        ],
        "MethodParameters": [
            {
                "MinValue": 0.0,
                "MethodFunctionPropertyName": "start",
                "MaxValue": 1.0,
                "MethodFunctionName": "Calculate",
                "DecimalPlaces": 0,
                "$type": "inmationLabXBridge.LabX.DecimalTypeMetaData, LabXBridge"
            },
            {
                "$type": "inmationLabXBridge.LabX.IntegerTypeMetaData, LabXBridge",
                "MethodFunctionPropertyName": "value",
                "MaxValue": 10,
                "MethodFunctionName": "SetValue",
                "MinValue": -10
            },
            {
                "$type": "inmationLabXBridge.LabX.BoolTypeMetaData, LabXBridge",
                "MethodFunctionName": "SetVisibility",
                "MethodFunctionPropertyName": "visible"
            },
            {
                "$type": "inmationLabXBridge.LabX.DateTimeTypeMetaData, LabXBridge",
                "InputKind": "DateTime",
                "MethodFunctionName": "SetStart",
                "MethodFunctionPropertyName": "starttime"
            },
            {
                "$type": "inmationLabXBridge.LabX.StringTypeMetaData, LabXBridge",
                "MethodFunctionName": "SetText",
                "MethodFunctionPropertyName": "text1"
            },
            {
                "$type": "inmationLabXBridge.LabX.StringTypeMetaData, LabXBridge",
                "MethodFunctionName": "SetText",
                "MethodFunctionPropertyName": "text2"
            },
            {
                "SelectableItems": [
                    "A",
                    "B",
                    "C"
                ],
                "MethodFunctionName": "SetType",
                "$type": "inmationLabXBridge.LabX.EnumerationTypeMetaData, LabXBridge",
                "MethodFunctionPropertyName": "type"
            }
        ]
    },
    "func": "GetMethodMetaData"
}
}

Exceptions

{"ex": [{"Exception":true,"msg":"MethodNotExistFault: Method with id 2e71a556-957d-4ef2-99a2-a0f254c5aaa8 does not exist"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETALLAVAILABLEINSTRUMENTS

GETALLAVAILABLEINSTRUMENTS returns all available (defined in LabX) instruments.

Parameters

args

Lua table containing the following parameters.

.MaxNumberOfRecords (optional)

Maximal number of records returned. Default value is defined by LabX Bridge Server configuration. If this parameter is not set then default is used.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.MaxNumberOfRecords = 100
local result, exception = lib:GETALLAVAILABLEINSTRUMENTS(args)
if exception then
	return (require "esi-string"):STRING({ex=exception})
else
	if result.MoreItems then
			local cargs = {}
			cargs.ContinuationKey = result.ContinuationKey
		while true do
			local lresult, exception = lib:GETCONTINUATION(cargs)
			if exception then
				return (require "esi-string"):STRING({ex=exception})
			end

			for ii=1,#lresult.farg do
				result.farg[#result.farg+1] = lresult.farg[ii]
			end

			if  not lresult.MoreItems then
				break
			end
		end
	end
end
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
    "func": "GetAllAvailableInstruments",
    "farg": [
        {
            "MethodId": "Weighing (Result)",
            "Name": "Simple Weighing (with Result)",
            "InternalId": "M12",
            "ReleaseState": "Released",
            "BusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
            "Comment": ""
        },
        {
            "MethodId": "Sample scope only",
            "Name": "Sample scope only",
            "InternalId": "M13",
            "ReleaseState": "Released",
            "BusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
            "Comment": ""
        }
    ],
    "MoreItems": false
}
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETTHISINSTRUMENTSBYNAME

GETTHISINSTRUMENTSBYNAME returns the list of instruments for which the name matches with provided parameter.

Parameters

args

Lua table containing the following parameters.

.InstrumentName

Instrument name

.MaxNumberOfRecords (optional)

Maximal number of records returned. Default value is defined by LabX Bridge Server configuration. If this parameter is not set then default is used.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.InstrumentName = "XPE205 Simulator"
local result, exception = lib:GETTHISINSTRUMENTSBYNAME(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{ "res": {
        "farg": [
            {
                "AvailabilityStatus": "Disconnected",
                "SerialNumber": "1111122222/1111122222",
                "ExtendedProperties": {},
                "Product": "BalanceExcellence",
                "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                "InstrumentModel": "XPE205",
                "AvailableWorkspaces": [
                    "Default"
                ],
                "InternalId": "I6",
                "ProductFamily": "BalanceExcellence",
                "IsDeleted": false,
                "InstrumentName": "XPE205 Simulator"
            }
        ],
        "func": "GetThisInstrumentsByName",
        "MoreItems": false
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETTHISINSTRUMENTBYID

GETTHISINSTRUMENTBYID returns the properties of the instrument specified by its GUID.

Parameters

args

Lua table containing the following parameters.

.InstrumentId

InstrumentId of the instrument

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.InstrumentId = "1d8ac640-e155-44f6-8341-8090068ceae5"
local result, exception = lib:GETTHISINSTRUMENTBYID(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{ "res": {
        "farg": {
            "ExtendedProperties": {},
            "SerialNumber": "1111122222/1111122222",
            "InternalId": "I6",
            "AvailabilityStatus": "Disconnected",
            "IsDeleted": false,
            "ProductFamily": "BalanceExcellence",
            "Product": "BalanceExcellence",
            "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
            "AvailableWorkspaces": [
                "Default"
            ],
            "InstrumentName": "XPE205 Simulator",
            "InstrumentModel": "XPE205"
        },
        "func": "GetThisInstrumentById"
    }
}
or, if the instrument does not exist
{
    "res": {
        "func": "GetThisInstrumentById",
        "farg": {}
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETALLRELEASEDPRODUCTS

GETALLRELEASEDPRODUCTS returns all released products in LabX.

Parameters

args

Lua table containing the following parameters.

.MaxNumberOfRecords (optional)

Maximal number of records returned. Default value is defined by LabX Bridge Server configuration. If this parameter is not set then default is used.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.MaxNumberOfRecords = 1000
local result, exception = lib:GETALLRELEASEDPRODUCTS(args)
if exception then
	return (require "esi-string"):STRING({ex=exception})
else
	if result.MoreItems then
			local cargs = {}
			cargs.ContinuationKey = result.ContinuationKey
		while true do
			local lresult, exception = lib:GETCONTINUATION(cargs)
			if exception then
				return (require "esi-string"):STRING({ex=exception})
			end

			for ii=1,#lresult.farg do
				result.farg[#result.farg+1] = lresult.farg[ii]
			end

			if  not lresult.MoreItems then
				break
			end
		end
	end
end

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
    "farg": [
        {
            "Comment": "",
            "Name": "Test Product 1",
            "InternalId": "P11",
            "BusinessId": "e28c47e7-6060-4f49-8b47-475ba816388f",
            "ProductId": "Test Product 1",
            "Description": ""
        },
        {
            "Comment": "",
            "Name": "Test Product 2",
            "InternalId": "P22",
            "BusinessId": "48a340f5-b068-4dbc-a4d6-34cc77dbfc74",
            "ProductId": "Test Product 2",
            "Description": ""
        }
    ],
    "MoreItems": false,
    "func": "GetAllReleasedProducts"
}
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETTHISPRODUCT

GETTHISPRODUCT returns detail information of the selected product.

Parameters

args

Lua table containing the following parameters.

.BusinessId

BusinessId of the product

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.BusinessId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:GETTHISPRODUCT(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
    "func": "GetThisProduct",
    "farg": {
        "MethodAssignments": [
            {
                "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                "MethodParameters": []
            }
        ],
        "ProductHeader": {
            "Description": "",
            "ProductId": "Test Product",
            "InternalId": "P11",
            "Name": "Test Product",
            "BusinessId": "e28c47e7-6060-4f49-8b47-475ba816388f",
            "Comment": ""
        }
    }
}
}

Exceptions

{"ex": [{"Exception":false,"msg":"'f33fd37c-f37d-4dbe-b62d-90c8839b203dx' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex": [{"Exception":true,"msg":"ProductNotExistFault: Product with id e28c47e7-6060-4f49-8b47-475ba816389f does not exist"}]}
or
"connection refused"

GETALLSAMPLESERIES

GETALLSAMPLESERIES returns all sample series defined in LabX.

Parameters

args

Lua table containing the following parameters.

.MaxNumberOfRecords (optional)

Maximal number of records returned. Default value is defined by LabX Bridge Server configuration. If this parameter is not set then default is used.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.MaxNumberOfRecords = 10
local result, exception = lib:GETALLSAMPLESERIES(args)
if exception then
	return (require "esi-string"):STRING({ex=exception})
else
	if result.MoreItems then
			local cargs = {}
			cargs.ContinuationKey = result.ContinuationKey
		while true do
			local lresult, exception = lib:GETCONTINUATION(cargs)
			if exception then
				return (require "esi-string"):STRING({ex=exception})
			end

			for ii=1,#lresult.farg do
				result.farg[#result.farg+1] = lresult.farg[ii]
			end

			if  not lresult.MoreItems then
				break
			end
		end
	end
end

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
    "MoreItems": false,
    "ContinuationKey": "a50df2a7-8acc-49c9-b1cc-70d772a311d2",
    "farg": [
        {
            "Comment": "",
            "BusinessId": "5cb15cd9-4078-4c9b-9601-6bfbe73cf14e",
            "Name": "NewSampleSeries1",
            "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
            "SeriesId": "",
            "InternalId": "SR11"
        },
        {
            "Comment": "",
            "BusinessId": "91697711-ee13-40cf-b3db-46130f12768b",
            "Name": "NewSampleSeries2",
            "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
            "SeriesId": "",
            "InternalId": "SR12"
        }
    ],
    "func": "GetAllSampleSeries"
}
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETTHISSAMPLESERIES

GETTHISSAMPLESERIES returns detail information of the selected sample series.

Parameters

args

Lua table containing the following parameters.

.BusinessId

BusinessId of the sample series

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.BusinessId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:GETTHISSAMPLESERIES(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res: "{
    "func": "GetThisSampleSeries",
    "farg": {
        "PredefinedSamples": [
            {
                "SampleId": {
                    "SampleId1": "Sample 1",
                    "SampleId3": "",
                    "SampleId6": "",
                    "SampleId4": "",
                    "SampleId2": "",
                    "SampleId5": ""
                },
                "MethodParameters": [],
                "SampleScopeName": "Samplescope1",
                "ProductId": "e28c47e7-6060-4f49-8b47-475ba816388f",
                "SampleChangerPosition": {
                    "ChangerPositionOrigin": "Relative",
                    "Position": 0
                }
            },
            {
                "SampleId": {
                    "SampleId1": "Sample 2",
                    "SampleId3": "",
                    "SampleId6": "",
                    "SampleId4": "",
                    "SampleId2": "",
                    "SampleId5": ""
                },
                "MethodParameters": [],
                "SampleScopeName": "Samplescope1",
                "ProductId": "e28c47e7-6060-4f49-8b47-475ba816388f",
                "SampleChangerPosition": {
                    "ChangerPositionOrigin": "Relative",
                    "Position": 0
                }
            },
            {
                "SampleId": {
                    "SampleId1": "Sample 3",
                    "SampleId3": "",
                    "SampleId6": "",
                    "SampleId4": "",
                    "SampleId2": "",
                    "SampleId5": ""
                },
                "MethodParameters": [],
                "SampleScopeName": "Samplescope1",
                "ProductId": "e28c47e7-6060-4f49-8b47-475ba816388f",
                "SampleChangerPosition": {
                    "ChangerPositionOrigin": "Relative",
                    "Position": 0
                }
            },
            {
                "SampleId": {
                    "SampleId1": "Sample 4",
                    "SampleId3": "",
                    "SampleId6": "",
                    "SampleId4": "",
                    "SampleId2": "",
                    "SampleId5": ""
                },
                "MethodParameters": [],
                "SampleScopeName": "Samplescope1",
                "ProductId": "e28c47e7-6060-4f49-8b47-475ba816388f",
                "SampleChangerPosition": {
                    "ChangerPositionOrigin": "Relative",
                    "Position": 0
                }
            },
            {
                "SampleId": {
                    "SampleId1": "sample 5",
                    "SampleId3": "",
                    "SampleId6": "",
                    "SampleId4": "",
                    "SampleId2": "",
                    "SampleId5": ""
                },
                "MethodParameters": [],
                "SampleScopeName": "Samplescope1",
                "ProductId": "e28c47e7-6060-4f49-8b47-475ba816388f",
                "SampleChangerPosition": {
                    "ChangerPositionOrigin": "Relative",
                    "Position": 0
                }
            }
        ],
        "SampleSeriesHeader": {
            "InternalId": "SR11",
            "Name": "NewSampleSeries1",
            "BusinessId": "5cb15cd9-4078-4c9b-9601-6bfbe73cf14e",
            "Comment": "",
            "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
            "SeriesId": ""
        },
        "MethodParameters": []
    }
}
}

Exceptions

{"ex": [{"Exception":false,"msg":"'e28c47e7-6060-4f49-8b47-475ba816388fnnn' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex":[{"msg":"SampleSerieNotExistFault: Sample series with id 5cb15cd9-4078-4c9b-9601-6bfbe73cf142 does not exist","Exception":false}]}
or
"connection refused"

GETALLEXECUTABLETASKS

GETALLEXECUTABLETASKS returns all tasks with status other than "Completed", "Aborted" or "Running".

Parameters

args

Lua table containing the following parameters.

.MaxNumberOfRecords (optional)

Maximal number of records returned. Default value is defined by LabX Bridge Server configuration. If this parameter is not set then default is used.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.MaxNumberOfRecords = 10
local result, exception = lib:GETALLEXECUTABLETASKS(args)
if exception then
	return (require "esi-string"):STRING({ex=exception})
else
	if result.MoreItems then
			local cargs = {}
			cargs.ContinuationKey = result.ContinuationKey
		while true do
			local lresult, exception = lib:GETCONTINUATION(cargs)
			if exception then
				return (require "esi-string"):STRING({ex=exception})
			end

			for ii=1,#lresult.farg do
				result.farg[#result.farg+1] = lresult.farg[ii]
			end

			if  not lresult.MoreItems then
				break
			end
		end
	end
end

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
    "farg": [
        {
            "TaskId": "eaaf5ad1-dc97-40fc-bbb6-3538e6713538",
            "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
            "TaskState": "Paused",
            "CreationTime": "2024-02-13T03:17:43.87",
            "AccountName": "PredefinedUser",
            "InternalId": "T12",
            "Name": "Sample scope only",
            "MethodName": "Sample scope only"
        },
        {
            "TaskId": "01456f1f-ea45-4630-9af5-94709ef9c1f9",
            "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
            "TaskState": "Created",
            "CreationTime": "2024-02-13T04:01:52.4",
            "AccountName": "PredefinedUser",
            "InternalId": "T15",
            "Name": "Sample scope only",
            "MethodName": "Sample scope only"
        },
        {
            "TaskId": "f33fd37c-f37d-4dbe-b62d-90c8839b203d",
            "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
            "TaskState": "Paused",
            "CreationTime": "2024-02-13T04:29:28.89",
            "AccountName": "PredefinedUser",
            "InternalId": "T16",
            "Name": "Sample scope only",
            "MethodName": "Sample scope only"
        }
    ],
    "MoreItems": true,
    "ContinuationKey": "69bafc54-86b9-4ec3-98ac-ab07b47d737f",
    "func": "GetAllExecutableTasks"
}
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETALLTASKSINRANGE

GETALLTASKSINRANGE returns the list with all tasks in LabX that were created in the range of the specified FromDate and ToDate. However the date range must not exceed 3 days per call.

Parameters

args

Lua table containing the following parameters.

.FromDate

Time as string or POSIX time

.ToDate

Time as string or POSIX time

.MaxNumberOfRecords (optional)

Maximal number of records returned. Default value is defined by LabX Bridge Server configuration. If this parameter is not set then default is used.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.FromDate = "2024-02-13T09:59:59"
args.ToDate = "2024-02-14T23:59:59"
args.MaxNumberOfRecords = 2

local result, exception = lib:GETALLTASKSINRANGE(args)
if exception then
	return (require "esi-string"):STRING({ex=exception})
else
	if result.MoreItems then
			local cargs = {}
			cargs.ContinuationKey = result.ContinuationKey
		while true do
			local lresult, exception = lib:GETCONTINUATION(cargs)
			if exception then
				return (require "esi-string"):STRING({ex=exception})
			end

			for ii=1,#lresult.farg do
				result.farg[#result.farg+1] = lresult.farg[ii]
			end

			if  not lresult.MoreItems then
				break
			end
		end
	end
end
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{ "res": {
        "MoreItems": true,
        "ContinuationKey": "029f6d1d-d766-4b0c-9aec-cd11ad20e615",
        "func": "GetAllTasksInRange",
        "farg": [
            {
                "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                "TaskState": "Paused",
                "TaskId": "f33fd37c-f37d-4dbe-b62d-90c8839b203d",
                "MethodName": "Sample scope only",
                "InternalId": "T16",
                "AccountName": "PredefinedUser",
                "Name": "Sample scope only",
                "CreationTime": "2024-02-13T04:29:28.89"
            },
            {
                "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                "TaskState": "Created",
                "TaskId": "01456f1f-ea45-4630-9af5-94709ef9c1f9",
                "MethodName": "Sample scope only",
                "InternalId": "T15",
                "AccountName": "PredefinedUser",
                "Name": "Sample scope only",
                "CreationTime": "2024-02-13T04:01:52.4"
            },
            {
                "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                "TaskState": "Completed",
                "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                "MethodName": "Simple Weighing (with Result)",
                "InternalId": "T14",
                "AccountName": "PredefinedUser",
                "Name": "T14_Simple Weighing (with Result)",
                "CreationTime": "2024-02-13T03:50:54.61"
            },
            {
                "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                "TaskState": "Paused",
                "TaskId": "eaaf5ad1-dc97-40fc-bbb6-3538e6713538",
                "MethodName": "Sample scope only",
                "InternalId": "T12",
                "AccountName": "PredefinedUser",
                "Name": "Sample scope only",
                "CreationTime": "2024-02-13T03:17:43.87"
            }
        ]
    }
}

Exceptions

[{"msg":"Date range not correct.","Exception":false}]
or
{"tcp":"timeout","msg":"Error during TCP connection"}
or
"connection refused"

GETTHISTASK

GETTHISTASK returns the properties of the selected task (specified by its GUID).

Parameters

args

Lua table containing the following parameters.

.TaskId

TaskId of the task

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.TaskId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:GETTHISTASK(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res": {
	"farg":
	{
	"TaskState":"Paused",
	"AccountName":"PredefinedUser",
	"TaskId":"f33fd37c-f37d-4dbe-b62d-90c8839b203d",
	"MethodBusinessId":"3dae4bfa-814e-4101-88e3-f38d7c821b6c",
	"CreationTime":"2024-02-13T04:29:28.89",
	"Name":"Sample scope only",
	"MethodName":"Sample scope only",
	"InternalId":"T16"
	},
    "func":"GetThisTask"
}
}
or, if the task does not exist
{"res": {
    "farg":{},
	"func":"GetThisTask"
}
}

Exceptions

{"ex": [{"Exception":false,"msg":"'x33fd37c-f37d-4dbe-b62d-90c8839b203d' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

CREATEPRODUCT

CREATEPRODUCT creates a product.

Parameters

args

Lua table containing the following parameters.

.Name

Product name

.ProductId

Product ID

.Comment (optional)

Comment

.Description

Description

.MethodAssignments (optional)

Array of method assigments. The created product may reference existing methods. In this case all defined task parameters of method functions in sample scopes have to be provided.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.Name = ""
args.ProductId = "Test product 1"
args.Comment = "This is test product"
args.Description = ""
args.MethodAssignments = {}
args.MethodAssignments[1] = {}
args.MethodAssignments[1].MethodBusinessId = "2e71a556-957d-4ef2-99a2-a0f254c5aaa7"
args.MethodAssignments[1].MethodParameters = {}
args.MethodAssignments[1].MethodParameters[1] = {}
args.MethodAssignments[1].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.MethodAssignments[1].MethodParameters[1].MethodFunctionPropertyValue = "10.5"
args.MethodAssignments[1].MethodParameters[1].MethodFunctionName = "Calculate"
args.MethodAssignments[1].MethodParameters[1].MethodFunctionPropertyName = "value"
args.MethodAssignments[1].MethodParameters[2] = {}
args.MethodAssignments[1].MethodParameters[2].MethodFunctionPropertyType = "Bool"
args.MethodAssignments[1].MethodParameters[2].MethodFunctionPropertyValue = true
args.MethodAssignments[1].MethodParameters[2].MethodFunctionName = "SetVisibility"
args.MethodAssignments[1].MethodParameters[2].MethodFunctionPropertyName = "visible"
args.MethodAssignments[1].MethodParameters[3] = {}
args.MethodAssignments[1].MethodParameters[3].MethodFunctionPropertyType = "DateTime"
args.MethodAssignments[1].MethodParameters[3].MethodFunctionPropertyValue = "2024-03-22T14:10:00"
args.MethodAssignments[1].MethodParameters[3].MethodFunctionName = "SetStart"
args.MethodAssignments[1].MethodParameters[3].MethodFunctionPropertyName = "startTime"
args.MethodAssignments[1].MethodParameters[4] = {}
args.MethodAssignments[1].MethodParameters[4].MethodFunctionPropertyType = "Enumeration"
args.MethodAssignments[1].MethodParameters[4].MethodFunctionPropertyValue = "A"
args.MethodAssignments[1].MethodParameters[4].MethodFunctionName = "SetType"
args.MethodAssignments[1].MethodParameters[4].MethodFunctionPropertyName = "type"
args.MethodAssignments[1].MethodParameters[5] = {}
args.MethodAssignments[1].MethodParameters[5].MethodFunctionPropertyType = "Integer"
args.MethodAssignments[1].MethodParameters[5].MethodFunctionPropertyValue = "15"
args.MethodAssignments[1].MethodParameters[5].MethodFunctionName = "SetValue"
args.MethodAssignments[1].MethodParameters[5].MethodFunctionPropertyName = "value"
args.MethodAssignments[1].MethodParameters[6] = {}
args.MethodAssignments[1].MethodParameters[6].MethodFunctionPropertyType = "String"
args.MethodAssignments[1].MethodParameters[6].MethodFunctionPropertyValue = "Test1"
args.MethodAssignments[1].MethodParameters[6].MethodFunctionName = "SetText"
args.MethodAssignments[1].MethodParameters[6].MethodFunctionPropertyName = "text1"
args.MethodAssignments[1].MethodParameters[7] = {}
args.MethodAssignments[1].MethodParameters[7].MethodFunctionPropertyType = "String"
args.MethodAssignments[1].MethodParameters[7].MethodFunctionPropertyValue = "Test2"
args.MethodAssignments[1].MethodParameters[7].MethodFunctionName = "SetText"
args.MethodAssignments[1].MethodParameters[7].MethodFunctionPropertyName = "text2"
args.MethodAssignments[2] = {}
args.MethodAssignments[2].MethodBusinessId = "6254e992-daef-4425-ab7c-3893ab14f168"
args.MethodAssignments[2].MethodParameters = {}
args.MethodAssignments[2].MethodParameters[1] = {}
args.MethodAssignments[2].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.MethodAssignments[2].MethodParameters[1].MethodFunctionPropertyValue = "33.5"
args.MethodAssignments[2].MethodParameters[1].MethodFunctionName = "CalculateTotal"
args.MethodAssignments[2].MethodParameters[1].MethodFunctionPropertyName = "value"

local result, exception = lib:CREATEPRODUCT(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{
    "res": {
        "func": "CreateProduct",
        "farg": {
            "ProductHeader": {
                "Comment": "mycomment",
                "Description": "mydescription",
                "Name": "This is product name",
                "BusinessId": "0c6bfc2c-72f8-4aee-ab53-23e3a52791f8",
                "InternalId": "P80",
                "ProductId": "myProductId1"
            },
            "MethodAssignments": [
                {
                    "MethodParameters": [
                        {
                            "MethodFunctionPropertyName": "value",
                            "Value": 10.5,
                            "$type": "LabXBridge.LabX.DecimalTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "Calculate"
                        },
                        {
                            "MethodFunctionPropertyName": "visible",
                            "Value": true,
                            "$type": "LabXBridge.LabX.BoolTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "SetVisibility"
                        },
                        {
                            "MethodFunctionPropertyName": "startTime",
                            "Value": "2024-03-22T14:10:00",
                            "$type": "LabXBridge.LabX.DateTimeTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "SetStart"
                        },
                        {
                            "MethodFunctionPropertyName": "type",
                            "Value": "A",
                            "$type": "LabXBridge.LabX.EnumerationTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "SetType"
                        },
                        {
                            "MethodFunctionPropertyName": "value",
                            "Value": 15,
                            "$type": "LabXBridge.LabX.IntegerTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "SetValue"
                        },
                        {
                            "MethodFunctionPropertyName": "text1",
                            "Value": "Test1",
                            "$type": "LabXBridge.LabX.StringTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "SetText"
                        },
                        {
                            "MethodFunctionPropertyName": "text2",
                            "Value": "Test2",
                            "$type": "LabXBridge.LabX.StringTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "SetText"
                        }
                    ],
                    "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7"
                },
                {
                    "MethodParameters": [
                        {
                            "MethodFunctionPropertyName": "value",
                            "Value": 33.5,
                            "$type": "LabXBridge.LabX.DecimalTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "CalculateTotal"
                        }
                    ],
                    "MethodBusinessId": "6254e992-daef-4425-ab7c-3893ab14f168"
                }
            ]
        }
    }
}

Exceptions

{"ex": [{"Exception":true,"msg":"ValidationFault: Parameter 'visible' of method function 'SetVisibility' is obsolete."}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

REMOVEPRODUCT

REMOVEPRODUCT removes a product in LabX.

Parameters

args

Lua table containing the following parameters.

.BusinessId

BusinessId of the product

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.BusinessId = "609cee6d-e8a5-4d71-8ec7-ec73cf2948ee"
local result, exception = lib:REMOVEPRODUCT(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{ "res": {
        "func": "RemoveProduct",
        "farg": {}
    }
}

Exceptions

{"ex": [{"Exception":false,"msg":"'x33fd37c-f37d-4dbe-b62d-90c8839b203d' is not valid guid"}]}
or
{"ex":[{"Exception":true,"msg":"ProductNotExistFault: Product with id 9d2443fb-78ee-4276-994c-c1598c1ab6b1 does not exist"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

CREATESAMPLESERIES

CREATESAMPLESERIES creates a sample series.

Parameters

args

Lua table containing the following parameters.

.Name

Sample series name

.Comment (optional)

Comment

.MethodBusinessId

BusinessId of the method

.PredefinedSamples

Array of predefined samples

.MethodParameters (optional)

Array of method parameters

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.Name = "Test sample series 1"
args.SeriesId = "myseriesid1"
args.Comment = "This is test sample series"
args.MethodBusinessId = "2e71a556-957d-4ef2-99a2-a0f254c5aaa7"
args.PredefinedSamples = {}
args.PredefinedSamples[2] = {}

args.PredefinedSamples[2].MethodParameters = {}
args.PredefinedSamples[2].MethodParameters[1] = {}
args.PredefinedSamples[2].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.PredefinedSamples[2].MethodParameters[1].MethodFunctionPropertyValue = "12.5"
args.PredefinedSamples[2].MethodParameters[1].MethodFunctionName = "CalculateWeight"
args.PredefinedSamples[2].MethodParameters[1].MethodFunctionPropertyName = "value"
args.PredefinedSamples[2].MethodParameters[2] = {}
args.PredefinedSamples[2].MethodParameters[2].MethodFunctionPropertyType = "String"
args.PredefinedSamples[2].MethodParameters[2].MethodFunctionPropertyValue = "Weigh a sample"
args.PredefinedSamples[2].MethodParameters[2].MethodFunctionName = "Weight1"
args.PredefinedSamples[2].MethodParameters[2].MethodFunctionPropertyName = "instruction"

args.PredefinedSamples[2].SampleId = {}
args.PredefinedSamples[2].SampleId.SampleId1 = "B"
args.PredefinedSamples[2].SampleId.SampleId2 = ""
args.PredefinedSamples[2].SampleId.SampleId3 = ""
args.PredefinedSamples[2].SampleId.SampleId4 = ""
args.PredefinedSamples[2].SampleId.SampleId5 = ""
args.PredefinedSamples[2].SampleId.SampleId6 = ""
args.PredefinedSamples[2].SampleScopeName = "Samplescope1"
args.PredefinedSamples[2].ProductId = "e28c47e7-6060-4f49-8b47-475ba816388f"
args.PredefinedSamples[2].SampleChangerPosition = {}
-- this value may be "Undefined", "Absolute", "Relative", "DetectSample"
args.PredefinedSamples[2].SampleChangerPosition.ChangerPositionOrigin = "Absolute"
args.PredefinedSamples[2].SampleChangerPosition.Position = 3

args.PredefinedSamples[1] = {}

args.PredefinedSamples[1].MethodParameters = {}
args.PredefinedSamples[1].MethodParameters[1] = {}
args.PredefinedSamples[1].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.PredefinedSamples[1].MethodParameters[1].MethodFunctionPropertyValue = "1.5"
args.PredefinedSamples[1].MethodParameters[1].MethodFunctionName = "CalculateWeight"
args.PredefinedSamples[1].MethodParameters[1].MethodFunctionPropertyName = "value"
args.PredefinedSamples[1].MethodParameters[2] = {}
args.PredefinedSamples[1].MethodParameters[2].MethodFunctionPropertyType = "String"
args.PredefinedSamples[1].MethodParameters[2].MethodFunctionPropertyValue = "Weigh a next sample"
args.PredefinedSamples[1].MethodParameters[2].MethodFunctionName = "Weight1"
args.PredefinedSamples[1].MethodParameters[2].MethodFunctionPropertyName = "instruction"

args.PredefinedSamples[1].SampleId = {}
args.PredefinedSamples[1].SampleId.SampleId1 = "A"
args.PredefinedSamples[1].SampleId.SampleId2 = ""
args.PredefinedSamples[1].SampleId.SampleId3 = ""
args.PredefinedSamples[1].SampleId.SampleId4 = ""
args.PredefinedSamples[1].SampleId.SampleId5 = ""
args.PredefinedSamples[1].SampleId.SampleId6 = ""
args.PredefinedSamples[1].SampleScopeName = "Samplescope1"
args.PredefinedSamples[1].ProductId = "e28c47e7-6060-4f49-8b47-475ba816388f"
args.PredefinedSamples[1].SampleChangerPosition = {}
-- this value may be "Undefined", "Absolute", "Relative", "DetectSample"
args.PredefinedSamples[1].SampleChangerPosition.ChangerPositionOrigin = "Absolute"
args.PredefinedSamples[1].SampleChangerPosition.Position = 4

args.MethodParameters = {}
args.MethodParameters[1] = {}
args.MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.MethodParameters[1].MethodFunctionPropertyValue = "10.5"
args.MethodParameters[1].MethodFunctionName = "Calculate"
args.MethodParameters[1].MethodFunctionPropertyName = "value"
args.MethodParameters[2] = {}
args.MethodParameters[2].MethodFunctionPropertyType = "Bool"
args.MethodParameters[2].MethodFunctionPropertyValue = true
args.MethodParameters[2].MethodFunctionName = "SetVisibility"
args.MethodParameters[2].MethodFunctionPropertyName = "visible"
args.MethodParameters[3] = {}
args.MethodParameters[3].MethodFunctionPropertyType = "DateTime"
args.MethodParameters[3].MethodFunctionPropertyValue = "2024-03-22T14:10:00"
args.MethodParameters[3].MethodFunctionName = "SetStart"
args.MethodParameters[3].MethodFunctionPropertyName = "startTime"
args.MethodParameters[4] = {}
args.MethodParameters[4].MethodFunctionPropertyType = "Enumeration"
args.MethodParameters[4].MethodFunctionPropertyValue = "A"
args.MethodParameters[4].MethodFunctionName = "SetType"
args.MethodParameters[4].MethodFunctionPropertyName = "type"
args.MethodParameters[5] = {}
args.MethodParameters[5].MethodFunctionPropertyType = "Integer"
args.MethodParameters[5].MethodFunctionPropertyValue = "15"
args.MethodParameters[5].MethodFunctionName = "SetValue"
args.MethodParameters[5].MethodFunctionPropertyName = "value"
args.MethodParameters[6] = {}
args.MethodParameters[6].MethodFunctionPropertyType = "String"
args.MethodParameters[6].MethodFunctionPropertyValue = "Test1"
args.MethodParameters[6].MethodFunctionName = "SetText"
args.MethodParameters[6].MethodFunctionPropertyName = "text1"
args.MethodParameters[7] = {}
args.MethodParameters[7].MethodFunctionPropertyType = "String"
args.MethodParameters[7].MethodFunctionPropertyValue = "Test2"
args.MethodParameters[7].MethodFunctionName = "SetText"
args.MethodParameters[7].MethodFunctionPropertyName = "text2"

local result, exception = lib:CREATESAMPLESERIES(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{
    "res": {
        "func": "CreateSampleSeries",
        "farg": {
            "PredefinedSamples": [
                {
                    "MethodParameters": [
                        {
                            "Value": 1.5,
                            "$type": "LabXBridge.LabX.DecimalTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "CalculateWeight",
                            "MethodFunctionPropertyName": "value"
                        },
                        {
                            "Value": "Weigh a next sample",
                            "$type": "LabXBridge.LabX.StringTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "Weight1",
                            "MethodFunctionPropertyName": "instruction"
                        }
                    ],
                    "ProductId": "e28c47e7-6060-4f49-8b47-475ba816388f",
                    "SampleScopeName": "Samplescope1",
                    "SampleChangerPosition": {
                        "Position": 4,
                        "ChangerPositionOrigin": "Absolute"
                    },
                    "SampleId": {
                        "SampleId2": "",
                        "SampleId3": "",
                        "SampleId1": "A",
                        "SampleId5": "",
                        "SampleId6": "",
                        "SampleId4": ""
                    }
                },
                {
                    "MethodParameters": [
                        {
                            "Value": 12.5,
                            "$type": "LabXBridge.LabX.DecimalTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "CalculateWeight",
                            "MethodFunctionPropertyName": "value"
                        },
                        {
                            "Value": "Weigh a sample",
                            "$type": "LabXBridge.LabX.StringTypeMethodParameter, LabXBridge",
                            "MethodFunctionName": "Weight1",
                            "MethodFunctionPropertyName": "instruction"
                        }
                    ],
                    "ProductId": "e28c47e7-6060-4f49-8b47-475ba816388f",
                    "SampleScopeName": "Samplescope1",
                    "SampleChangerPosition": {
                        "Position": 3,
                        "ChangerPositionOrigin": "Absolute"
                    },
                    "SampleId": {
                        "SampleId2": "",
                        "SampleId3": "",
                        "SampleId1": "B",
                        "SampleId5": "",
                        "SampleId6": "",
                        "SampleId4": ""
                    }
                }
            ],
            "SampleSeriesHeader": {
                "Comment": "This is test sample series",
                "SeriesId": "myseriesid1",
                "BusinessId": "7240bb39-dc6c-46ad-9f6f-677f380651b5",
                "InternalId": "SR174",
                "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                "Name": "Test sample series 1"
            },
            "MethodParameters": [
                {
                    "Value": 10.5,
                    "$type": "LabXBridge.LabX.DecimalTypeMethodParameter, LabXBridge",
                    "MethodFunctionName": "Calculate",
                    "MethodFunctionPropertyName": "value"
                },
                {
                    "Value": true,
                    "$type": "LabXBridge.LabX.BoolTypeMethodParameter, LabXBridge",
                    "MethodFunctionName": "SetVisibility",
                    "MethodFunctionPropertyName": "visible"
                },
                {
                    "Value": "2024-03-22T14:10:00",
                    "$type": "LabXBridge.LabX.DateTimeTypeMethodParameter, LabXBridge",
                    "MethodFunctionName": "SetStart",
                    "MethodFunctionPropertyName": "startTime"
                },
                {
                    "Value": "A",
                    "$type": "LabXBridge.LabX.EnumerationTypeMethodParameter, LabXBridge",
                    "MethodFunctionName": "SetType",
                    "MethodFunctionPropertyName": "type"
                },
                {
                    "Value": 15,
                    "$type": "LabXBridge.LabX.IntegerTypeMethodParameter, LabXBridge",
                    "MethodFunctionName": "SetValue",
                    "MethodFunctionPropertyName": "value"
                },
                {
                    "Value": "Test1",
                    "$type": "LabXBridge.LabX.StringTypeMethodParameter, LabXBridge",
                    "MethodFunctionName": "SetText",
                    "MethodFunctionPropertyName": "text1"
                },
                {
                    "Value": "Test2",
                    "$type": "LabXBridge.LabX.StringTypeMethodParameter, LabXBridge",
                    "MethodFunctionName": "SetText",
                    "MethodFunctionPropertyName": "text2"
                }
            ]
        }
    }
}

Exceptions

{"ex":[{"msg":"SampleSeriesValidationFault: Invalid sample serie can't be inserted: No samples for sample scope 'Samplescope1' defined.","Exception":true}]}
or
{"ex":[{"Exception":true,"msg":"SampleSeriesValidationFault: The value for 'Name' is incorrect.  "}]}
or
{"ex":[{"Exception":true,"msg":"MethodNotExistFault: Method with id 2e71a556-957d-4ef2-99a2-a0f254c5aaa8 does not exist"}]}
or
{"ex":[{"Exception":true,"msg":"ProductNotExistFault: Product with id e28c47e7-6060-4f49-8b47-475ba816388a does not exist"}]}
or
{"ex": [{"Exception":true,"msg":"ValidationFault: Parameter 'visible' of method function 'SetVisibility' is obsolete."}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

REMOVESAMPLESERIES

REMOVESAMPLESERIES removes a sample series in LabX.

Parameters

args

Lua table containing the following parameters.

.BusinessId

BusinessId of the sample series

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.BusinessId = "609cee6d-e8a5-4d71-8ec7-ec73cf2948ee"
local result, exception = lib:REMOVESAMPLESERIES(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{
    "func":"RemoveSampleSeries",
    "farg":{}
}
}

Exceptions

{"ex": [{"Exception":false,"msg":"'x33fd37c-f37d-4dbe-b62d-90c8839b203d' is not valid guid"}]}
or
{"ex":[{"Exception":true,"msg":"SampleSerieNotExistFault: Sample series with id 9d2443fb-78ee-4276-994c-c1598c1ab6b1 does not exist"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

CREATETASK

CREATETASK creates a task.

Parameters

args

Lua table containing the following parameters.

.UserDefinedTaskId (optional)

User defined task Id (visible as "Name" on the LabX task listing)

.PriorityTask

Defines if it is priority task

.MethodBusinessId

BusinessId of the method

.MethodParameters (optional)

Array of method parameters

.SampleParameters (optional)

Array of sample parameters

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.MethodBusinessId = "2e71a556-957d-4ef2-99a2-a0f254c5aaa7"
args.UserDefinedTaskId = "My Test task 2"
args.PriorityTask = false
args.SampleParameters = {}
args.SampleParameters[2] = {}

args.SampleParameters[2].MethodParameters = {}
args.SampleParameters[2].MethodParameters[1] = {}
args.SampleParameters[2].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.SampleParameters[2].MethodParameters[1].MethodFunctionPropertyValue = "12.5"
args.SampleParameters[2].MethodParameters[1].MethodFunctionName = "CalculateWeight"
args.SampleParameters[2].MethodParameters[1].MethodFunctionPropertyName = "value"
args.SampleParameters[2].MethodParameters[2] = {}
args.SampleParameters[2].MethodParameters[2].MethodFunctionPropertyType = "String"
args.SampleParameters[2].MethodParameters[2].MethodFunctionPropertyValue = "Weigh a sample"
args.SampleParameters[2].MethodParameters[2].MethodFunctionName = "Weight1"
args.SampleParameters[2].MethodParameters[2].MethodFunctionPropertyName = "instruction"

args.SampleParameters[2].SampleId = {}
args.SampleParameters[2].SampleId.SampleId1 = "B"
args.SampleParameters[2].SampleId.SampleId2 = ""
args.SampleParameters[2].SampleId.SampleId3 = ""
args.SampleParameters[2].SampleId.SampleId4 = ""
args.SampleParameters[2].SampleId.SampleId5 = ""
args.SampleParameters[2].SampleId.SampleId6 = ""
args.SampleParameters[2].SampleScopeName = "Samplescope1"
args.SampleParameters[2].ProductId = "e28c47e7-6060-4f49-8b47-475ba816388f"
args.SampleParameters[2].SampleChangerPosition = {}
-- this value may be "Undefined", "Absolute", "Relative", "DetectSample"
args.SampleParameters[2].SampleChangerPosition.ChangerPositionOrigin = "Absolute"
args.SampleParameters[2].SampleChangerPosition.Position = 3

args.SampleParameters[1] = {}

args.SampleParameters[1].MethodParameters = {}
args.SampleParameters[1].MethodParameters[1] = {}
args.SampleParameters[1].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.SampleParameters[1].MethodParameters[1].MethodFunctionPropertyValue = "1.5"
args.SampleParameters[1].MethodParameters[1].MethodFunctionName = "CalculateWeight"
args.SampleParameters[1].MethodParameters[1].MethodFunctionPropertyName = "value"
args.SampleParameters[1].MethodParameters[2] = {}
args.SampleParameters[1].MethodParameters[2].MethodFunctionPropertyType = "String"
args.SampleParameters[1].MethodParameters[2].MethodFunctionPropertyValue = "Weigh a next sample"
args.SampleParameters[1].MethodParameters[2].MethodFunctionName = "Weight1"
args.SampleParameters[1].MethodParameters[2].MethodFunctionPropertyName = "instruction"

args.SampleParameters[1].SampleId = {}
args.SampleParameters[1].SampleId.SampleId1 = "A"
args.SampleParameters[1].SampleId.SampleId2 = ""
args.SampleParameters[1].SampleId.SampleId3 = ""
args.SampleParameters[1].SampleId.SampleId4 = ""
args.SampleParameters[1].SampleId.SampleId5 = ""
args.SampleParameters[1].SampleId.SampleId6 = ""
args.SampleParameters[1].SampleScopeName = "Samplescope1"
args.SampleParameters[1].ProductId = "e28c47e7-6060-4f49-8b47-475ba816388f"
args.SampleParameters[1].SampleChangerPosition = {}
-- this value may be "Undefined", "Absolute", "Relative", "DetectSample"
args.SampleParameters[1].SampleChangerPosition.ChangerPositionOrigin = "Absolute"
args.SampleParameters[1].SampleChangerPosition.Position = 4

args.MethodParameters = {}
args.MethodParameters[1] = {}
args.MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.MethodParameters[1].MethodFunctionPropertyValue = "10.5"
args.MethodParameters[1].MethodFunctionName = "Calculate"
args.MethodParameters[1].MethodFunctionPropertyName = "value"
args.MethodParameters[2] = {}
args.MethodParameters[2].MethodFunctionPropertyType = "Bool"
args.MethodParameters[2].MethodFunctionPropertyValue = true
args.MethodParameters[2].MethodFunctionName = "SetVisibility"
args.MethodParameters[2].MethodFunctionPropertyName = "visible"
args.MethodParameters[3] = {}
args.MethodParameters[3].MethodFunctionPropertyType = "DateTime"
args.MethodParameters[3].MethodFunctionPropertyValue = "2024-03-22T14:10:00"
args.MethodParameters[3].MethodFunctionName = "SetStart"
args.MethodParameters[3].MethodFunctionPropertyName = "startTime"
args.MethodParameters[4] = {}
args.MethodParameters[4].MethodFunctionPropertyType = "Enumeration"
args.MethodParameters[4].MethodFunctionPropertyValue = "A"
args.MethodParameters[4].MethodFunctionName = "SetType"
args.MethodParameters[4].MethodFunctionPropertyName = "type"
args.MethodParameters[5] = {}
args.MethodParameters[5].MethodFunctionPropertyType = "Integer"
args.MethodParameters[5].MethodFunctionPropertyValue = "15"
args.MethodParameters[5].MethodFunctionName = "SetValue"
args.MethodParameters[5].MethodFunctionPropertyName = "value"
args.MethodParameters[6] = {}
args.MethodParameters[6].MethodFunctionPropertyType = "String"
args.MethodParameters[6].MethodFunctionPropertyValue = "Test1"
args.MethodParameters[6].MethodFunctionName = "SetText"
args.MethodParameters[6].MethodFunctionPropertyName = "text1"
args.MethodParameters[7] = {}
args.MethodParameters[7].MethodFunctionPropertyType = "String"
args.MethodParameters[7].MethodFunctionPropertyValue = "Test2"
args.MethodParameters[7].MethodFunctionName = "SetText"
args.MethodParameters[7].MethodFunctionPropertyName = "text2"

local result, exception = lib:CREATETASK(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"farg":{"TaskId":"7140b75f-8f73-43e8-a401-718fc4d88993"},"func":"CreateTask"}}

Exceptions

{"ex":[{"msg":"MethodNotExistFault: Method with id 2e71a556-957d-4ef2-99a2-a0f254c5aaa8 does not exist","Exception":true}]}
or

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETALLUSERS

GETALLUSERS returns all users defined in LabX (V13 method).

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}

local result, exception = lib:GETALLUSERS()

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":
    {
    "MoreItems":false,
    "func":"GetAllUsers",
    "farg":
    [
    {
    "LogOnName":"PredefinedUser",
    "FullName":"Administrator",
    "UserId":"5d5e746c-2030-4f12-baaf-55c422007a77",
    "State":"Active"
    },
    {
    "LogOnName":"test",
    "FullName":"test",
    "UserId":"9d4c93e0-4d20-43ea-bd81-33a94bdd4b49",
    "State":"Active"
    },
    {
    "LogOnName":"long",
    "FullName":"very long name",
    "UserId":"4eae4f32-174a-44df-836d-3ed0205a80e8",
    "State":"Active"
    }
    ]
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETALLROLES

GETALLROLES returns all user roles defined in LabX (V13 method).

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}

local result, exception = lib:GETALLROLES()

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":
    {
    "MoreItems":false,
    "func":"GetAllRoles",
    "farg":
    [
    {
    "Name":"MT Service",
    "RoleId":"162e50f6-e786-416b-aaba-0d8fc489ca9e"
    },
    {
    "Name":"Lab Administrator",
    "RoleId":"f67230b5-db6f-4a45-9e8e-a88050e206c5"
    },
    {
    "Name":"Lab Manager",
    "RoleId":"4541bbaa-b0cf-4a57-ac48-edc312aac40b"
    },
    {
    "Name":"Lab Technician",
    "RoleId":"470f4dba-2a75-4fc9-abc9-4e662c6e2cdc"
    },
    {
    "Name":"Lab Assistant",
    "RoleId":"5c824f52-38a3-4fae-b2f5-40b6b712fac8"
    }
    ]
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex":[{"Exception":false,"msg":"Missing \"RoleId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"Missing \"TaskId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"'5cb15cd9-4078-4c9b-9601-6bfbe73cf14eg' is not valid guid"}]}
or
"connection refused"

UNASSIGNTASKFROMUSER

UNASSIGNTASKFROMUSER removes the assignment of the task from a user (V13 method).

Parameters

args

Lua table containing the following parameters.

.TaskId

BusinessId of the task

.UserId

BusinessId of the user

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.TaskId = "75ebfde4-8d35-4fc1-bffe-303fd302f6e0"
args.UserId = "5d5e746c-2030-4f12-baaf-55c422007a77"

local result, exception = lib:UNASSIGNTASKFROMUSER(args)

Return Values

{"res":
    {
    "func":"UnassignTaskFromUser",
    "farg":{}}
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex":[{"Exception":false,"msg":"Missing \"UserId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"The creator of this fault did not specify a Reason."}]}
or
{"ex":[{"Exception":false,"msg":"Missing \"TaskId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"'5cb15cd9-4078-4c9b-9601-6bfbe73cf14eg' is not valid guid"}]}
or
"connection refused"

UNASSIGNTASKFROMINSTRUMENT

UNASSIGNTASKFROMINSTRUMENT removes the assignment of the task from an instrument (V13 method).

Parameters

args

Lua table containing the following parameters.

.TaskId

BusinessId of the task

.InstrumentId

BusinessId of the instrument

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.TaskId = "75ebfde4-8d35-4fc1-bffe-303fd302f6e0"
args.InstrumentId = "1d8ac640-e155-44f6-8341-8090068ceae5"

local result, exception = lib:UNASSIGNTASKFROMINSTRUMENT(args)

Return Values

{"res":
    {
    "func":"UnassignTaskFromInstrument",
    "farg":{}}
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex":[{"Exception":false,"msg":"Missing \"InstrumentId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"The creator of this fault did not specify a Reason."}]}
or
{"ex":[{"Exception":false,"msg":"Missing \"TaskId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"'5cb15cd9-4078-4c9b-9601-6bfbe73cf14eg' is not valid guid"}]}
or
"connection refused"

ASSIGNTASKTOROLE

ASSIGNTASKTOROLE makes task visible only for users within a dedicated role, make use of this method immediately after having created the task (V13 method).

Parameters

args

Lua table containing the following parameters.

.TaskId

BusinessId of the task

.RoleId

BusinessId of the role

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.TaskId = "75ebfde4-8d35-4fc1-bffe-303fd302f6e0"
args.RoleId = "162e50f6-e786-416b-aaba-0d8fc489ca9e"

local result, exception = lib:ASSIGNTASKTOROLE(args)

Return Values

{"res":
    {
    "func":"AssignTaskToRole",
    "farg":{}}
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex":[{"Exception":false,"msg":"Missing \"RoleId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"Missing \"TaskId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"'5cb15cd9-4078-4c9b-9601-6bfbe73cf14eg' is not valid guid"}]}
or
"connection refused"

UNASSIGNTASKFROMROLE

UNASSIGNTASKFROMROLE removes the assignment of the task from a user role (V13 method).

Parameters

args

Lua table containing the following parameters.

.TaskId

BusinessId of the task

.RoleId

BusinessId of the role

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.TaskId = "75ebfde4-8d35-4fc1-bffe-303fd302f6e0"
args.RoleId = "162e50f6-e786-416b-aaba-0d8fc489ca9e"

local result, exception = lib:UNASSIGNTASKFROMROLE(args)

Return Values

{"res":
    {
    "func":"UnassignTaskFromRole",
    "farg":{}}
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex":[{"Exception":false,"msg":"Missing \"RoleId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"Missing \"TaskId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"The creator of this fault did not specify a Reason."}]}
or
{"ex":[{"Exception":false,"msg":"'5cb15cd9-4078-4c9b-9601-6bfbe73cf14eg' is not valid guid"}]}
or
"connection refused"

GETTASKSTATE

GETTASKSTATE returns the state of the task with the given unique identifier (V13 method).

Parameters

args

Lua table containing the following parameters.

.TaskId

BusinessId of the task

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.TaskId = "75ebfde4-8d35-4fc1-bffe-303fd302f6e0"

local result, exception = lib:GETTASKSTATE(args)

Return Values

{"res":
    {
    "func":"GetTaskState",
    ""farg":{"State":"Created","StateComment":"","TaskId":"75ebfde4-8d35-4fc1-bffe-303fd302f6e0"}
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex":[{"Exception":false,"msg":"Missing \"TaskId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"'5cb15cd9-4078-4c9b-9601-6bfbe73cf14eg' is not valid guid"}]}
or
"connection refused"

GETTASKSTATECHANGE

GETTASKSTATECHANGE returns the state of the task with the given unique identifier (V13 method).

Parameters

args

Lua table containing the following parameters.

.TaskId

BusinessId of the task

.Timeout

Timeout in milliseconds.Indicates the maximum waiting time before the method returns.Maximum value: 600000 milliseconds (10 minutes).

.StateId

Unique identifier of the state, received from a previous call to GETTASKSTATECHANGE (may be nil for the first call).

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.TaskId = "75ebfde4-8d35-4fc1-bffe-303fd302f6e0"
args.Timeout = 3000
args.LastStateId =  "74284ef3-0c35-b434-4972-9383802a5bbb"

local result, exception = lib:GETTASKSTATECHANGE(args)

Return Values

{"res":
    {
    "func":"GetTaskStateChange",
    ""farg":{"StateChange":{"State":"Created","TaskId":"75ebfde4-8d35-4fc1-bffe-303fd302f6e0","StateComment":""},"StateId":"b78Bcdd2-ec7a-4e86-a7be-0090062adb30}","HasChange":true}
    }
}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
{"ex":[{"Exception":false,"msg":"Missing \"TaskId\" property of the JSON object."}]}
or
{"ex":[{"Exception":false,"msg":"'5cb15cd9-4078-4c9b-9601-6bfbe73cf14eg' is not valid guid"}]}
or
"connection refused"

CREATETASKFROMPRODUCT

CREATETASKFROMPRODUCT creates a task based on the product and method.

Parameters

args

Lua table containing the following parameters.

.UserDefinedTaskId (optional)

User defined task Id (visible as "Name" on the LabX task listing)

.PriorityTask

Defines if it is priority task

.MethodBusinessId

BusinessId of the method

.ProductBusinessId

BusinessId of the product

.MethodParameters (optional)

Array of method parameters

.SampleParameters (optional)

Array of sample parameters

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.MethodBusinessId = "2e71a556-957d-4ef2-99a2-a0f254c5aaa7"
args.UserDefinedTaskId = "My Test task 2"
args.PriorityTask = false
args.ProductBusinessId = "e28c47e7-6060-4f49-8b47-475ba816388f"
args.SampleParameters = {}
args.SampleParameters[2] = {}

args.SampleParameters[2].MethodParameters = {}
args.SampleParameters[2].MethodParameters[1] = {}
args.SampleParameters[2].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.SampleParameters[2].MethodParameters[1].MethodFunctionPropertyValue = "12.5"
args.SampleParameters[2].MethodParameters[1].MethodFunctionName = "CalculateWeight"
args.SampleParameters[2].MethodParameters[1].MethodFunctionPropertyName = "value"
args.SampleParameters[2].MethodParameters[2] = {}
args.SampleParameters[2].MethodParameters[2].MethodFunctionPropertyType = "String"
args.SampleParameters[2].MethodParameters[2].MethodFunctionPropertyValue = "Weigh a sample"
args.SampleParameters[2].MethodParameters[2].MethodFunctionName = "Weight1"
args.SampleParameters[2].MethodParameters[2].MethodFunctionPropertyName = "instruction"

args.SampleParameters[2].SampleId = {}
args.SampleParameters[2].SampleId.SampleId1 = "B"
args.SampleParameters[2].SampleId.SampleId2 = ""
args.SampleParameters[2].SampleId.SampleId3 = ""
args.SampleParameters[2].SampleId.SampleId4 = ""
args.SampleParameters[2].SampleId.SampleId5 = ""
args.SampleParameters[2].SampleId.SampleId6 = ""
args.SampleParameters[2].SampleScopeName = "Samplescope1"
args.SampleParameters[2].ProductId = "e3429820-fb16-4dc6-8de1-921ded0cc229"
args.SampleParameters[2].SampleChangerPosition = {}
-- this value may be "Undefined", "Absolute", "Relative", "DetectSample"
args.SampleParameters[2].SampleChangerPosition.ChangerPositionOrigin = "Absolute"
args.SampleParameters[2].SampleChangerPosition.Position = 3

args.SampleParameters[1] = {}

args.SampleParameters[1].MethodParameters = {}
args.SampleParameters[1].MethodParameters[1] = {}
args.SampleParameters[1].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.SampleParameters[1].MethodParameters[1].MethodFunctionPropertyValue = "1.5"
args.SampleParameters[1].MethodParameters[1].MethodFunctionName = "CalculateWeight"
args.SampleParameters[1].MethodParameters[1].MethodFunctionPropertyName = "value"
args.SampleParameters[1].MethodParameters[2] = {}
args.SampleParameters[1].MethodParameters[2].MethodFunctionPropertyType = "String"
args.SampleParameters[1].MethodParameters[2].MethodFunctionPropertyValue = "Weigh a next sample"
args.SampleParameters[1].MethodParameters[2].MethodFunctionName = "Weight1"
args.SampleParameters[1].MethodParameters[2].MethodFunctionPropertyName = "instruction"

args.SampleParameters[1].SampleId = {}
args.SampleParameters[1].SampleId.SampleId1 = "A"
args.SampleParameters[1].SampleId.SampleId2 = ""
args.SampleParameters[1].SampleId.SampleId3 = ""
args.SampleParameters[1].SampleId.SampleId4 = ""
args.SampleParameters[1].SampleId.SampleId5 = ""
args.SampleParameters[1].SampleId.SampleId6 = ""
args.SampleParameters[1].SampleScopeName = "Samplescope1"
args.SampleParameters[1].ProductId = "e28c47e7-6060-4f49-8b47-475ba816388f"
args.SampleParameters[1].SampleChangerPosition = {}
-- this value may be "Undefined", "Absolute", "Relative", "DetectSample"
args.SampleParameters[1].SampleChangerPosition.ChangerPositionOrigin = "Absolute"
args.SampleParameters[1].SampleChangerPosition.Position = 4

args.MethodParameters = {}
args.MethodParameters[1] = {}
args.MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.MethodParameters[1].MethodFunctionPropertyValue = "10.5"
args.MethodParameters[1].MethodFunctionName = "Calculate"
args.MethodParameters[1].MethodFunctionPropertyName = "value"
args.MethodParameters[2] = {}
args.MethodParameters[2].MethodFunctionPropertyType = "Bool"
args.MethodParameters[2].MethodFunctionPropertyValue = true
args.MethodParameters[2].MethodFunctionName = "SetVisibility"
args.MethodParameters[2].MethodFunctionPropertyName = "visible"
args.MethodParameters[3] = {}
args.MethodParameters[3].MethodFunctionPropertyType = "DateTime"
args.MethodParameters[3].MethodFunctionPropertyValue = "2024-03-22T14:10:00"
args.MethodParameters[3].MethodFunctionName = "SetStart"
args.MethodParameters[3].MethodFunctionPropertyName = "startTime"
args.MethodParameters[4] = {}
args.MethodParameters[4].MethodFunctionPropertyType = "Enumeration"
args.MethodParameters[4].MethodFunctionPropertyValue = "A"
args.MethodParameters[4].MethodFunctionName = "SetType"
args.MethodParameters[4].MethodFunctionPropertyName = "type"
args.MethodParameters[5] = {}
args.MethodParameters[5].MethodFunctionPropertyType = "Integer"
args.MethodParameters[5].MethodFunctionPropertyValue = "15"
args.MethodParameters[5].MethodFunctionName = "SetValue"
args.MethodParameters[5].MethodFunctionPropertyName = "value"
args.MethodParameters[6] = {}
args.MethodParameters[6].MethodFunctionPropertyType = "String"
args.MethodParameters[6].MethodFunctionPropertyValue = "Test1"
args.MethodParameters[6].MethodFunctionName = "SetText"
args.MethodParameters[6].MethodFunctionPropertyName = "text1"
args.MethodParameters[7] = {}
args.MethodParameters[7].MethodFunctionPropertyType = "String"
args.MethodParameters[7].MethodFunctionPropertyValue = "Test2"
args.MethodParameters[7].MethodFunctionName = "SetText"
args.MethodParameters[7].MethodFunctionPropertyName = "text2"

local result, exception = lib:CREATETASKFROMPRODUCT(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"farg":{"TaskId":"7140b75f-8f73-43e8-a401-718fc4d88993"},"func":"CreateTaskFromProduct"}}

Exceptions

{"ex":[{"Exception":true,"msg":"ProductNotExistFault: Product with id e28c47e7-6060-4f49-8b47-475ba8163881 does not exist"}]}
or
{"ex":[{"msg":"MethodNotExistFault: Method with id 2e71a556-957d-4ef2-99a2-a0f254c5aaa8 does not exist","Exception":true}]}
or

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

CREATETASKFROMSERIES

CREATETASKFROMSERIES creates a task based on the series.

Parameters

args

Lua table containing the following parameters.

.UserDefinedTaskId (optional)

User defined task Id (visible as "Name" on the LabX task listing)

.PriorityTask

Defines if it is priority task

.MethodBusinessId

BusinessId of the method

.SeriesBusinessId

BusinessId of the series

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.UserDefinedTaskId = "My Test task 2"
args.SeriesBusinessId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
args.PriorityTask = false
local result, exception = lib:CREATETASKFROMSERIES(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"CreateTaskFromSeries","farg":{"TaskId":"304ac820-537c-4787-b869-f2c46ace40e6"}}}

Exceptions

{"ex":[{"Exception":true,"msg":"SampleSerieNotExistFault: Sample series with id 5cb15cd9-4078-4c9b-9601-6bfbe73cf141 does not exist"}]}
or
{"ex":[{"Exception":false,"msg":"'5cb15cd9-4078-4c9b-9601-6bfbe73cf14eg' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

CREATETASKFROMINSTANTSERIES

CREATETASKFROMINSTANTSERIES creates a task based on the defined series parameters.

Parameters

args

Lua table containing the following parameters.

.UserDefinedTaskId (optional)

User defined task Id (visible as "Name" on the LabX task listing)

.PriorityTask

Defines if it is priority task

.MethodBusinessId

BusinessId of the method

.Name

Name of the sample series

.Comment (optional)

Comment

.MethodParameters (optional)

Array of method parameters

.PredefinedSamples

Array of predefined sample parameters

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.MethodBusinessId = "2e71a556-957d-4ef2-99a2-a0f254c5aaa7"
args.UserDefinedTaskId = "My Test task 2"
args.Name = "My sample series"
args.Comment = ""
args.PriorityTask = false
args.PredefinedSamples = {}
args.PredefinedSamples[2] = {}

args.PredefinedSamples[2].MethodParameters = {}
args.PredefinedSamples[2].MethodParameters[1] = {}
args.PredefinedSamples[2].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.PredefinedSamples[2].MethodParameters[1].MethodFunctionPropertyValue = "12.5"
args.PredefinedSamples[2].MethodParameters[1].MethodFunctionName = "CalculateWeight"
args.PredefinedSamples[2].MethodParameters[1].MethodFunctionPropertyName = "value"
args.PredefinedSamples[2].MethodParameters[2] = {}
args.PredefinedSamples[2].MethodParameters[2].MethodFunctionPropertyType = "String"
args.PredefinedSamples[2].MethodParameters[2].MethodFunctionPropertyValue = "Weigh a sample"
args.PredefinedSamples[2].MethodParameters[2].MethodFunctionName = "Weight1"
args.PredefinedSamples[2].MethodParameters[2].MethodFunctionPropertyName = "instruction"

args.PredefinedSamples[2].SampleId = {}
args.PredefinedSamples[2].SampleId.SampleId1 = "B"
args.PredefinedSamples[2].SampleId.SampleId2 = ""
args.PredefinedSamples[2].SampleId.SampleId3 = ""
args.PredefinedSamples[2].SampleId.SampleId4 = ""
args.PredefinedSamples[2].SampleId.SampleId5 = ""
args.PredefinedSamples[2].SampleId.SampleId6 = ""
args.PredefinedSamples[2].SampleScopeName = "Samplescope1"
args.PredefinedSamples[2].ProductId = "e28c47e7-6060-4f49-8b47-475ba816388f"
args.PredefinedSamples[2].SampleChangerPosition = {}
-- this value may be "Undefined", "Absolute", "Relative", "DetectSample"
args.PredefinedSamples[2].SampleChangerPosition.ChangerPositionOrigin = "Absolute"
args.PredefinedSamples[2].SampleChangerPosition.Position = 3

args.PredefinedSamples[1] = {}

args.PredefinedSamples[1].MethodParameters = {}
args.PredefinedSamples[1].MethodParameters[1] = {}
args.PredefinedSamples[1].MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.PredefinedSamples[1].MethodParameters[1].MethodFunctionPropertyValue = "1.5"
args.PredefinedSamples[1].MethodParameters[1].MethodFunctionName = "CalculateWeight"
args.PredefinedSamples[1].MethodParameters[1].MethodFunctionPropertyName = "value"
args.PredefinedSamples[1].MethodParameters[2] = {}
args.PredefinedSamples[1].MethodParameters[2].MethodFunctionPropertyType = "String"
args.PredefinedSamples[1].MethodParameters[2].MethodFunctionPropertyValue = "Weigh a next sample"
args.PredefinedSamples[1].MethodParameters[2].MethodFunctionName = "Weight1"
args.PredefinedSamples[1].MethodParameters[2].MethodFunctionPropertyName = "instruction"

args.PredefinedSamples[1].SampleId = {}
args.PredefinedSamples[1].SampleId.SampleId1 = "A"
args.PredefinedSamples[1].SampleId.SampleId2 = ""
args.PredefinedSamples[1].SampleId.SampleId3 = ""
args.PredefinedSamples[1].SampleId.SampleId4 = ""
args.PredefinedSamples[1].SampleId.SampleId5 = ""
args.PredefinedSamples[1].SampleId.SampleId6 = ""
args.PredefinedSamples[1].SampleScopeName = "Samplescope1"
args.PredefinedSamples[1].ProductId = "e28c47e7-6060-4f49-8b47-475ba816388f"
args.PredefinedSamples[1].SampleChangerPosition = {}
-- this value may be "Undefined", "Absolute", "Relative", "DetectSample"
args.PredefinedSamples[1].SampleChangerPosition.ChangerPositionOrigin = "Absolute"
args.PredefinedSamples[1].SampleChangerPosition.Position = 4

args.MethodParameters = {}
args.MethodParameters[1] = {}
args.MethodParameters[1].MethodFunctionPropertyType = "Decimal"
args.MethodParameters[1].MethodFunctionPropertyValue = "10.5"
args.MethodParameters[1].MethodFunctionName = "Calculate"
args.MethodParameters[1].MethodFunctionPropertyName = "value"
args.MethodParameters[2] = {}
args.MethodParameters[2].MethodFunctionPropertyType = "Bool"
args.MethodParameters[2].MethodFunctionPropertyValue = true
args.MethodParameters[2].MethodFunctionName = "SetVisibility"
args.MethodParameters[2].MethodFunctionPropertyName = "visible"
args.MethodParameters[3] = {}
args.MethodParameters[3].MethodFunctionPropertyType = "DateTime"
args.MethodParameters[3].MethodFunctionPropertyValue = "2024-03-22T14:10:00"
args.MethodParameters[3].MethodFunctionName = "SetStart"
args.MethodParameters[3].MethodFunctionPropertyName = "startTime"
args.MethodParameters[4] = {}
args.MethodParameters[4].MethodFunctionPropertyType = "Enumeration"
args.MethodParameters[4].MethodFunctionPropertyValue = "A"
args.MethodParameters[4].MethodFunctionName = "SetType"
args.MethodParameters[4].MethodFunctionPropertyName = "type"
args.MethodParameters[5] = {}
args.MethodParameters[5].MethodFunctionPropertyType = "Integer"
args.MethodParameters[5].MethodFunctionPropertyValue = "15"
args.MethodParameters[5].MethodFunctionName = "SetValue"
args.MethodParameters[5].MethodFunctionPropertyName = "value"
args.MethodParameters[6] = {}
args.MethodParameters[6].MethodFunctionPropertyType = "String"
args.MethodParameters[6].MethodFunctionPropertyValue = "Test1"
args.MethodParameters[6].MethodFunctionName = "SetText"
args.MethodParameters[6].MethodFunctionPropertyName = "text1"
args.MethodParameters[7] = {}
args.MethodParameters[7].MethodFunctionPropertyType = "String"
args.MethodParameters[7].MethodFunctionPropertyValue = "Test2"
args.MethodParameters[7].MethodFunctionName = "SetText"
args.MethodParameters[7].MethodFunctionPropertyName = "text2"

local result, exception = lib:CREATETASKFROMINSTANTSERIES(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"farg":{"TaskId":"7140b75f-8f73-43e8-a401-718fc4d88993"},"func":"CreateTaskFromInstantSeries"}}

Exceptions

{"ex":[{"msg":"MethodNotExistFault: Method with id 2e71a556-957d-4ef2-99a2-a0f254c5aaa8 does not exist","Exception":true}]}
or

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

ASSIGNTASKTOINSTRUMENT

ASSIGNTASKTOINSTRUMENT assigns a created task to a specific instrument or instrument type.

Parameters

args

Lua table containing the following parameters.

.InstrumentId

InstrumentId of the instrument

.TaskId

TaskId of the task

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.InstrumentId = "1d8ac640-e155-44f6-8341-8090068ceae5"
args.TaskId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:ASSIGNTASKTOINSTRUMENT(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"farg":{},"func":"AssignTaskToInstrument"}}

Exceptions

{"ex":[{"msg":"InstrumentNotExistFault: Cannot find instrument with id 1d8ac640-e155-44f6-8341-8090068ceae4","Exception":true}]}
or
{"ex":[{"msg":"TaskNotExistFault: Exception of type 'MT.Sequoia.Platform.Common.ErrorHandling.TaskNotExistException' was thrown.","Exception":true}]}
or
{"ex":[{"Exception":false,"msg":"'e28c47e7-6060-4f49-8b47-475ba816388f' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

ASSIGNTASKTOUSER

ASSIGNTASKTOUSER assigns a created task to a specific user.

Parameters

args

Lua table containing the following parameters.

.LogOnName

Account name

.TaskId

TaskId of the task

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.LogOnName = "PredefinedUser"
args.TaskId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:ASSIGNTASKTOUSER(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"farg":{},"func":"AssignTaskToUser"}}

Exceptions

{"ex":[{"Exception":true,"msg":"UserManagementFault: The logon name is incorrect"}]}
or
{"ex":[{"msg":"TaskNotExistFault: Exception of type 'MT.Sequoia.Platform.Common.ErrorHandling.TaskNotExistException' was thrown.","Exception":true}]}
or
{"ex":[{"Exception":false,"msg":"'e28c47e7-6060-4f49-8b47-475ba816388f' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

STARTTASK

STARTTASK starts a task.

Parameters

args

Lua table containing the following parameters.

.TaskId

TaskId of the task

.InstrumentId

InstrumentId of the instrument

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.InstrumentId = "1d8ac640-e155-44f6-8341-8090068ceae5"
args.TaskId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:STARTTASK(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"StartTask","farg":{}}}

Exceptions

{"ex":[{"Exception":true,"msg":"InstrumentNotExistFault: Instrument with id 1d8ac640-e155-44f6-8341-8090068ceae1 does not exist"}]}
or
{"ex":[{"msg":"TaskNotExistFault: Exception of type 'MT.Sequoia.Platform.Common.ErrorHandling.TaskNotExistException' was thrown.","Exception":true}]}
or
{"ex":[{"Exception":false,"msg":"'e28c47e7-6060-4f49-8b47-475ba816388f' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

STARTTASKATWORKSPACE

STARTTASKATWORKSPACE starts a task.

Parameters

args

Lua table containing the following parameters.

.TaskId

TaskId of the task

.InstrumentId

InstrumentId of the instrument

.WorkspaceName

The name of a workspace

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.InstrumentId = "1d8ac640-e155-44f6-8341-8090068ceae5"
args.TaskId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
args.WorkspaceName = "WorkspaceB"
local result, exception = lib:STARTTASKATWORKSPACE(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"StartTask","farg":{}}}

Exceptions

{"ex":[{"Exception":true,"msg":"InstrumentNotExistFault: Instrument with id 1d8ac640-e155-44f6-8341-8090068ceae1 does not exist"}]}
or
{"ex":[{"msg":"TaskNotExistFault: Exception of type 'MT.Sequoia.Platform.Common.ErrorHandling.TaskNotExistException' was thrown.","Exception":true}]}
or
{"ex":[{"Exception":false,"msg":"'e28c47e7-6060-4f49-8b47-475ba816388f' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

ABORTTASK

ABORTTASK aborts a running task.

Parameters

args

Lua table containing the following parameters.

.TaskId

TaskId of the task

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.TaskId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:ABORTTASK(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"farg":{},"func":"AbortTask"}}

Exceptions

{"ex":[{"msg":"TaskStateInvalidFault: Operation on task cannot be performed on current task state: Stopped","Exception":true}]}
or
{"ex":[{"msg":"TaskNotExistFault: Exception of type 'MT.Sequoia.Platform.Common.ErrorHandling.TaskNotExistException' was thrown.","Exception":true}]}
or
{"ex":[{"Exception":false,"msg":"'e28c47e7-6060-4f49-8b47-475ba816388f' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

PAUSETASK

PAUSETASK aborts a running task.

Parameters

args

Lua table containing the following parameters.

.TaskId

TaskId of the task

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.TaskId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:PAUSETASK(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"farg":{},"func":"PauseTask"}}

Exceptions

{"ex":[{"msg":"TaskStateInvalidFault: Operation on task cannot be performed on current task state: Created","Exception":true}]}
or
{"ex":[{"msg":"TaskStateInvalidFault: Operation on task cannot be performed on current task state: Stopped","Exception":true}]}
or
{"ex":[{"msg":"TaskNotExistFault: Exception of type 'MT.Sequoia.Platform.Common.ErrorHandling.TaskNotExistException' was thrown.","Exception":true}]}
or
{"ex":[{"Exception":false,"msg":"'e28c47e7-6060-4f49-8b47-475ba816388f' is not valid guid"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

SUBSCRIBE

SUBSCRIBE creates subscription for LabX notifications.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local result, exception = lib:SUBSCRIBE()
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"Subscribe","farg":{"SubscriptionHandle":"c0960b2d-3e67-4177-8da4-66edd5b06091"}}}

Exceptions

{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

UNSUBSCRIBE

UNSUBSCRIBE removes subscription for LabX notifications.

Parameters

args

Lua table containing the following parameters.

.SubscriptionHandle

Handle of the subscription created by SUBSCRIBE() method

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local result, exception = lib:SUBSCRIBE()
local subscriptionHandle = result.farg.SubscriptionHandle

local args = {}
args.SubscriptionHandle = subscriptionHandle

result, exception = lib:UNSUBSCRIBE(args)

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"UnSubscribe","farg":{}}}

Exceptions

{"ex":[{"Exception":false,"msg":"Invalid handle."}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

REGISTERINSTRUMENTSTATENOTIFICATIONS

REGISTERINSTRUMENTSTATENOTIFICATIONS registers for getting instrument state change notifications for an particular instrument or for all instruments.

Parameters

args

Lua table containing the following parameters.

.SubscriptionHandle

Handle of the subscription created by SUBSCRIBE() method

.InstrumentId (optional)

InstrumentId of the instrument for which the notification will be sent. Set it to nil to get instrument state notifications for all instruments

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local result, exception = lib:SUBSCRIBE()
local subscriptionHandle = result.farg.SubscriptionHandle

local args = {}
args.SubscriptionHandle = subscriptionHandle
args.InstrumentId = nil

result, exception = REGISTERINSTRUMENTSTATENOTIFICATIONS(args)

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"RegisterInstrumentStateNotifications","farg":{}}}

Exceptions

{"ex":[{"Exception":false,"msg":"Invalid handle"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

UNREGISTERINSTRUMENTSTATENOTIFICATIONS

UNREGISTERINSTRUMENTSTATENOTIFICATIONS unregisters from receiving instrument state change notifications. It is not possible to unregister for a single instrument.

Parameters

args

Lua table containing the following parameters.

.SubscriptionHandle

Handle of the subscription created by SUBSCRIBE() method

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local result, exception = lib:SUBSCRIBE()
local subscriptionHandle = result.farg.SubscriptionHandle

local params = {}
params.SubscriptionHandle = subscriptionHandle
params.InstrumentId = nil

REGISTERINSTRUMENTSTATENOTIFICATIONS(params)

local args = {}
args.SubscriptionHandle = subscriptionHandle

result, exception = UNREGISTERINSTRUMENTSTATENOTIFICATIONS(args)

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"UnRegisterInstrumentStateNotifications","farg":{}}}

Exceptions

{"ex":[{"Exception":false,"msg":"Invalid handle"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

REGISTERTASKSTATENOTIFICATIONS

REGISTERTASKSTATENOTIFICATIONS registers for getting task state change and task data stored notifications for an particular task or for all tasks.

Parameters

args

Lua table containing the following parameters.

.SubscriptionHandle

Handle of the subscription created by SUBSCRIBE() method

.TaskId (optional)

TaskId of the task for which the notification will be sent. Set it to nil to get task state notifications for all tasks.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local result, exception = lib:SUBSCRIBE()
local subscriptionHandle = result.farg.SubscriptionHandle

local args = {}
args.SubscriptionHandle = subscriptionHandle
args.TaskId = nil

result, exception = REGISTERTASKSTATENOTIFICATIONS(args)

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"RegisterTaskStateNotifications","farg":{}}}

Exceptions

{"ex":[{"msg":"'1d8ac640-e155-44f6-8341-8090068ceae5d' is not valid guid","Exception":false}]}
or
{"ex":[{"Exception":false,"msg":"Invalid handle"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

UNREGISTERTASKSTATENOTIFICATIONS

UNREGISTERTASKSTATENOTIFICATIONS unregisters from receiving task state change notifications and task data stored notifications. It is not possible to unregister for a single task.

Parameters

args

Lua table containing the following parameters.

.SubscriptionHandle

Handle of the subscription created by SUBSCRIBE() method

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local result, exception = lib:SUBSCRIBE()
local subscriptionHandle = result.farg.SubscriptionHandle

local params = {}
params.SubscriptionHandle = subscriptionHandle
params.TaskId = nil

result, exception = REGISTERTASKSTATENOTIFICATIONS(params)

local args = {}
args.SubscriptionHandle = subscriptionHandle
result, exception = UNREGISTERTASKSTATENOTIFICATIONS(args)

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{"res":{"func":"UnRegisterTaskStateNotifications","farg":{}}}

Exceptions

{"ex":[{"msg":"'1d8ac640-e155-44f6-8341-8090068ceae5d' is not valid guid","Exception":false}]}
or
{"ex":[{"Exception":false,"msg":"Invalid handle"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETNOTIFICATIONS

GETNOTIFICATIONS returns notifications collected since the last call of GETNOTIFICATIONS() method.

Parameters

args

Lua table containing the following parameters.

.SubscriptionHandle

Handle of the subscription created by SUBSCRIBE() method

Usage

local lib = require("esi-labxbridge")
local socket = require "socket"

lib:SETCONNECTION({})

local result, exception = lib:SUBSCRIBE()
local subscriptionHandle = result.farg.SubscriptionHandle

local params = {}
params.SubscriptionHandle = subscriptionHandle
params.TaskId = nil

REGISTERTASKSTATENOTIFICATIONS(params)

params = {}
params.SubscriptionHandle = subscriptionHandle
params.InstrumentId = nil

REGISTERINSTRUMENTSTATENOTIFICATIONS(params)

-- wait for a while
socket.sleep(120)

local args = {}
args.SubscriptionHandle = subscriptionHandle

result, exception = lib:GETNOTIFICATIONS(args)
if not exception then
	if result.farg.Overflow then
		-- there is the buffer overflow
		-- GETNOTIFICATIONS() should be called more frequently
	end
	-- do something with the result and check if there are more notifications in the buffer
	while result.farg.MoreNotifications do
		result, exception = lib:GETNOTIFICATIONS(args)
		-- do something with the result
	end
end

return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{
    "res": {
        "func": "GetNotifications",
        "farg": {
            "MoreNotifications": false,
            "Notifications": [
                {
                    "Type": "TaskStateChange",
                    "Data": {
                        "CreationTime": "2024-04-10T05:19:47.9",
                        "TaskId": "1b91d72b-65c1-4ab7-aa6e-e61f08951d6f",
                        "AccountName": "PredefinedUser",
                        "TaskState": "Created",
                        "Name": "My Test task 3",
                        "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                        "MethodName": "Simple Weighing (with Result)",
                        "InternalId": "T388"
                    }
                },
                {
                    "Type": "InstrumentStateChange",
                    "Data": {
                        "State": "Connected",
                        "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5"
                    }
                },
                {
                    "Type": "InstrumentStateChange",
                    "Data": {
                        "State": "Ready",
                        "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5"
                    }
                },
                {
                    "Type": "TaskStateChange",
                    "Data": {
                        "CreationTime": "2024-03-19T03:15:40.77",
                        "TaskId": "a2e9f33c-05a7-47a4-8305-08036b0b3191",
                        "AccountName": "PredefinedUser",
                        "TaskState": "Running",
                        "Name": "My Test task 3",
                        "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                        "MethodName": "Simple Weighing (with Result)",
                        "InternalId": "T145"
                    }
                },
                {
                    "Type": "TaskDataStored",
                    "Data": {
                        "TaskId": "a2e9f33c-05a7-47a4-8305-08036b0b3191"
                    }
                }
            ],
            "Overflow": false
        }
    }
}

Exceptions

{"ex":[{"Exception":false,"msg":"Invalid handle"}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETTASKRESULTS

GETTASKRESULTS returns one task result set belonging to the task with the specified task ID (GUID)

Parameters

args

Lua table containing the following parameters.

.TaskId

TaskId of the task

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})
local args = {}
args.TaskId = "f33fd37c-f37d-4dbe-b62d-90c8839b203d"
local result, exception = lib:GETTASKRESULTS(args)
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{ "res": {
        "func": "GetTaskResults",
        "farg": {
            "Samples": [
                {
                    "Results": [
                        {
                            "Instrument": {
                                "AvailableWorkspaces": [
                                    "Default"
                                ],
                                "Product": 1,
                                "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                "IsDeleted": false,
                                "SerialNumber": "1111122222/1111122222",
                                "ProductFamily": "BalanceExcellence",
                                "ExtendedProperties": {},
                                "AvailabilityStatus": "Disconnected",
                                "InstrumentName": "XPE205 Simulator",
                                "InternalId": "I6",
                                "InstrumentModel": "XPE205"
                            },
                            "UserLogonName": "PredefinedUser",
                            "Unit": "g",
                            "UserFullName": "Administrator",
                            "CreationTime": "2024-02-13T03:56:34.45",
                            "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                            "ResultName": "ResultNetWeight",
                            "OverallState":"Ok",
                            "InstrumentName": "XPE205 Simulator",
                            "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                            "Scalar": {
                                "Value": 77.0,
                                "Precision": 5
                            }
                        }
                    ],
                    "SampleStartTime": "2024-02-13T03:51:38.48",
                    "OverallState":"Ok",
                    "SampleId": {
                        "SampleId3": "",
                        "SampleId1": "sample1",
                        "SampleId5": "",
                        "SampleId6": "",
                        "SampleId2": "",
                        "SampleId4": ""
                    }
                },
                {
                    "Results": [
                        {
                            "Instrument": {
                                "AvailableWorkspaces": [
                                    "Default"
                                ],
                                "Product": 1,
                                "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                "IsDeleted": false,
                                "SerialNumber": "1111122222/1111122222",
                                "ProductFamily": "BalanceExcellence",
                                "ExtendedProperties": {},
                                "AvailabilityStatus": "Disconnected",
                                "InstrumentName": "XPE205 Simulator",
                                "InternalId": "I6",
                                "InstrumentModel": "XPE205"
                            },
                            "UserLogonName": "PredefinedUser",
                            "Unit": "g",
                            "UserFullName": "Administrator",
                            "CreationTime": "2024-02-13T03:57:14.84",
                            "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                            "ResultName": "ResultNetWeight",
                            "OverallState":"Ok",
                            "InstrumentName": "XPE205 Simulator",
                            "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                            "Scalar": {
                                "Value": 67.375,
                                "Precision": 5
                            }
                        }
                    ],
                    "SampleStartTime": "2024-02-13T03:56:50.02",
                    "OverallState":"Ok",
                    "SampleId": {
                        "SampleId1": "sample 2",
                        "SampleId2": "",
                        "SampleId3": "",
                        "SampleId4": "",
                        "SampleId5": "",
                        "SampleId6": "",
                    }
                },
                {
                    "Results": [
                        {
                            "Instrument": {
                                "AvailableWorkspaces": [
                                    "Default"
                                ],
                                "Product": 1,
                                "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                "IsDeleted": false,
                                "SerialNumber": "1111122222/1111122222",
                                "ProductFamily": "BalanceExcellence",
                                "ExtendedProperties": {},
                                "AvailabilityStatus": "Disconnected",
                                "InstrumentName": "XPE205 Simulator",
                                "InternalId": "I6",
                                "InstrumentModel": "XPE205"
                            },
                            "UserLogonName": "PredefinedUser",
                            "Unit": "g",
                            "UserFullName": "Administrator",
                            "CreationTime": "2024-02-13T03:58:30.28",
                            "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                            "ResultName": "ResultNetWeight",
                            "OverallState":"Ok",
                            "InstrumentName": "XPE205 Simulator",
                            "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                            "Scalar": {
                                "Value": 35.8375,
                                "Precision": 5
                            }
                        }
                    ],
                    "SampleStartTime": "2024-02-13T03:57:58.9",
                    "OverallState":"Ok",
                    "SampleId": {
                        "SampleId3": "",
                        "SampleId1": "sample 3",
                        "SampleId5": "",
                        "SampleId6": "",
                        "SampleId2": "",
                        "SampleId4": ""
                    }
                }
            ],
            "TaskResults": [],
            "Task": {
                "TaskState": "Completed",
                "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                "CreationTime": "2024-02-13T03:50:54.61",
                "Name": "T14_Simple Weighing (with Result)",
                "MethodName": "Simple Weighing (with Result)",
                "InternalId": "T14",
                "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                "AccountName": "PredefinedUser"
            },
            "IsApproved": false,
            "OverallState":"Ok"
        }
    }
}

Exceptions

{"ex": [{"Exception":false,"msg":"'x33fd37c-f37d-4dbe-b62d-90c8839b203d' is not valid guid"}]}
or
{"ex":[{"Exception":true,"msg":"TaskNotExistFault: Exception of type 'MT.Sequoia.Platform.Common.ErrorHandling.TaskNotExistException' was thrown."}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETTASKRESULTSINRANGE

GETTASKRESULTSINRANGE returns the list with all task result sets in LabX that were created in the range of the specified FromDate and ToDate. The date range must not exceed 3 days per call.

Parameters

args

Lua table containing the following parameters.

.FromDate

Time as string or POSIX time

.ToDate

Time as string or POSIX time

.MaxNumberOfRecords (optional)

Maximal number of records returned. Default value is defined by LabX Bridge Server configuration. If this parameter is not set then default is used.

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.FromDate = "2024-02-13T09:59:59"
args.ToDate = "2024-02-14T23:59:59"
args.MaxNumberOfRecords = 2

local result, exception = lib:GETTASKRESULTSINRANGE(args)
if exception then
	return (require "esi-string"):STRING({ex=exception})
else
	if result.MoreItems then
			local cargs = {}
			cargs.ContinuationKey = result.ContinuationKey
		while true do
			local lresult, exception = lib:GETCONTINUATION(cargs)
			if exception then
				return (require "esi-string"):STRING({ex=exception})
			end

			for ii=1,#lresult.farg do
				result.farg[#result.farg+1] = lresult.farg[ii]
			end

			if  not lresult.MoreItems then
				break
			end
		end
	end
end
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{ "res": {
        "farg": [
            {
                "Samples": [
                    {
                        "Results": [
                            {"TaskId":"f33fd37c-f37d-4dbe-b62d-90c8839b203d","CreationTime": "2024-02-13T04:30:01.41",
                                "Instrument": {
                                    "IsDeleted": false,
                                    "ProductFamily": "BalanceExcellence",
                                    "InternalId": "I6",
                                    "Product": 1,
                                    "SerialNumber": "1111122222/1111122222",
                                    "InstrumentName": "XPE205 Simulator",
                                    "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                    "AvailabilityStatus": "Disconnected",
                                    "ExtendedProperties": {},
                                    "AvailableWorkspaces": [
                                        "Default"
                                    ],
                                    "InstrumentModel": "XPE205"
                                },
                                "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                                "InstrumentName": "XPE205 Simulator",
                                "UserFullName": "Administrator",
                                "ResultName": "Result1",
                                "OverallState":"Ok",
                                "UserLogonName": "PredefinedUser",
                                "Scalar": {
                                    "Value": 55.125,
                                    "Precision": 5
                                },
                                "Unit": "g"
                            }
                        ],
                        "SampleStartTime": "2024-02-13T04:29:51.2",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample7",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [
                            {
                                "TaskId": "f33fd37c-f37d-4dbe-b62d-90c8839b203d",
                                "CreationTime": "2024-02-13T04:30:30.35",
                                "Instrument": {
                                    "IsDeleted": false,
                                    "ProductFamily": "BalanceExcellence",
                                    "InternalId": "I6",
                                    "Product": 1,
                                    "SerialNumber": "1111122222/1111122222",
                                    "InstrumentName": "XPE205 Simulator",
                                    "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                    "AvailabilityStatus": "Disconnected",
                                    "ExtendedProperties": {},
                                    "AvailableWorkspaces": [
                                        "Default"
                                    ],
                                    "InstrumentModel": "XPE205"
                                },
                                "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                                "InstrumentName": "XPE205 Simulator",
                                "UserFullName": "Administrator",
                                "ResultName": "Result1",
                                "OverallState":"Ok",
                                "UserLogonName": "PredefinedUser",
                                "Scalar": {
                                    "Value": 0.0,
                                    "Precision": 5
                                },
                                "Unit": "g"
                            }
                        ],
                        "SampleStartTime": "2024-02-13T04:30:20.19",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample 8",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [
                            {
                                "TaskId": "f33fd37c-f37d-4dbe-b62d-90c8839b203d",
                                "CreationTime": "2024-02-13T04:31:11.06",
                                "Instrument": {
                                    "IsDeleted": false,
                                    "ProductFamily": "BalanceExcellence",
                                    "InternalId": "I6",
                                    "Product": 1,
                                    "SerialNumber": "1111122222/1111122222",
                                    "InstrumentName": "XPE205 Simulator",
                                    "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                    "AvailabilityStatus": "Disconnected",
                                    "ExtendedProperties": {},
                                    "AvailableWorkspaces": [
                                        "Default"
                                    ],
                                    "InstrumentModel": "XPE205"
                                },
                                "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                                "InstrumentName": "XPE205 Simulator",
                                "UserFullName": "Administrator",
                                "ResultName": "Result1",
                                "OverallState":"Ok",
                                "UserLogonName": "PredefinedUser",
                                "Scalar": {
                                    "Value": 0.0,
                                    "Precision": 5
                                },
                                "Unit": "g"
                            }
                        ],
                        "SampleStartTime": "2024-02-13T04:30:37.95",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample 9",
                            "SampleId6": ""
                        }
                    }
                ],
                "IsApproved": false,
                "Task": {
                    "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                    "Name": "Sample scope only",
                    "CreationTime": "2024-02-13T04:29:28.89",
                    "TaskState": "Waiting",
                    "TaskId": "f33fd37c-f37d-4dbe-b62d-90c8839b203d",
                    "MethodName": "Sample scope only",
                    "AccountName": "PredefinedUser",
                    "InternalId": "T16"
                },
                "TaskResults": [],
                "OverallState":"Ok"
            },
            {
                "Samples": [],
                "IsApproved": false,
                "OverallState":"Ok",
                "Task": {
                    "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                    "Name": "Sample scope only",
                    "CreationTime": "2024-02-13T04:01:52.4",
                    "TaskState": "Created",
                    "TaskId": "01456f1f-ea45-4630-9af5-94709ef9c1f9",
                    "MethodName": "Sample scope only",
                    "AccountName": "PredefinedUser",
                    "InternalId": "T15"
                },
                "TaskResults": []
            },
            {
                "Samples": [
                    {
                        "Results": [
                            {
                                "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                                "CreationTime": "2024-02-13T03:56:34.45",
                                "Instrument": {
                                    "IsDeleted": false,
                                    "ProductFamily": "BalanceExcellence",
                                    "InternalId": "I6",
                                    "Product": 1,
                                    "SerialNumber": "1111122222/1111122222",
                                    "InstrumentName": "XPE205 Simulator",
                                    "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                    "AvailabilityStatus": "Disconnected",
                                    "ExtendedProperties": {},
                                    "AvailableWorkspaces": [
                                        "Default"
                                    ],
                                    "InstrumentModel": "XPE205"
                                },
                                "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                                "InstrumentName": "XPE205 Simulator",
                                "UserFullName": "Administrator",
                                "ResultName": "ResultNetWeight",
                                "OverallState":"Ok",
                                "UserLogonName": "PredefinedUser",
                                "Scalar": {
                                    "Value": 77.0,
                                    "Precision": 5
                                },
                                "Unit": "g"
                            }
                        ],
                        "SampleStartTime": "2024-02-13T03:51:38.48",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample1",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [
                            {
                                "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                                "CreationTime": "2024-02-13T03:57:14.84",
                                "Instrument": {
                                    "IsDeleted": false,
                                    "ProductFamily": "BalanceExcellence",
                                    "InternalId": "I6",
                                    "Product": 1,
                                    "SerialNumber": "1111122222/1111122222",
                                    "InstrumentName": "XPE205 Simulator",
                                    "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                    "AvailabilityStatus": "Disconnected",
                                    "ExtendedProperties": {},
                                    "AvailableWorkspaces": [
                                        "Default"
                                    ],
                                    "InstrumentModel": "XPE205"
                                },
                                "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                                "InstrumentName": "XPE205 Simulator",
                                "UserFullName": "Administrator",
                                "ResultName": "ResultNetWeight",
                                "OverallState":"Ok",
                                "UserLogonName": "PredefinedUser",
                                "Scalar": {
                                    "Value": 67.375,
                                    "Precision": 5
                                },
                                "Unit": "g"
                            }
                        ],
                        "SampleStartTime": "2024-02-13T03:56:50.02",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample 2",
                            "SampleId6": ""
                        }
                    },
                ],
                "IsApproved": false,
                "OverallState":"Ok",
                "Task": {
                    "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                    "Name": "T14_Simple Weighing (with Result)",
                    "CreationTime": "2024-02-13T03:50:54.61",
                    "TaskState": "Completed",
                    "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                    "MethodName": "Simple Weighing (with Result)",
                    "AccountName": "PredefinedUser",
                    "InternalId": "T14"
                },
                "TaskResults": []
            },
            {
                "Samples": [],
                "IsApproved": false,
                "OverallState":"Ok",
                "Task": {
                    "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                    "Name": "Weighing (Result)",
                    "CreationTime": "2024-02-13T03:18:48.44",
                    "TaskState": "Aborted",
                    "TaskId": "b8ac912e-5b3d-47fa-bc48-7a4c75d0a783",
                    "MethodName": "Simple Weighing (with Result)",
                    "AccountName": "PredefinedUser",
                    "InternalId": "T13"
                },
                "TaskResults": []
            },
            {
                "Samples": [
                    {
                        "Results": [],
                        "SampleStartTime": "2024-02-13T03:25:22.76",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "Sample XXX",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [],
                        "SampleStartTime": "2024-02-13T03:26:52.32",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "Sample YYY",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [],
                        "SampleStartTime": "2024-02-13T03:34:30.89",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "Sample AAA",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [],
                        "SampleStartTime": "2024-02-13T04:02:37.9",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample 4",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [],
                        "SampleStartTime": "2024-02-13T04:02:50.55",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample 5",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [],
                        "SampleStartTime": "2024-02-13T04:04:50.59",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample 6",
                            "SampleId6": ""
                        }
                    },
                    {
                        "Results": [],
                        "SampleStartTime": "2024-02-13T04:05:38.83",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "sample 7",
                            "SampleId6": ""
                        }
                    }
                ],
                "IsApproved": false,
                "OverallState":"Ok",
                "Task": {
                    "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                    "Name": "Sample scope only",
                    "CreationTime": "2024-02-13T03:17:43.87",
                    "TaskState": "Paused",
                    "TaskId": "eaaf5ad1-dc97-40fc-bbb6-3538e6713538",
                    "MethodName": "Sample scope only",
                    "AccountName": "PredefinedUser",
                    "InternalId": "T12"
                },
                "TaskResults": []
            },
            {
                "Samples": [
                    {
                        "Results": [
                            {
                                "TaskId": "c78d363e-8efc-4eeb-8ad6-e4c01009bec4",
                                "CreationTime": "2024-02-13T02:58:25.34",
                                "Instrument": {
                                    "IsDeleted": false,
                                    "ProductFamily": "BalanceExcellence",
                                    "InternalId": "I6",
                                    "Product": 1,
                                    "SerialNumber": "1111122222/1111122222",
                                    "InstrumentName": "XPE205 Simulator",
                                    "InstrumentId": "1d8ac640-e155-44f6-8341-8090068ceae5",
                                    "AvailabilityStatus": "Disconnected",
                                    "ExtendedProperties": {},
                                    "AvailableWorkspaces": [
                                        "Default"
                                    ],
                                    "InstrumentModel": "XPE205"
                                },
                                "InstrumentVersionId": "a7ef3bb0-d5fc-463b-9eaa-a04809b90774",
                                "InstrumentName": "XPE205 Simulator",
                                "UserFullName": "Administrator",
                                "ResultName": "ResultNetWeight",
                                "OverallState":"Ok",
                                "UserLogonName": "PredefinedUser",
                                "Scalar": {
                                    "Value": 16.3421,
                                    "Precision": 5
                                },
                                "Unit": "g"
                            }
                        ],
                        "SampleStartTime": "2024-02-13T02:57:17.72",
                        "OverallState":"Ok",
                        "SampleId": {
                            "SampleId4": "",
                            "SampleId2": "",
                            "SampleId3": "",
                            "SampleId5": "",
                            "SampleId1": "4711id",
                            "SampleId6": ""
                        }
                    }
                ],
                "IsApproved": false,
                "OverallState":"Ok",
                "Task": {
                    "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                    "Name": "T11_Simple Weighing (with Result)",
                    "CreationTime": "2024-02-13T02:56:18.66",
                    "TaskState": "Completed",
                    "TaskId": "c78d363e-8efc-4eeb-8ad6-e4c01009bec4",
                    "MethodName": "Simple Weighing (with Result)",
                    "AccountName": "PredefinedUser",
                    "InternalId": "T11"
                },
                "TaskResults": []
            }
        ],
        "MoreItems": false,
        "func": "GetTaskResultsInRange"
    }
}

Exceptions

{"ex": [{"msg":"Date range not correct.","Exception":false}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"

GETCONTINUATION

GETCONTINUATION returns the list with continuation of records.

Parameters

args

Lua table containing the following parameter.

.ContinuationKey

A continuation key

Usage

local lib = require("esi-labxbridge")

lib:SETCONNECTION({})

local args = {}
args.FromDate = "2024-02-13T09:59:59"
args.ToDate = "2024-02-14T23:59:59"
args.MaxNumberOfRecords = 2

local result, exception = lib:GETALLTASKSINRANGE(args)
if exception then
	return (require "esi-string"):STRING({ex=exception})
else
	if result.MoreItems then
			local cargs = {}
			cargs.ContinuationKey = result.ContinuationKey
		while true do
			local lresult, exception = lib:GETCONTINUATION(cargs)
			if exception then
				return (require "esi-string"):STRING({ex=exception})
			end

			for ii=1,#lresult.farg do
				result.farg[#result.farg+1] = lresult.farg[ii]
			end

			if  not lresult.MoreItems then
				break
			end
		end
	end
end
return (require "esi-string"):STRING({res=result,ex=exception})

Return Values

{ "res": {
        "MoreItems": true,
        "ContinuationKey": "029f6d1d-d766-4b0c-9aec-cd11ad20e615",
        "func": "GetAllTasksInRange",
        "farg": [
            {
                "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                "TaskState": "Paused",
                "TaskId": "f33fd37c-f37d-4dbe-b62d-90c8839b203d",
                "MethodName": "Sample scope only",
                "InternalId": "T16",
                "AccountName": "PredefinedUser",
                "Name": "Sample scope only",
                "CreationTime": "2024-02-13T04:29:28.89"
            },
            {
                "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                "TaskState": "Created",
                "TaskId": "01456f1f-ea45-4630-9af5-94709ef9c1f9",
                "MethodName": "Sample scope only",
                "InternalId": "T15",
                "AccountName": "PredefinedUser",
                "Name": "Sample scope only",
                "CreationTime": "2024-02-13T04:01:52.4"
            },
            {
                "MethodBusinessId": "2e71a556-957d-4ef2-99a2-a0f254c5aaa7",
                "TaskState": "Completed",
                "TaskId": "9d2443fb-78ee-4276-994c-c1598c1ab6b0",
                "MethodName": "Simple Weighing (with Result)",
                "InternalId": "T14",
                "AccountName": "PredefinedUser",
                "Name": "T14_Simple Weighing (with Result)",
                "CreationTime": "2024-02-13T03:50:54.61"
            },
            {
                "MethodBusinessId": "3dae4bfa-814e-4101-88e3-f38d7c821b6c",
                "TaskState": "Paused",
                "TaskId": "eaaf5ad1-dc97-40fc-bbb6-3538e6713538",
                "MethodName": "Sample scope only",
                "InternalId": "T12",
                "AccountName": "PredefinedUser",
                "Name": "Sample scope only",
                "CreationTime": "2024-02-13T03:17:43.87"
            }
        ]
    }
}

Exceptions

{"ex": [{"msg":"Date range not correct.","Exception":false}]}
or
{"ex": {"tcp":"timeout","msg":"Error during TCP connection"}}
or
"connection refused"