---
title: "DeviceClass"
canonical: "https://docs.cuesystem.com/space/CVCHELP/587989021/DeviceClass"
format: markdown
---
A DeviceClass is a special class that can have a Connector. The class can be usefull only inside the device driver. The device class is the core of the device driver and has to be the only DeviceClass inside the driver. The DeviceClass is ony template class and the real content depends on connection. Thus is not possible create instances of that class manually. The real instances are made by the XPL compiler and the real class instance depends on connection of the connectors. The DeviceClass can have one or more connectors. The connection is made in the cofiguration window of the CVC (Cue Visual Composer). All connectors must be connected to the channels of the controller or previous driver in the chain. The DeviceClass can have channels. The channel is the variable of Class type assigned with the special keyword Channel. Programmer can not inherit from the DeviceClass but the DeviceClass can inherit from the normal Class. See the example. It’s possible to have one base Class for the DeviceClass with virtual functions for the Connector functions and in the real driver inherit from that base Class and only overwrite the “connector functions“. See the example.

# Connector

The connector is a connection to a channel of another unit. It can be used only in a DeviceClass. 

#### Syntax 

```visualbasic
Connector Name
```

#### Example 

```visualbasic
Connector CUEwireConnector
```

#### Example

```
// Device Class without inheritance

DeviceClass MyDeviceClass
  Connector Serial 
  
  // example functions for device control
  Public Function Play()
    Serial.SendData(&S"Play")
  End Function
  
  Public Function IsPlaying() As Boolean
    Var result As ByteString[20]
    Serial.SendData(&S"GetPlayStatus")
    If not Serial.ReceiveData(result) then
      Return Value False
    End If
    If result <> &S"Play In Progress" then
      Return Value False
    End If
    Return Value True
  End Function
End Class

```

#### Example

Base device driver 

![image](media://11a19bcc-2633-4ee7-943b-05b702212200)

```visualbasic
// Device Class inheritance

// Base for the DeviceClass
Class MyDeviceBaseClass

// Virtual connector functions - need to overwrite inside the real DeviceClass
  Protected Function Connector_SendData(data As ByteString)
  End Function
  
  Protected Function Connector_ReceiveData(ByRef data As ByteString) As Boolean
    Return Value False
  End Function
  
  // example functions for device control
  Public Function Play()
    Connector_SendData(&S"Play")
  End Function
  
  Public Function IsPlaying() As Boolean
    Var result As ByteString[20]
    Connector_SendData(&S"GetPlayStatus")
    If not Connector_ReceiveData(result) then
      Return Value False
    End If
    If result <> &S"Play In Progress" then
      Return Value False
    End If
    Return Value True
  End Function
End Class

```

Specific device inherited from "MyCompany.Device.BasePlayer".MyDeviceBaseClass

```visualbasic
// Example of the inherited device class - connected with the Serial connector
DeviceClass MyDeviceConnectedSerial Inherits Namespace "MyCompany.Device.BasePlayer".MyDeviceBaseClass
  Connector Serial
  Protected Function Connector_SendData(data As ByteString)
    Serial.Send(data)
  End Function
  
  Protected Function Connector_ReceiveData(ByRef data As ByteString) As Boolean
    Return Value Serial.Receive(data)
  End Function
End DeviceClass
```

## Channel

Some drivers can have channels. The channel is specialized variable of class type for connecting next driver in the chain.

#### Example

```
// DeviceClass with the channel

Class MyChannelClass
  Friend MyDeviceClassWithChannel
  Protected Var MyOwner As AddressOf MyDeviceClassWithChannel
  Public Function Play()
    MyOwner.Play()
  End Function
End Class

DeviceClass MyDeviceClassWithChannel
  Friend MyChannelClass
  Connector MyConnector
  Public Channel MyChannel As MyChannelClass
  
  Function Init()
    MyChannel.MyOwner := Me
  End Function
  
  Protected Function Play()
    // ... some Play Function Code on the MyConnector
  End Function
End DeviceClass

```