Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
blocks:drivers:example [2018-04-22 19:46] admin [Parsing Data] |
blocks:drivers:example [2023-06-12 11:11] (current) admin Clarified connect callback parameters |
||
---|---|---|---|
Line 3: | Line 3: | ||
The WOCustomDrvr.ts file demonstrates how to write a driver for a device that provides a TCP " | The WOCustomDrvr.ts file demonstrates how to write a driver for a device that provides a TCP " | ||
- | This example driver communicates with Dataton WATCHOUT production software, controlling some basic | + | This example driver communicates with [[https:// |
functions. It's provided only as an example, since Blocks already has full | functions. It's provided only as an example, since Blocks already has full | ||
support for controlling WATCHOUT built-in. Using WATCHOUT as an example device | support for controlling WATCHOUT built-in. Using WATCHOUT as an example device | ||
Line 10: | Line 10: | ||
- Many of you are already familiar with WATCHOUT. | - Many of you are already familiar with WATCHOUT. | ||
- The production software UI clearly shows what's going on. | - The production software UI clearly shows what's going on. | ||
- | - It's available as a free download, so anyone can use it to try out the driver. | + | - It's available as a [[https:// |
- | + | ||
- | Open the driver using the Atom editor, and follow along in the code as you read this walk-through. | + | |
+ | Open the driver using a [[blocks: | ||
===== Import Statements ===== | ===== Import Statements ===== | ||
Line 24: | Line 23: | ||
</ | </ | ||
- | These other files provide definitions of system functions used to communicate with the device, such as the NetworkTCP interface imported from the " | + | These other files provide definitions of system functions used to communicate with the device, such as the NetworkTCP interface imported from the " |
- | Not only does this provide relevant documentation. It also provides information for the TypeScript compiler as well as for the [[blocks: | + | Not only does this provide relevant documentation. It also provides information for the TypeScript compiler as well as for the [[blocks: |
===== Driver Class Declaration ===== | ===== Driver Class Declaration ===== | ||
Line 68: | Line 67: | ||
< | < | ||
public constructor(private socket: NetworkTCP) { | public constructor(private socket: NetworkTCP) { | ||
+ | super(socket); | ||
+ | ... | ||
</ | </ | ||
Line 73: | Line 74: | ||
This parameter must be passed to the //Driver// base class using the //super// keyword, as shown. | This parameter must be passed to the //Driver// base class using the //super// keyword, as shown. | ||
- | |||
==== Event Subscriptions ==== | ==== Event Subscriptions ==== | ||
Line 84: | Line 84: | ||
</ | </ | ||
- | Event subscriptions are similar to how // | + | Event subscriptions are similar to how // |
When the subscribed-to event occurs, the function body following the // | When the subscribed-to event occurs, the function body following the // |