⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ycclass.cpp

📁 基于PC104平台
💻 CPP
字号:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                 File name: ycclass.cpp
//  This file define the functions of base module yc
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "ycclass.h"
void CYc::ycinit()
{
	int i;
	if ((hardwareset[C3718].state == FALSE) || (datasource.board_yc == 0)) return;
	ADWays = SwitchWays = 0;
	for (i = 0; i < MAXBOARDYC; i++) BoardYc[i] = 0;
}

void CYc::selectayc()
{
	BYTE temp;
	if (ADWays == 0) {
		switch(SwitchWays) {
			case 0:	temp = 0x07;	break;
			case 1:	temp = 0x06;	break;
			case 2:	temp = 0x05;	break;
			case 3:	temp = 0x04;	break;
			case 4:	temp = 0x03;	break;
			case 5:	temp = 0x02;	break;
			case 6:	temp = 0x01;	break;
			case 7:	temp = 0x00;	break;
			case 8:	temp = 0x0f;	break;
			case 9:	temp = 0x0e;	break;
			case 10:	temp = 0x0d;	break;
			case 11:	temp = 0x0c;	break;
			case 12:	temp = 0x0b;	break;
			case 13:	temp = 0x0a;	break;
			case 14:	temp = 0x09;	break;
			case 15:	temp = 0x08;	break;
		}
		outportb(hardwareset[C3724].address + 2, temp);			// select 4067 way
	}
}

void CYc::startayc()
{
	int status, StopChan = 15;

	status = inportb(hardwareset[C3718].address + 8);
	if (status & 0x80) return;					// conversion incomplete
	outportb(hardwareset[C3718].address + 8, 0);				// clear flag
	outportb(hardwareset[C3718].address, 0);					// trigger a conversion
	ADWays++;						  				//to flag the A/D ways
	if (ADWays > StopChan) {
		ADWays = 0;
		SwitchWays++;								// increace the 4067 ways
		if (SwitchWays > 15) SwitchWays = 0;//if >15
	}
}

void interrupt ADNewHand(...)
{
	INT8U RawL, RawH, RealL;
	INT16U Real;
	INT16U ADChan;

	asm cli;
	RawL = inportb(hardwareset[C3718].address);
	RawH = inportb(hardwareset[C3718].address + 1);

	RealL = RawL / 16;
	Real = RawH * 16 + RealL;						// get data

	ADChan = RawL - RealL * 16;					// get ad channel


	if (datasource.board_yc > 16)
		ADChan = (ADChan / 8) * 128 + (ADChan % 2) * 64
				  + SwitchWays * 4 + (ADChan % 8) / 2;

	// filter by average 1/2
	BoardYc[ADChan] = (BoardYc[ADChan] + Real) / 2;

	outportb(0x20, 0x20);					// end of interrupt
	asm sti;
}

void CYc::ycdeal()
{
	int i,j;
	unsigned int test=0x01;
	unsigned int test1;
	unsigned int temp1,temp2;
	int temp_yc[512];    //for save board yc

	if(datasource.total_yc>512)return;

	// convert ad original to binary code
	for (i = 0; i < datasource.board_yc; i++) {
		if (BoardYc[i] >= 0x802) temp_yc[i] = (BoardYc[i] - 0x800) & 0xfff;
		else if (BoardYc[i] <= 0x7fd) temp_yc[i] = (BoardYc[i] & 0xfff) | 0x800;
		else temp_yc[i] = 0;
	}

	for (i = 0; i < datasource.protect_yc; i++)
		temp_yc[i + datasource.board_yc] = lfp_yc[i];   //here for save basler yc

	for (i = 0; i < datasource.zlp_yc; i++)
		temp_yc[i + datasource.board_yc + datasource.protect_yc] = zlp_yc[i];   //here for save basler yc

	for (i = 0; i < datasource.total_yc; i++) {
//		if(temp_yc[i]>2047)  temp_yc[i]/=10;
		test1=test;
		temp1=i/16;
		temp2=i-temp1*16;
		test1<<=temp2;
	// if not set, send yc to display
		if(!(yc_info.yc_set_bit[temp1]&test1)) yc_info.yc_value[i]=temp_yc[i];
	// if sign find send in nature order
//		if((yc_sequence[0][0]==4096)&&(yc_sequence[1][0]==4096))
		for(j=0;j<10;j++)port_yc[j][i]=yc_info.yc_value[i];
/*	else  // send in special order
	{
	  for(j=0;j<4;j++)// send to first 4 port
		if((yc_sequence[i][j]!=2048)&&(yc_sequence[i][j]<=512))
		  port_yc[j][yc_sequence[i][j]]=yc_info.yc_value[i];
	  if((yc_sequence[i][4]!=2048)&&(yc_sequence[i][4]<=512))
		for(j=4;j<8;j++) // send to last 4 port
		  port_yc[j][yc_sequence[i][4]]=yc_info.yc_value[i];
	}*/
  }
}
//////////////////////////////////////////////////////////////////////////////////////
// The end of ycclass.cpp
//////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -