UNPKG

@edgepi-cloud/node-red-edgepi-digital-out

Version:

node-red node for edgepi digital output module utilizing remote procedure calls

161 lines (152 loc) 4.5 kB
<script type="text/javascript"> RED.nodes.registerType("digital-out", { category: "EdgePi", color: "#f391aa", defaults: { name: { value: "" }, transport: { value: "Local" }, tcpAddress: { value: "" }, tcpPort: { value: "" }, channel: { value: "DOUT1" }, doutState: { value: "LOW" }, }, inputs: 1, outputs: 1, icon: "right-arrow.svg", label: function () { return this.name || "digial-out"; }, oneditprepare: function () { const transportType = document.getElementById("node-input-transport"); const tcpTransportInputs = document.querySelector(".form-row.tcp"); function updateEditor() { if (transportType.value === "Network") { tcpTransportInputs.style.display = "flex"; } else { tcpTransportInputs.style.display = "none"; } } updateEditor(); transportType.addEventListener("change", updateEditor); }, }); </script> <script type="text/html" data-template-name="digital-out"> <style> * { box-sizing: border-box !important; } .form-row { display: flex; align-items: center; } .form-row > label { margin-top: auto; margin-bottom: auto; } .form-row.tcp { flex-direction: row; align-items: center; margin-top: -5px; margin-bottom: 10px; } .tcp-address-input { width: 160px !important; margin-left: 100px !important; } .tcp-port-input { width: 60px !important; } .tcp-port-label { width: 5px !important; margin: auto 5px; } </style> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name:</label> <input type="text" id="node-input-name" placeholder="Name" /> </div> <div class="form-row transport"> <label for="node-input-transport">RPC Server:</label> <select id="node-input-transport"> <option value="Local">Local</option> <option value="Network">Network</option> </select> </div> <div class="form-row tcp"> <input class="tcp-address-input" type="text" id="node-input-tcpAddress" placeholder="IP Address/ Hostname" /> <label class="tcp-port-label" for="node-input-tcpPort">:</label> <input class="tcp-port-input" type="text" id="node-input-tcpPort" placeholder="Port" /> </div> <div class="form-row"> <label for="node-input-DoutPin">Channel:</label> <select id="node-input-DoutPin"> <option value="1">D-OUT1</option> <option value="2">D-OUT2</option> <option value="3">D-OUT3</option> <option value="4">D-OUT4</option> <option value="5">D-OUT5</option> <option value="6">D-OUT6</option> <option value="7">D-OUT7</option> <option value="8">D-OUT8</option> </select> </div> <div class="form-row"> <label for="node-input-DoutTriState">State:</label> <select id="node-input-DoutTriState"> <option value="HI_Z">HI_Z</option> <option value="HIGH">HIGH</option> <option value="LOW">LOW</option> </select> </div> </script> <script type="text/html" data-help-name="digital-out"> <p> Sets the state of a given digital output channel on the EdgePi. The state can be set to LOW, HIGH, or HI_Z. </p> <h3>Properties</h3> <dl class="message-properties"> <dt>RPC Server</dt> <dd> The connection to your EdgePi's RPC Server. Use <strong>Local</strong> if node-red is running on EdgePi. Otherwise use the <strong>Network</strong> option and enter EdgePi's IP address / Hostname. </dd> <dt>Channel</dt> <dd>The channel being configured.</dd> <dt>State</dt> <dd>The state to set the selected channel to.</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <dt>payload <span class="property-type">string</span></dt> <dd> The D-OUT state (<strong>HI_Z</strong>, <strong>HIGH</strong>, or <strong>LOW</strong>). </dd> <dt>channel <span class="property-type">number</span></dt> </dl> <h3>Outputs</h3> <dl class="message-properties"> <dt>payload <span class="property-type">string</span></dt> <dd>A success message stating the configured channel's changed state.</dd> </dl> <h3>References</h3> <ul> <li> <a href="https://github.com/edgepi-cloud/node-red-digital-out">GitHub</a> -the node's github repository </li> </ul> </script>