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

📄 server1.cpp

📁 DCOM 上位机和嵌入式系统通信
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// Server1.cpp : Implementation of CComServerApp and DLL registration.

#include "stdafx.h"
#include "ComServer.h"
#include "Server1.h"
/**********************************************************************************/
STDMETHODIMP Server1::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_ILoadSystem,
		&IID_IDataSave,
		&IID_IAlarm,
	};

	for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}

void Server1::Read_Sys_Files()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\KJ95SYS.SYS");

//	char fn[60]="E:\\kj95opc\\CONFIG\\KJ95SYS.SYS";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&Files,sizeof(Files),1,file);
	fclose(file);
}


void Server1::Read_Kjsys001()
{
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\KJSYS001.SYS");

//	char fn[60]="E:\\kj95opc\\CONFIG\\KJSYS001.SYS";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&File1,sizeof(File1),1,file);
	fclose(file);

}

void Server1::Read_St_Ini()
{
	// TODO: Add your implementation code here
	FILE *file;
	int i;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\STATION.INI");

	
//	char fn[60]="E:\\kj95opc\\CONFIG\\STATION.INI";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return;
	}
	st_ini[255];
	for(i=0;i<255;i++)
    	fread(&st_ini[i],sizeof(st_ini[0]),1,file);
	fclose(file);
}


void Server1::Read_St_Exd()
{
	// TODO: Add your implementation code here
    FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\STATION.EXD");
//	char fn[60]="E:\\kj95opc\\CONFIG\\STATION.EXD";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&st_exd,sizeof(st_exd),1,file);
	fclose(file);
}

void Server1::Read_Kjsys004()
{
	// TODO: Add your implementation code here
    FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\KJSYS004.SYS");
//	char fn[60]="E:\\kj95opc\\CONFIG\\KJSYS004.SYS";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
		//MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&File4,sizeof(File4),1,file);
	fclose(file);
}


void Server1::Read_kjsys005()
{
	// TODO: Add your implementation code here
	
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\KJSYS005.SYS");
//	char fn[60]="E:\\kj95opc\\CONFIG\\KJSYS005.SYS";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&File5,sizeof(File5),1,file);
	fclose(file);
}

void Server1::Read_Kjsys006()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\KJSYS006.SYS");
//	char fn[60]="E:\\kj95opc\\CONFIG\\KJSYS006.SYS";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&File6,sizeof(File6),1,file);
	fclose(file);
}

void Server1::Read_Cfg0()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\config00.sys");
//	char fn[60]="E:\\kj95opc\\config\\config00.sys";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&Cfg0,sizeof(Cfg0),1,file);
	fclose(file);
}

void Server1::Read_Cfg1()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\config01.sys");
//	char fn[60]="E:\\kj95opc\\config\\config01.sys";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&Cfg1,sizeof(Cfg1),1,file);
	fclose(file);
}

void Server1::Read_Cfg2()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\config02.sys");
//	char fn[60]="E:\\kj95opc\\config\\config02.sys";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&Cfg2,sizeof(Cfg2),1,file);
	fclose(file);
}

void Server1::Read_Cfg3()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\config03.sys");
//	char fn[60]="E:\\kj95opc\\config\\config03.sys";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&Cfg3,sizeof(Cfg3),1,file);
	fclose(file);
}

void Server1::Read_Cfg4()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\config04.sys");
//	char fn[60]="E:\\kj95opc\\config\\config04.sys";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&Cfg4,sizeof(Cfg4),1,file);
	fclose(file);
}

void Server1::Read_Kjsys002()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\KJSYS002.SYS");
//	char fn[60]="E:\\kj95opc\\CONFIG\\KJSYS002.SYS";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&File2,sizeof(File2),1,file);
	fclose(file);
}


void Server1::Read_Kjsys003()
{
	// TODO: Add your implementation code here
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\KJSYS0033.SYS");
//	char fn[60]="E:\\kj95opc\\CONFIG\\KJSYS0033.SYS";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&File3,sizeof(File3),1,file);
	fclose(file);
}


