---
title: "Universal (_Universal class)"
canonical: "https://docs.cuesystem.com/space/CVCHELP/522223688/Universal%20(_Universal%20class)"
format: markdown
---
> Macro (toc)

---

# Close

This function switches output ON. 

#### Syntax 

```visualbasic
Function Close() As Boolean
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

#### Example 

```visualbasic
U1.Close()
```

This command switches the U1 output ON. 

# ClosePulse

This function switches output ON and after **pulsetime** switches it OFF. 

#### Syntax 

```visualbasic
Function ClosePulse(pulsetime As Time) As Boolean
```

#### Parameters 

pulsetime 

<u>[Time](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)</u> It is a time of the pulse. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

#### Example 

```visualbasic
U1.ClosePulse(:1.0)
```

This command switches the U1 output ON and after one second switches it OFF. 

# GetDigitalLevel

The function returns True if the input is at active level (input voltage is above threshold) and False otherwise. 

#### Syntax 

```visualbasic
Function GetDigitalLevel() As Boolean
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True if the input is in active level (input voltage is above threshold), False otherwise. 

#### Example 

```visualbasic
Var Level1 As Boolean  

Level1 := U1.GetDigitalLevel()
```

There is a current digital level on the U1 channel in the variable Level1. 

# IrSend

The function sends IR data to the Universal channel. If a parameter repeatuntilstop is True, it sends the data repeatedly until a function StopIrSend is called. 

#### Syntax 

```visualbasic
Function IrSend( 
  irdata As _IrData, 
  Optional repeatuntilstop As Boolean := False) 
As Boolean
```

#### Parameters 

irdata 

_IrData It is the data to be sent. 

repeatuntilstop 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> Optional, defaults to False. If it is False, the data is sent only once. If it is True, the data is sent repeatedly until a function StopIrSend is called. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

# IrSendFromByteString

The function sends IR data from ByteString. If a parameter repeatuntilstop is True, it sends the data repeatedly until a function StopIrSend is called. 

#### Syntax 

```visualbasic
Function IrSendFromByteString( 
  irdata As ByteString, 
  Optional repeatuntilstop As Boolean := False) 
As Boolean
```

#### Parameters 

irdata 

