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 isActive() const { return true; }
00052 bool gActiveChanged() { return false; }
00053 std::string getType() const { return "ExternGeneralizedIO"; }
00054 void init(InitStage stage);
00055
00056 void connect(Object *obj, int qInd_, int uInd_) { connectedObject=obj; qInd=qInd_; uInd=uInd_; }
00057 void setGeneralizedForce(double h) { la(0)=h; }
00058 void setGeneralizedLinearForceParameters(double m_, double a_, double t0_) { m=m_; a=a_; t0=t0_; }
00059 double getGeneralizedPosition() { return g(0); }
00060 double getGeneralizedVelocity() { return gd(0); }
00061
00062 void plot(double t, double dt=1);
00063 void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00064 Type getType() { return type; }
00065
00066 virtual void updateWRef(const fmatvec::Mat&, int) {}
00067 virtual void updateVRef(const fmatvec::Mat&, int) {}
00068 virtual void updatehRef(const fmatvec::Vec&, int) {}
00069 virtual void updatedhdqRef(const fmatvec::Mat&, int) {}
00070 virtual void updatedhduRef(const fmatvec::SqrMat&, int) {}
00071 virtual void updatedhdtRef(const fmatvec::Vec&, int) {}
00072 virtual void updaterRef(const fmatvec::Vec&, int) {}
00073
00074 void addApplyForceAlsoTo(Object *ref, double factor, int index);
00075
00076 private:
00077 std::string saved_connectedObject;
00078 protected:
00079 Type type;
00080 };
00081
00082 }
00083
00084 #endif