AGX Dynamics  2.35.0.1
PowerLineUtils.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXPOWERLINE_POWER_LINE_UTILS_H
18 #define AGXPOWERLINE_POWER_LINE_UTILS_H
19 
20 #include <agxModel/export.h>
21 
22 #include <agxStream/Serializable.h>
23 #include <agx/List.h>
24 #include <agx/Vector.h>
25 #include <agxUtil/agxUtil.h>
27 #include <agx/LookupTables.h>
28 
29 
30 namespace agxPowerLine
31 {
32  namespace detail
33  {
34  class ConnectionOperations;
35  }
36 
37 }
38 
39 
40 namespace agxPowerLine
41 {
42  class Unit;
43  class PowerLine;
44  class PhysicalDimensionMultiBodyConstraintImplementation;
45 
49 
51  const std::string& dimensionName);
52 
68  class AGXMODEL_EXPORT LookupTable : virtual public agx::LookupTable // virtual inheritance due to diamond
69  {
70  public:
76 
81 
86 
92 
96  virtual bool store(agxStream::StorageStream& str) const;
97 
101  virtual bool restore(agxStream::StorageStream& str);
102 
103 
104  virtual void store( agxStream::OutputArchive& out ) const override;
105  virtual void restore( agxStream::InputArchive& in ) override;
106 
108  protected:
110  virtual ~LookupTable();
112  };
113 
114 
120  {
121  public:
126 
130  virtual agx::Real lookup( const agx::Real x ) const override;
131 
135  virtual bool store(agxStream::StorageStream& str) const override;
136 
140  virtual bool restore(agxStream::StorageStream& str) override;
141 
143  protected:
146  };
148 
149 
154  {
155  public:
162 
166  virtual bool store(agxStream::StorageStream& str) const override;
167 
171  virtual bool restore(agxStream::StorageStream& str) override;
172 
174 
175  protected:
179 
180  };
182 
183 
188  {
189  public:
195 
200 
205 
210 
215  virtual void applyPower() = 0;
216 
220  virtual agx::Real variableLookupFunction( ) const = 0;
221 
225  virtual agx::Real resultScalerFunction( ) const = 0;
226 
230  void clear();
231 
235  virtual bool store(agxStream::StorageStream& str) const;
236 
240  virtual bool restore(agxStream::StorageStream& str);
241 
242  virtual void store( agxStream::OutputArchive& out ) const override;
243  virtual void restore( agxStream::InputArchive& in ) override;
244 
246 
247  protected:
249  virtual ~PowerGenerator();
250 
252  };
253 
254 
255  /*
256  A Connection can link one physical dimension to another.
257  */
259  {
260  public:
266 
270  bool isValid() const;
271 
276 
281 
287 
292 
297 
301  virtual void clear();
302 
306  virtual bool store(agxStream::StorageStream& str) const;
307 
311  virtual bool restore(agxStream::StorageStream& str);
312 
313  //Will use the efficiency of the output connection
315 
316  protected:
318  virtual ~Connection();
319 
320  protected:
323  };
324 
325 }
326 
327 #endif // AGXMODEL_POWER_LINE_UTILS_H
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXMODEL_EXPORT
agxPowerLine::Connector * getConnector()
const agxPowerLine::Connector * getConnector() const
bool setConnector(agxPowerLine::Connector *connector)
agxPowerLine::PhysicalDimension * getDimension()
const agxPowerLine::PhysicalDimension * getDimension() const
virtual void clear()
clear all reference pointers
virtual bool store(agxStream::StorageStream &str) const
Stores internal data into stream.
virtual bool restore(agxStream::StorageStream &str)
Restores internal data from stream.
PhysicalDimension * m_dimension
Connection(agxPowerLine::PhysicalDimension *dimension, agxPowerLine::Connector *connector)
Create a connection in or out of a physical dimension.
Links two connections together.
Definition: Connector.h:54
Linear interpolation between the inserted variable/value pairs.
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
virtual agx::Real lookup(const agx::Real x) const override
Lookup a specific value.
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
LinearLookupTable(agxPowerLine::PhysicalDimension *dimension)
Constructor.
Return a value of y given any value of x.
virtual void store(agxStream::OutputArchive &out) const override
virtual agx::Real variableLookupFunction() const
Implement this in any child class to define the lookup variable.
virtual bool restore(agxStream::StorageStream &str)
Restores internal data from stream.
agx::Real lookupCurrent() const
Lookup the current value (given the dimension set.)
virtual bool store(agxStream::StorageStream &str) const
Stores internal data into stream.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxPowerLine::LookupTable)
LookupTable(agxPowerLine::PhysicalDimension *dimension)
Create a lookup table.
virtual void restore(agxStream::InputArchive &in) override
agx::observer_ptr< PhysicalDimension > m_dimension
void setDimension(agxPowerLine::PhysicalDimension *dimension)
change dependent physical dimension
Will generate power by adding a load to a physical dimension.
virtual agx::Real getCurrentPowerTimeIntegral() const
return how big load that is added to the simulation through the physical dimension at the moment
virtual agx::Real variableLookupFunction() const =0
Implement this to scale lookups accordingly.
agxPowerLine::PowerTimeIntegralLookupTable * getPowerTimeIntegralLookupTable() const
virtual void store(agxStream::OutputArchive &out) const override
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxPowerLine::PowerGenerator)
virtual agx::Real resultScalerFunction() const =0
Implement this to scale lookups accordingly.
virtual void restore(agxStream::InputArchive &in) override
virtual bool restore(agxStream::StorageStream &str)
Restores internal data from stream.
void clear()
clear all reference pointers
virtual void applyPower()=0
Implement this to apply power each timestep.
PowerTimeIntegralLookupTableRef m_timeIntegralLookupTable
void setPowerTimeIntegralLookupTable(agxPowerLine::PowerTimeIntegralLookupTable *table)
Set the time integral table.
PowerGenerator(agxPowerLine::PhysicalDimension *dimension)
Create a power generator.
virtual bool store(agxStream::StorageStream &str) const
Stores internal data into stream.
A lookup table used for power time integral (torque for rotational power, force for translational pow...
PowerTimeIntegralLookupTable(agxPowerLine::PhysicalDimension *dimension, agxPowerLine::PowerGenerator *generator)
The time integral is the one of the power lookup table in the power generator.
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
Linear interpolation between the inserted variable/value pairs.
Definition: LookupTables.h:108
Return a value of y given any value of x.
Definition: LookupTables.h:41
Base class providing referencing counted objects.
Definition: Referenced.h:114
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Definition: observer_ptr.h:61
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:24
agx::observer_ptr< Unit > UnitObserver
agx::ref_ptr< LinearLookupTable > LinearLookupTableRef
agx::HashVector< UnitRef, bool > UnitRefBoolHashVector
agx::ref_ptr< Unit > UnitRef
agx::ref_ptr< PowerTimeIntegralLookupTable > PowerTimeIntegralLookupTableRef
AGXMODEL_EXPORT agxPowerLine::PhysicalDimension::Type getDimensionType(const std::string &dimensionName)
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
double Real
Definition: Real.h:42