00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _EXTERNGENERALIZEDIO_H_
00020 #define _EXTERNGENERALIZEDIO_H_
00021
00022 #include "mbsim/link.h"
00023
00024 namespace MBSim {
00025
00026 class ExternGeneralizedIO : public Link {
00027 protected:
00028 Object *connectedObject;
00029 int qInd, uInd;
00030 double m, a, t0;
00031 struct ApplyForceAlsoTo {
00032 std::string saved_ref;
00033 Object *ref;
00034 double factor;
00035 int index;
00036 };
00037 std::vector<ApplyForceAlsoTo> applyForceAlsoTo;
00038 public:
00039 enum Type {
00040 constant, linear
00041 };
00042 ExternGeneralizedIO(const std::string &name="");
00043 void updateh(double, int i=0);
00044 void updateg(double);
00045 void updategd(double);
00046
00047 void calcxSize();
00048 void updatedx(double t, double dt);
00049 void updatexd(double t);
00050
00051 bool isSingleValued() const { return true; }
00052
00053 bool isActive() const { return true; }
00054 bool gActiveChanged() { return false; }
00055 std::string getType() const { return "ExternGeneralizedIO"; }
00056 void init(InitStage stage);
00057
00058 void connect(Object *obj, int qInd_, int uInd_) { connectedObject=obj; qInd=qInd_; uInd=uInd_; }
00059 void setGeneralizedForce(double h) { la(0)=h; }
00060 void setGeneralizedLinearForceParameters(double m_, double a_, double t0_) { m=m_; a=a_; t0=t0_; }
00061 const double& getGeneralizedPosition() { return g(0); }
00062 const double& getGeneralizedVelocity() { return gd(0); }
00063
00064 void plot(double t, double dt=1);
00065 void initializeUsingXML(xercesc::DOMElement *element);
00066 Type getType() { return type; }
00067
00068 virtual void updateWRef(const fmatvec::Mat&, int) {}
00069 virtual void updateVRef(const fmatvec::Mat&, int) {}
00070 virtual void updatehRef(const fmatvec::Vec&, int) {}
00071 virtual void updatedhdqRef(const fmatvec::Mat&, int) {}
00072 virtual void updatedhduRef(const fmatvec::SqrMat&, int) {}
00073 virtual void updatedhdtRef(const fmatvec::Vec&, int) {}
00074 virtual void updaterRef(const fmatvec::Vec&, int) {}
00075
00076 void addApplyForceAlsoTo(Object *ref, double factor, int index);
00077
00078 private:
00079 std::string saved_connectedObject;
00080 protected:
00081 Type type;
00082 };
00083
00084 }
00085
00086 #endif