00001 #ifndef DEVICE_DRNITTAFORCE_H
00002 #define DEVICE_DRNITTAFORCE_H
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007 #include "DRRealDevice.h"
00008 #include "DVForceBase.h"
00009 #include <base/Affine.h>
00010
00011 namespace Spr {
00012
00013
00014 class SPR_DLL DRNittaForce: public DRRealDevice{
00015 public:
00016
00017 class VirtualDevice:public DVForceBase{
00018 protected:
00019 DRNittaForce* realDevice;
00020 public:
00021 VirtualDevice(DRNittaForce* r):realDevice(r){}
00022 virtual DRRealDevice* RealDevice() { return realDevice; }
00023 virtual const char* Name() const{ return realDevice->Name(); }
00024 virtual int GetDOF() const { return 6; }
00025 virtual float GetForce(int ch) const { return realDevice->GetForce(ch); }
00026 };
00027
00028 enum{
00029 count1_addr = 0xe8,
00030 count2_addr = 0xe9,
00031 count3_addr = 0xea,
00032 count4_addr = 0xeb,
00033 count5_addr = 0xec,
00034 count6_addr = 0xed,
00035 force_units_addr = 0xfc,
00036 full_fx_addr = 0x80,
00037 force_addr = 0x90,
00038 fx0_addr = 0x90,
00039 full_fy_addr = 0x81,
00040 fy0_addr = 0x91,
00041 full_fz_addr = 0x82,
00042 fz0_addr = 0x92,
00043 full_mx_addr = 0x83,
00044 mx0_addr = 0x93,
00045 full_my_addr = 0x84,
00046 my0_addr = 0x94,
00047 full_mz_addr = 0x85,
00048 mz0_addr = 0x95,
00049 software_ver_no_addr= 0xf5,
00050 serial_no_addr = 0xf8,
00051 model_no_addr = 0xf9,
00052 DOF = 6
00053 };
00054 protected:
00055 char name[100];
00056 unsigned int baseAdr;
00057 unsigned int boardNumber;
00058 unsigned short software_ver_no;
00059 unsigned short serial_no;
00060 unsigned short model_no;
00061 unsigned short full_range[DOF];
00062 unsigned short units;
00063 short force[DOF];
00064
00065 public:
00066
00067 DRNittaForce(int boardNum);
00068
00069 virtual ~DRNittaForce();
00070
00071 virtual bool Init();
00072
00073 virtual void Register(DVVirtualDevicePool& vpool);
00074
00075 virtual const char* Name() const { return name; }
00076
00077 unsigned short GetCounter2K();
00078
00079 unsigned short GetCounter8K();
00080
00081 void Reset();
00082
00083 float GetForce(int ch){
00084 if (ch > DOF-1) ch = DOF-1;
00085 if (ch < 0) ch = 0;
00086 ReadForce(ch);
00087 return Force(ch);
00088 }
00089 protected:
00090
00091 float DRNittaForce::Force(int num){
00092 return (float)force[num]/(float)16384*(float)full_range[num];
00093 }
00094
00095 void ReadForce(int ch);
00096
00097 void ReadReg(unsigned short a, unsigned short* d);
00098 void WriteReg(unsigned short a, unsigned short d);
00099 };
00100
00101 }
00102
00103 #endif