Latest 0.1.3
Homepage https://github.com/Label305/dSRelay
License Apache 2
Platforms ios 9.0, osx 10.10
Dependencies SwiftSocket, thenPromise
Authors

CI Status
Version
License
Platform

dSRelay is a small library to connect with Robot Electronics network
relay devices. This library implements all binary commands specified
by Robot Electronics’ documentation.

To run the example/tests project, clone the repo, and run pod install from the Example directory first.

This library was tested on the dS282

To create a device:

if let device = Device(ipaddress: <ipaddress>, port : 17123) {
    // do something
}

device.getStatus().then { status in // asynchronously get info of device
}

if let status = device.getRelayStatus().value // synchronously get info of device

Sending Commands

The binary commands documented by Robot Electronics are implemented
in this library. The original documentation can be found here.

Get Status

device.getStatus.then { status in
    // status is a Dictionary<String, UInt> with the following keys:
    // moduleID
    // systemFirmwareMajor
    // systemFirmwareMinor
    // appFirmwareMajor
    // appFirmwareMinor
    // volts
    // internalTemperature
}

Set a Relay

// set a relay on/off
device.setRelay(relayNr: 1, set: Status.On).then { result in
    // result is a boolean inidicating whether the command succeeded
}

// set a relay on for a certain duration (in ms)
device.setRelay(relayNr: 1, pulseTime: 1000).then { result in
    // result is a boolean inidicating whether the command succeeded
}

Get Status of Relays

Note: the order of relay status indicated in the bytes returned was changed between firmware versions 2 and 3.
This library takes this difference into account and thus should work with any device with any firmware.

For reference:

device.getRelayStatus().then { statuses in
    // statuses is an array of 32 (virtual) relays, 0 = status for relay 1 .. 31 = status for (virtual) relay 32
}

Get Input

device.getInputStatus().then { inputs in
    // array of 8 booleans for each input's status (on/off)
}

device.getAnalogueInputStatus().then { inputs in
    // array of 8 UInt16s indicating the analogue input's status
}

Get Counters

device.getCounters().then { counters in
    // counters is a tuple of (counterValue: UInt, captureRegister: UInt)
}

Installation

dSRelay is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'dSRelay'

License

dSRelay is available under the Apache 2.0 license. See the LICENSE file for more info.

Latest podspec

{
    "name": "dSRelay",
    "version": "0.1.3",
    "summary": "A Swift library for connecting with Robot Electronics ethernet relay devices.",
    "description": "A Swift library to connect with devices from Robot Electronics such as the dS2824 over network connections.",
    "homepage": "https://github.com/Label305/dSRelay",
    "license": {
        "type": "Apache 2",
        "file": "LICENSE"
    },
    "authors": {
        "Mu00e8ir Noordermeer": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Label305/dSRelay.git",
        "tag": "0.1.3"
    },
    "swift_version": "4.2",
    "dependencies": {
        "SwiftSocket": [],
        "thenPromise": []
    },
    "platforms": {
        "ios": "9.0",
        "osx": "10.10"
    },
    "source_files": "dSRelay/Classes/**/*"
}

Pin It on Pinterest

Share This