123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using RUSCommon;
- using System;
- using System.Runtime.InteropServices;
- namespace AdmittanceModuleLib
- {
- public class AdmittanceModule : IAdmittanceModule
- {
- #region dll import
- [DllImport("AdmittanceControl.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void CreateAdmittanceControl(out IntPtr hAdmittanceControl);
- [DllImport("AdmittanceControl.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void ReleaseAdmittanceControl([In] IntPtr hAdmittanceControl);
- [DllImport("AdmittanceControl.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void SetAdmittanceControl([In] IntPtr hAdmittanceControl, EnumAdmittanceSpace admittanceSpace, EnumAdmittanceType admittanceType);
- [DllImport("AdmittanceControl.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void UpdateCurrentForce([In] IntPtr hAdmittanceControl, FTData force);
- [DllImport("AdmittanceControl.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void UpdateCurrentWayPoint([In] IntPtr hAdmittanceControl, RobotWayPointData wayPoint);
- [DllImport("AdmittanceControl.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void UpdateReferWayPoint([In] IntPtr hAdmittanceControl, RobotWayPointData wayPoint);
- [DllImport("AdmittanceControl.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void GetTargetWayPoint([In] IntPtr hAdmittanceControl, ref RobotWayPointData wayPoint);
- #endregion
- #region private variable
- private static IntPtr _admittanceControlHandle = IntPtr.Zero;
- #endregion private variable
- #region 实现
- public void Dispose()
- {
- if (_admittanceControlHandle != IntPtr.Zero)
- {
- ReleaseAdmittanceControl(_admittanceControlHandle);
- _admittanceControlHandle = IntPtr.Zero;
- }
- }
- public void SetAdmittance(EnumAdmittanceSpace admittanceSpace, EnumAdmittanceType admittanceType)
- {
- SetAdmittanceControl(_admittanceControlHandle, admittanceSpace, admittanceType);
- }
- public void UpdateRealTimeForce(FTData ftdata)
- {
- UpdateCurrentForce(_admittanceControlHandle, ftdata);
- }
- public void UpdateRealTimeCurWayPt(RobotWayPointData currentWayPt)
- {
- UpdateCurrentWayPoint(_admittanceControlHandle, currentWayPt);
- }
- public void UpdateReferTargetWayPt(RobotWayPointData referWayPt)
- {
- UpdateReferWayPoint(_admittanceControlHandle, referWayPt);
- }
- public void GetActualTargetWayPt(ref RobotWayPointData targetWayPt)
- {
- GetTargetWayPoint(_admittanceControlHandle, ref targetWayPt);
- }
- public void StopAdmittanceControl()
- {
- Dispose();
- }
- #endregion 实现
- #region consdtuctor
- public AdmittanceModule()
- {
- if (_admittanceControlHandle == IntPtr.Zero)
- {
- CreateAdmittanceControl(out _admittanceControlHandle);
- }
- }
- #endregion consdtuctor
- }
- }
|