📄 dio.cpp
字号:
// Dio.cpp: implementation of the CDio class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MdlSysol.h"
#include "Dio.h"
#include <conio.h>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#define BD_DIO_ISA 0
#define BD_DIO_PCI 1
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDio::CDio()
{
m_wInputAddr = 0x301;
m_wOutputAddr = 0x300;
/* m_byteOldBitMap = (BYTE)Read();
m_byteOldBitMapH = m_byteOldBitMap;
m_byteOldBitMapL = m_byteOldBitMap;
m_byteCurBitMap = m_byteOldBitMap;
m_byteCurBitMapH = m_byteOldBitMap;
m_byteCurBitMapL = m_byteOldBitMap;
*/
}
CDio::~CDio()
{
}
void CDio::SetAddress(WORD InputAddr, WORD OutputAddr)
{
m_wInputAddr = InputAddr;
m_wOutputAddr = OutputAddr;
}
int CDio::Read()
{
if(m_wInputAddr)
{
return _inp(m_wInputAddr);
}
else
return 0;
}
int CDio::Read(WORD wInAddr)
{
if(wInAddr)
{
return _inp(wInAddr);
}
else
return 0;
}
int CDio::Write(int byteOut)
{
if(byteOut)
{
return _outp(m_wOutputAddr, byteOut);
}
else
return 0;
}
int CDio::Write(WORD wOutAddr, int byteOut)
{
// if( wOutAddr && byteOut)
return _outp(wOutAddr, byteOut);
// return 0;
}
BYTE CDio::GetNewHighBitMap(int DioBoardType)
{
m_byteOldBitMapH = m_byteCurBitMapH;
if(DioBoardType == BD_DIO_ISA) // ISA Type Dio Board 20020108
m_byteCurBitMapH = (BYTE)Read();
else if(DioBoardType == BD_DIO_PCI) // PCI Type Dio Board 20020108
m_byteCurBitMapH = (BYTE)Read_YS6016P(0);
return ((~m_byteOldBitMapH) & m_byteCurBitMapH);
}
BYTE CDio::GetNewLowBitMap(int DioBoardType)
{
m_byteOldBitMapL = m_byteCurBitMapL;
if(DioBoardType == BD_DIO_ISA) // ISA Type Dio Board 20020108
m_byteCurBitMapL = (BYTE)Read();
else if(DioBoardType == BD_DIO_PCI)
m_byteCurBitMapL = (BYTE)Read_YS6016P(0); // PCI Type Dio Board 20020108
return (m_byteOldBitMapL & (~m_byteCurBitMapL));
}
BYTE CDio::GetChangeBitMap()
{
m_byteOldBitMap = m_byteCurBitMap;
m_byteCurBitMap = (BYTE)Read();
return (m_byteOldBitMap ^ m_byteCurBitMap);
}
int CDio::IsPCIorISA()
{
if(!Search_YS6016P())
return BD_DIO_ISA;
else
return BD_DIO_PCI;
}
void CDio::InitVariable(int DioboardType)
{
if(DioboardType == BD_DIO_ISA)
{
m_byteOldBitMap = (BYTE)Read();
}
else if(DioboardType = BD_DIO_PCI)
{
m_byteOldBitMap = (BYTE)Read_YS6016P(0);
}
m_byteOldBitMapH = m_byteOldBitMap;
m_byteOldBitMapL = m_byteOldBitMap;
m_byteCurBitMap = m_byteOldBitMap;
m_byteCurBitMapH = m_byteOldBitMap;
m_byteCurBitMapL = m_byteOldBitMap;
}
void CDio::Write_PCI(int Bd_Num, int byteOut)
{
Write_YS6016P( Bd_Num, byteOut);
}
int CDio::Read_PCI(int Bd_Num)
{
return Read_YS6016P(Bd_Num);
}
int CDio::DORead_PCI(int Bd_Num)
{
return DORead_YS6016P(Bd_Num);
}
void CDio::End_PCI()
{
End_YS6016P();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -