NDEVR
API Documentation
DeviCounter.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2023, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: DeviCounter
28File: DLLInfo
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DeviCounterConnection.h"
34#include "DeviCounterBattery.h"
35#include <NDEVR/DistanceEncoder.h>
36#include <NDEVR/Translator.h>
37#include <NDEVR/FileResource.h>
38#include <NDEVR/INIFactory.h>
39namespace NDEVR
40{
45 {
47 uint04 count = 1024;
49 bool is_clockwise = true;
50 };
56 class DeviCounter : public DistanceEncoder
57 {
58 Q_OBJECT
59 public:
60 DeviCounter(InfoPipe* log = nullptr, InfoPipe* raw_log = nullptr);
61 DeviCounter(const ConnectionInfo& connection);
62 void attemptConnect();
63 const EncoderSettings& encoderSettings() const;
64 void setDeploymentInfo(const DeploymentInfo& info) final override;
65 void setEncoderSettings(const EncoderSettings& settings, bool send_to_device);
66 protected:
67 void init();
68 void calibrateToLength(fltp08 length) final override;
69 void update(Time time) final override;
70 [[nodiscard]] TimeSpan updateInterval() const final override;
71 [[nodiscard]] const DeviCounterSettings& options() const;
72 [[nodiscard]] DeviCounterSettings& options();
73 virtual bool isInUse() const override { return m_is_connected && m_data_recieved; }
74 signals:
75 void settingsChangedSignal();
76 void connectionChangedSignal(bool is_connected);
77 protected:
81 LogPtr m_raw_log = nullptr;
84 bool m_is_connected = false;
85 bool m_data_recieved = false;
86 bool m_try_to_connect = true;
87
88 };
89}
Network connection implementation for communicating with a DeviCounter device.
INI-based settings for DeviCounter connection behavior, timing, and simulation mode.
bool m_try_to_connect
Whether to attempt connection on next update.
Definition DeviCounter.h:86
bool m_data_recieved
Whether data has been received from the device.
Definition DeviCounter.h:85
bool m_is_connected
Whether the device is currently connected.
Definition DeviCounter.h:84
virtual bool isInUse() const override
Checks whether this encoder is currently in use.
Definition DeviCounter.h:73
void setDeploymentInfo(const DeploymentInfo &info) final override
Sets the deployment info for managing deployment sessions.
TimeSpan updateInterval() const final override
Returns the time interval between automatic updates.
uint04 m_num_of_failures_in_row
Consecutive connection failures.
Definition DeviCounter.h:83
ConnectionInfo m_connection_info
Connection parameters for the device.
Definition DeviCounter.h:78
DeviCounterConnection * m_connection
Active connection to the device.
Definition DeviCounter.h:82
LogPtr m_raw_log
Raw data log for debugging.
Definition DeviCounter.h:81
EncoderSettings m_encoder_settings
Current encoder configuration.
Definition DeviCounter.h:79
void calibrateToLength(fltp08 length) final override
Calibrates the encoder scale so that the current raw reading maps to the given length.
Time m_last_connection_attempt_time
Timestamp of last connection attempt.
Definition DeviCounter.h:80
void update(Time time) final override
Called to update the device with only the current time.
DistanceEncoder(const Model &model, LogPtr log=LogPtr(), QObject *parent=nullptr)
Constructs a DistanceEncoder device.
virtual fltp08 length() const
Returns the calibrated length, applying scale and offset to the raw reading.
A light-weight base class for Log that allows processes to update, without the need for additional in...
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
The core String class for the NDEVR API.
Definition String.h:95
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
A structure designed to store information about a specific Connection.
Definition Connection.h:90
Parameters describing a deployment session for a DistanceEncoder and its associated sensor.
Configuration settings for a DeviCounter rotary encoder device.
Definition DeviCounter.h:45
fltp08 initial_offset
Initial distance offset in meters.
Definition DeviCounter.h:48
String ssid
SSID of the encoder's wireless network.
Definition DeviCounter.h:46
uint04 count
Number of encoder ticks per revolution.
Definition DeviCounter.h:47
bool is_clockwise
Whether the encoder counts clockwise.
Definition DeviCounter.h:49