#pragma once


#include "robbase.h"


class CMotion ;

class ROBBASE_API CGpio
{
public:
	CGpio(void);
	CGpio(int type, int bit, BOOL bReverse, CMotion*  pMotion);
	virtual ~CGpio(void);

	enum{
		GT_IN =0,
		GT_OUT,
	};
	
	//可以指定位号
	virtual BOOL Get(int bit, int* pLevel, int* pErrCode);
	virtual BOOL Set(int bit, int  level, int* pErrCode);
	
	//不用指定位号
	BOOL Get(int* pLevel, int* pErrCode);
	BOOL Set(int  level, int* pErrCode);
	  
	//一起读和写
	virtual  BOOL GetBatch(int* pLevels, int* pErrCode);
	virtual  BOOL SetBatch(int  levels, int* pErrCode);

	//从批信号里面提取对应位的电平
	//getat返回对应的电平值
	//SetAt返回设置对应后的levels
	//信号不翻转
	static int GetAt(int levels, int bit);
	static int SetAt(int levels, int bit);
	 
	//输出反置
	BOOL     Topple(int* pErrCode);

public:
	int      m_nType;   //类型: 0-输入, 1-输出
	int      m_nBit;    //位号： 从1开始编号
	BOOL     m_bReverse;//信号是否翻转, 如果翻转，CRobMot优先
	CMotion* m_pRobMat;
	CUtString m_strName;
	//int       m_nId;
};