<u>[ByteString](/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u>. It is the ByteString with IR data to be sent. Command IrCaptureToByteString can be used to create ByteString with IR data. 

repeatuntilstop 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> Optional, defaults to False. If it is False, the data is sent only once. If it is True, the data is sent repeatedly until a function StopIrSend is called. 

# IrSendFromFile

The function sends IR data from the file to the IR channel. If a parameter repeatuntilstop is True, it sends the data repeatedly until a function StopIrSend is called. 

#### Syntax 

```visualbasic
Function IrSendFromFile( 
  Filename As Text, 
  Optional repeatuntilstop As Boolean := False) 
As Boolean
```

#### Parameters 

filename 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. It is the file name with IR data to be sent. Command IrCaptureToFile can be used to create a file with IR data. 

repeatuntilstop 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> Optional, defaults to False. If it is False, the data is sent only once. If it is True, the data is sent repeatedly until a function StopIrSend is called. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. These errors can happen: <u>[600](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#600)</u>, <u>[601](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#601)</u>, <u>[602](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#602)</u>, <u>[603](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#603)</u>, <u>[604](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#604)</u>. 

# IsClosed

The function returns if a channel is closed or opened. 

#### Syntax 

```visualbasic
Function IsClosed() As Boolean
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True if the channel is closed, False otherwise. 

#### Example 

```visualbasic
If U1.IsClosed() Then 
  DebugPrint("U1 is closed now") 
Else 
  DebugPrint("U1 is open now") 
End If
```

# IsPullupOn

The function returns if a pullup is ON or OFF. 

#### Syntax 

```visualbasic
Function IsPullupOn() As Boolean
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True if the pullup is ON, False otherwise. 

#### Example 

```visualbasic
If U1.IsPullupOn() Then 
  DebugPrint("U1 Pullup is ON") 
Else 
  DebugPrint("U1 Pullup is OFF") 
End If
```

# Open

This function switches output OFF. 

#### Syntax 

```visualbasic
Function Open() As Boolean
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

#### Example 

```visualbasic
U1.Open()
```

This command switches the U1 output OFF. 

# PullupOff

This function switches a pullup OFF. 

#### Syntax 

```visualbasic
Function PullupOff() As Boolean
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

#### Example 

```visualbasic
U4.PullupOff()
```

This command switches U4 pullup OFF. 

# PullupOn

This function switches a pullup ON. 

#### Syntax 

```visualbasic
Function PullupOn() As Boolean
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

#### Example 

```visualbasic
U1.PullupOn()
```

This command switches U1 pullup ON. 

# Send

The function sends data to the Universal channel. It returns True on success or False if data is not accessible. 

#### Syntax 

```visualbasic
Function Send(data As ByteString) As Boolean
```

#### Parameters 

data 

<u>[ByteString](/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the data to be sent. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if data is not accessible. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

# SetCarrier

The function modes the Universal channel for sending with or without a carrier. 

#### Syntax 

```visualbasic
Function SetCarrier(enable As Boolean) As Boolean
```

#### Parameters 

enable 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It enables (True) or disables (False) the carrier. 

#### Return value* *

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

# SetOutputState

The function sets the complex output state of the channel with optional interruption of the currently running program. 

#### Syntax 

```visualbasic
Function SetOutputState( 
  outputstate As _UniversalOutputState, 
  Optional stopoutputprogram As Boolean := True) 
As Boolean
```

#### Parameters 

outputstate 

<u>_UniversalOutputState</u> <u>[Structure](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Structure)</u> It defines the output value of the channel. It is possible individually set up all three of the active elements of the output channel, i.e. Close, Pullup and Pulldown switches. For each of the switches can be defined, whether it should be closed, open, or left in the current state. See <u>_UniversalOutputControl</u> <u>[Enum](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Enum)</u> for more details. 

stopoutputprogram 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> If True it interrupts the currently running program. If False currently running program is not affected. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

#### Example 

Relay with potential free input contacts is connected to U1 

```visualbasic
// switch universal output to close state 
Var outputstate As _UniversalOutputState 

outputstate.Close := _UniversalOutputControl.On  
outputstate.Pulldown := _UniversalOutputControl.Off 
outputstate.Pullup := _UniversalOutputControl.Off 
U1.SetOutputState(outputstate, True)
```

The command switches universal U1 output to close state and thus closes the relay contacts. 

# SetSerialParameters

The function sets the communication parameters of the Universal channel. 

#### Syntax 

```visualbasic
Function SetSerialParameters( 
  mode As Byte, 
  bitspersecond As Long, 
  databits As Byte, 
  parity As Byte, 
  stopbits As Byte, 
  flowcontrol As Byte, 
  ParamArray) As Boolean
```

#### Parameters 

mode 

<u>[Byte](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Byte)</u> It is the mode of the channel. Predefined constants for parameter mode are as follows: 

|  |  |  |
| --- | --- | --- |
| Name | Value | Description |
| _SERIAL_MODE_RS232 | 0 | Channel is in RS-232 mode. |

bitspersecond 

<u>[Long](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the baud rate from 300 to 115200. 

databits 

<u>[Byte](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Byte)</u> It is the number of data bits from 5 to 8. 

parity 

<u>[Byte](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Byte)</u> It is the type of parity. Predefined constants for parameter parity are as follows: 

|  |  |  |
| --- | --- | --- |
| Name | Value | Description |
| _SERIAL_PARITY_NO | 0 | No parity. |
| _SERIAL_PARITY_ODD | 1 | Odd parity. |
| _SERIAL_PARITY_EVEN | 2 | Even parity. |

stopbits 

<u>[Byte](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Byte)</u> It is the number of stop bits. Predefined constants for parameter stopbits are as follows: 

|  |  |  |
| --- | --- | --- |
| Name | Value | Description |
| _SERIAL_STOPBITS_ONE | 0 | One stop bit. |
| _SERIAL_STOPBITS_ONEANDHALF | 1 | One and a half stop bits. |
| _SERIAL_STOPBITS_TWO | 2 | Two stop bits. |

flowcontrol 

<u>[Byte](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Byte)</u> It is the type of the control. Predefined constants for parameter flowcontrol are as follows: 

|  |  |  |
| --- | --- | --- |
| Name | Value | Description |
| _SERIAL_FLOWCONTROL_NONE | 0 | No handshake. |
| _SERIAL_FLOWCONTROL_DELAY | 4 | Specifies the delay time between bytes. It must be specified in the next parameter ParamArray. |

ParamArray 

<u>[ParamArray](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/509149361)</u> They are parameters of the flow. The number and types of these parameters depend on previous parameter flowcontrol if _SERIAL_FLOWCONTROL_DELAY is used. 

 

- _SERIAL_FLOWCONTROL_DELAY is used as the flowcontrol:

timedelay 

<u>[Time](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)</u> It is the delay time between bytes. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

#### Examples 

Channel U1 is in RS-232 mode, 9600 bits per second, 8 data bits, no parity, one stop bit, and no handshake. 

```visualbasic
U1.SetSerialParameters( 
  _SERIAL_MODE_RS232, 
  9600, 
  8, 
  _SERIAL_PARITY_NO, 
  _SERIAL_STOPBITS_ONE, 
  _SERIAL_FLOWCONTROL_NONE)
```

Channel U1 is in RS-232 mode, 9600 bits per second, 8 data bits, no parity, one stop bit, specifies the delay time between bytes. The time delay is 1 second. 

```visualbasic
U1.SetSerialParameters( 
  _SERIAL_MODE_RS232, 
  9600, 
  8, 
  _SERIAL_PARITY_NO, 
  _SERIAL_STOPBITS_ONE, 
  _SERIAL_FLOWCONTROL_DELAY, 
  :1)
```

# StopIrSend

The function stops sending IR data to the Universal channel started by the function IrSend. 

#### Syntax 

```visualbasic
Function StopIrSend() As Boolean
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

# WaitWhileDigitalLevelActive

The function waits while the input signal on the channel is in the active level (input voltage is above threshold) and until the **timeout** elapsed. 

#### Syntax 

```visualbasic
Function WaitWhileDigitalLevelActive(Optional timeout As Time := _TIME_INFINITE) As Boolean
```

#### Parameters 

timeout 

<u>[Time](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)</u> Optional, defaults to _TIME_INFINITE. It is time to wait. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True if the function is finished before the timeout has passed. It is False when the time elapsed or if an error occurs. A function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number. 

#### Example 

The command waits as long as the input signal on the channel is in the active level (input voltage is above threshold). 

```visualbasic
// wait while the input signal is in the active level 
U1.WaitWhileDigitalLevelActive()
```

# Structure _UniversalOutputState

This structure is predefined in the firmware of all units, which supports universal output. 

#### Syntax 

```visualbasic
Structure _UniversalOutputState 
  Var Pullup As _UniversalOutputControl, 
  Var Pulldown As _UniversalOutputControl 
  Var Close As _UniversalOutputControl 
End Structure
```

# Enum _UniversalOutputControl

This enum is predefined in the firmware of all units, which supports universal output. 

#### Syntax 

```visualbasic
Enum _UniversalOutputControl 
  NoChange := -1, 
  On := 1, 
  Off := 0, 
End Enum
```