NDEVR
API Documentation
DistanceEncoder.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/Device.h>
4namespace NDEVR
5{
6 class PositionSensor;
8 class Battery;
9 class Motor;
21
39 class HARDWARE_API DistanceEncoder : public Device
40 {
41 public:
48 DistanceEncoder(const Model& model, LogPtr log = LogPtr(), QObject* parent = nullptr);
53 virtual void setRawLengthEpsilon(fltp08 epsilon) { m_raw_length_epsilon = epsilon; }
57 virtual void clearDeploymentInfo();
62 virtual void setSpeed(fltp08 speed) { m_speed = speed; }
67 virtual void setDistanceBounds(const Bounds<1, fltp08>& bounds) { m_bounds = bounds; }
72 virtual void setRawLength(fltp08 length);
77 virtual void setDeploymentInfo(const DeploymentInfo& info);
81 virtual void startNewDeployment();
85 virtual void updateModel();
90 virtual fltp08 rawLength() const { return m_raw_length; };
95 virtual fltp08 scale() const { return m_scale; };
100 virtual fltp08 reference() const { return m_reference; }
105 virtual fltp08 length() const;
110 virtual fltp08 lengthToReference() const;
114 virtual void zeroRaw();
129 virtual void setScale(fltp08 scale);
134 virtual void setOffset(fltp08 offset);
139 virtual void setReference(fltp08 offset);
143 virtual void clearReference();
148 virtual void setLocation(const Vertex<3, fltp08>& location);
153 virtual void setCanDeleteReadings(bool can_delete) { m_delete_encoder_readings = can_delete; }
158 virtual Battery* battery() const { return m_battery; }
168 virtual void setNewDeploymentOffset(fltp08 offset) { m_new_deployment_offset = offset; }
183 virtual bool isInUse() const { return m_is_in_use; }
188 virtual void setInUse(bool is_in_use);
193 virtual bool isConnected() const { return true; }
194 public:
204 static void SetPrimaryDistanceEncoderCallback(const std::function<DistanceEncoder*()>& encoder);
205 protected:
206 static std::function<DistanceEncoder*()> s_get_distance_encoder;
207 protected:
215 fltp08 m_reference = Constant<fltp08>::Invalid;
218 Battery* m_battery = nullptr;
221 bool m_is_in_use = true;
222 };
223}
A device which has an associated voltage or percent that changes.
Definition Battery.h:106
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
A core class where all Design Objects including models, materials, and geometries are stored.
Device(const Model &model, LogPtr log, QObject *parent=nullptr)
Constructs a Device from a Model with the given log and optional Qt parent.
virtual void zeroRaw()
Zeros the raw length reading, treating the current position as zero.
virtual Battery * battery() const
Returns the battery associated with this encoder, if any.
bool m_is_in_use
Whether this encoder is currently in use.
virtual void setDistanceBounds(const Bounds< 1, fltp08 > &bounds)
Sets the valid distance bounds for this encoder.
virtual void setLocation(const Vertex< 3, fltp08 > &location)
Sets the 3D spatial location of the encoder.
Bounds< 1, fltp08 > m_bounds
Valid distance bounds for this encoder.
fltp08 m_new_deployment_offset
Offset applied at the start of a new deployment.
virtual void setReference(fltp08 offset)
Sets the reference distance point.
virtual void calibrateToLength(fltp08 length)
Calibrates the encoder scale so that the current raw reading maps to the given length.
DistanceEncoder(const Model &model, LogPtr log=LogPtr(), QObject *parent=nullptr)
Constructs a DistanceEncoder device.
Battery * m_battery
Associated battery device, if any.
virtual bool isInUse() const
Checks whether this encoder is currently in use.
virtual fltp08 reference() const
Returns the current reference point distance.
fltp08 m_reference
Reference distance point. Invalid if not set.
static DistanceEncoder * PrimaryDistanceEncoder()
Returns the primary distance encoder registered with the system.
fltp08 m_raw_length
Raw uncalibrated length reading from hardware.
virtual void clearDeploymentInfo()
Clears the current deployment info and deactivates the deployment.
static std::function< DistanceEncoder *()> s_get_distance_encoder
Callback to retrieve the primary distance encoder.
fltp08 m_speed
Current speed of encoder movement.
bool m_delete_encoder_readings
Whether old readings can be deleted during deployment.
virtual void setSpeed(fltp08 speed)
Sets the current encoder speed.
virtual fltp08 scale() const
Returns the current scale factor applied to raw readings.
virtual void setScale(fltp08 scale)
Sets the scale factor applied to raw readings.
virtual void setInUse(bool is_in_use)
Sets whether this encoder is currently in use.
virtual void updateModel()
Updates the underlying Model with the current encoder state.
virtual void setCanDeleteReadings(bool can_delete)
Sets whether old encoder readings can be deleted during deployment.
DeploymentInfo m_deployment_info
Current deployment session parameters.
virtual void setBattery(Battery *battery)
Sets the battery associated with this encoder.
virtual void setNewDeploymentOffset(fltp08 offset)
Sets the offset applied at the start of a new deployment.
fltp08 preferredSegmentLength() const
Returns the preferred deployment segment length.
virtual fltp08 rawLength() const
Returns the current raw (uncalibrated) length reading.
fltp08 m_raw_length_epsilon
Minimum raw length change to register as a new reading.
static void SetPrimaryDistanceEncoderCallback(const std::function< DistanceEncoder *()> &encoder)
Registers a callback that returns the primary distance encoder.
fltp08 m_raw_offset
Offset applied to the raw reading for zeroing.
fltp08 m_offset
User-defined offset added to the calibrated length.
virtual void setRawLengthEpsilon(fltp08 epsilon)
Sets the minimum change in raw length required to register as a new reading.
virtual fltp08 length() const
Returns the calibrated length, applying scale and offset to the raw reading.
virtual fltp08 lengthToReference() const
Returns the distance from the current position to the reference point.
virtual bool isConnected() const
Checks whether the encoder hardware is connected.
virtual void setDeploymentInfo(const DeploymentInfo &info)
Sets the deployment info for managing deployment sessions.
virtual void startNewDeployment()
Begins a new deployment session, resetting relevant state.
virtual void clearReference()
Clears the reference point, setting it to invalid.
TemperatureSensor * m_temperature_sensor
Associated temperature sensor, if any.
virtual void setRawLength(fltp08 length)
Sets the raw length reading from the encoder hardware.
virtual TemperatureSensor * temperatureSensor() const
Returns the temperature sensor associated with this encoder, if any.
virtual void setOffset(fltp08 offset)
Sets the offset added to the scaled raw reading.
virtual void setTemperatureSensor(TemperatureSensor *sensor)
Sets the temperature sensor associated with this encoder.
fltp08 m_scale
Scale factor applied to raw readings.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
A core class that represents a node on model hierarchy.
Definition Model.h:292
A motor is a device which produces rotational spin.
Definition Motor.h:46
Forward declaration for distance encoder device.
A Device responsible for determining the temperature of either the environment or a specific componen...
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
double fltp08
Defines an alias representing an 8 byte floating-point number.
Parameters describing a deployment session for a DistanceEncoder and its associated sensor.
fltp08 deployment_segment_length
The length of each deployment segment.
DesignObjectLookup * manager
Design object lookup for managing deployment models.
bool active
Whether a deployment is currently active.
PositionSensor * sensor
The position sensor used during deployment.