void Server1::Read_St_Xinxi()
{
	// TODO: Add your implementation code here
	
	int i;
	FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\STATION.DAT");
//	char fn[60]="E:\\kj95opc\\CONFIG\\STATION.DAT";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	for(i=0;i<255;i++)
		fread(&station_xinxi[i],sizeof(station_xinxi[0]),1,file);
	fclose(file);
}

void Server1::Read_yddd()
{
	// TODO: Add your implementation code here
    FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\kj95yddd.DAT");
//	char fn[60]="E:\\kj95opc\\CONFIG\\kj95yddd.DAT";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&yddds,sizeof(yddds),1,file);
	fclose(file);
}

void Server1::Read_qydd()
{
	// TODO: Add your implementation code here
    FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\kj95qydd.DAT");
//	char fn[60]="E:\\kj95opc\\CONFIG\\kj95qydd.DAT";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&station_qydd,sizeof(station_qydd),1,file);
	fclose(file);
}

void Server1::Read_devpt()
{
	// TODO: Add your implementation code here
    FILE *file;
	char path[_MAX_PATH]="";
	unsigned char tmp[_MAX_PATH]="";

	char fn[_MAX_PATH];
	_mbscpy(tmp,Curpath);
	unsigned_To_signed(tmp,path);
    strcpy(fn,path);
    strcat(fn,"\\CONFIG\\configdc.sys");
//	char fn[60]="E:\\kj95opc\\CONFIG\\kj95qydd.DAT";
	if ((file=fopen(fn,"rb+"))==NULL)
	{
//		MessageBox(NULL,"文件打开错误!!","提示!",MB_OK);
		return ;
	}
	fread(&devpoint,sizeof(devpoint),1,file);
	fclose(file);
}

STDMETHODIMP Server1::Set_Two_Min_Flag(int Flag)
{
	// TODO: Add your implementation code here
    minute_flg=Flag;
	return S_OK;
}

STDMETHODIMP Server1::Set_One_Hour_Flag(int Flag)
{
	// TODO: Add your implementation code here
    hour_flg=Flag;
	return S_OK;
}

STDMETHODIMP Server1::Get_NowData(int NowDataNo,int *addr_sensor,float *nowdata,float *data1,float *data2,float *data3,float *data4,int *timeflag)//
{
	// TODO: Add your implementation code here
    *addr_sensor=Timedata.NowdataRec[NowDataNo].addr_sensor;
	*nowdata=Timedata.NowdataRec[NowDataNo].nowdata;
	*data1=Timedata.NowdataRec[NowDataNo].data1;
	*data2=Timedata.NowdataRec[NowDataNo].data2;
	*data3=Timedata.NowdataRec[NowDataNo].data3;
	*data4=Timedata.NowdataRec[NowDataNo].data4;
	*timeflag=Timedata.NowdataRec[NowDataNo].timeflag;
	return S_OK;
}

STDMETHODIMP Server1::Get_File3(int Sensor_ind,byte *property)//Sensor_unit_struct00 *Tmp, sensor_unit_struct *file3)
{
	// TODO: Add your implementation code here
	*property=File3.file3[Sensor_ind].property&0xf;
	return S_OK;
}

int Server1::Get_Bltx(BYTE fzNo, BYTE PortNo)
{
	BYTE Tmp;
	int Val;
	Tmp=(File4.info[fzNo].state_type & 0x0f);
	switch(Tmp)
	{
	case 0:
		Val=Cfg0.cfg0[File4.info[fzNo].fzindex][PortNo].sensor;
		break;
	case 1:
		Val=Cfg1.cfg1[File4.info[fzNo].fzindex][PortNo].sensor;
		break;
	case 2:
		Val=Cfg2.cfg2[File4.info[fzNo].fzindex][PortNo].sensor;
		break;
	case 3:

⌨️ 快捷键说明

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