• 大小: 748KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: 其他
  • 标签: ge  VC  opc  server  source  

资源简介

ge VC opc server source code ,适宜OPC 服务器编程学习

资源截图

代码片段和文件信息

#include “stdafx.h“
#include “Item.h“

#include “opcda.h“
#include se.h> 

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNCREATE(CItem Cobject)

CItem::CItem()
{
Handle = NULL;
  VariantInit(&Value);
Quality = OPC_QUALITY_UNCERTAIN;
Name.Empty();
Connected = FALSE;
}

CItem::~CItem()
{
VariantClear(&Value);
Name.ReleaseBuffer();
}


void CItem::ReadFromDevice()
{
//if not connected no need to read from device
if (!Connected) return;

//Read value from hardware
//in this sample we just do some simple simulation

switch (Value.vt)
{
case VT_BOOL: //BOOL
Value.boolVal = !Value.boolVal;
break;
case VT_I2: //SHORT
Value.iVal += 1;
break;
case VT_UI2: //WORD
Value.uiVal += 1;
break;
case VT_I4: //LONG
Value.lVal += 1;
break;
case VT_UI4: //DWORD
Value.ulVal += 1;
break;
case VT_R4: //Float
Value.fltVal += 0.01f;
break;
case VT_R8: //Double
Value.dblVal += 0.02f;
break;
case VT_BSTR: //String
int n = rand();
SysFreeString(Value.bstrVal);
if ( n > 0x7000 )
Value.bstrVal = SysAllocString(L“This is a string test.“);
else if ( n>0x6000 )
Value.bstrVal = SysAllocString(L“http://www.eehoo.net“);
else if ( n>0x5000 )
Value.bstrVal = SysAllocString(L“Knight.OPC.Server.RDK“);
else if ( n>0x4000 )
Value.bstrVal = SysAllocString(L“eehoo Technology“);
else if ( n>0x3000 )
Value.bstrVal = SysAllocString(L“sales@eehoo.net“);
else if ( n>0x2000 )
Value.bstrVal = SysAllocString(L“Knight.OPC.Server.Test“);
else if ( n>0x1000 )
Value.bstrVal = SysAllocString(L“opc@eehoo.net“);
else
Value.bstrVal = SysAllocString(L“You‘re welcome!“);
break;
}//end switch

//setting quality
Quality = OPC_QUALITY_GOOD;

//setting timestamp
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
SystemTimeToFileTime(&sysTime&this->TimeStamp);
}

void CItem::WriteToDevice(VARIANT *pVar)
{
//Write value to your hardware
//in this sample we just do some simple simulation
VariantClear(&Value);
VariantCopy(&ValuepVar);

//setting quality
Quality = OPC_QUALITY_GOOD;

//setting timestamp
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
SystemTimeToFileTime(&sysTime&this->TimeStamp);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2003-04-09 17:31  help\
     目录           0  2003-04-09 17:31  help\chn\
     文件      300949  2002-11-01 10:20  help\chn\KOSRDK_chn.pdf
     目录           0  2003-04-09 17:31  help\enu\
     文件       42227  2002-11-01 10:48  help\enu\KOSRDK.chm
     文件        3429  2003-04-10 16:26  license.txt
     文件        5025  2003-04-10 16:38  license_chn.txt
     目录           0  2003-04-09 17:31  opcdist\
     文件      158560  1999-03-01 11:27  opcdist\APRXDIST.EXE
     文件       73728  2002-10-21 15:54  opcdist\opccomn_ps.dll
     文件       81920  2002-10-21 15:54  opcdist\OPCENUM.EXE
     文件      118784  2001-04-26 11:19  opcdist\opchda_ps.dll
     文件       77824  1999-03-02 13:55  opcdist\opcproxy.dll
     文件       45056  1999-06-03 11:15  opcdist\opc_aeps.dll
     文件        1085  2002-10-21 09:34  opcdist\readme.txt
     文件        4819  2003-04-10 16:32  readme.txt
     目录           0  2003-04-09 17:31  release\
     文件      237568  2003-04-02 18:03  release\KOSRDK.dll
     文件        6374  2003-04-02 18:03  release\KOSRDK.lib
     文件        7587  2003-04-02 18:07  release\KOSRDKapi.h
     文件       93689  1999-04-08 17:52  release\opcda.h
     目录           0  2003-04-09 17:31  samples\
     目录           0  2003-04-09 17:31  samples\bin\
     目录           0  2003-04-09 17:31  samples\bin\KOSSerial\
     文件       28672  2002-11-25 14:18  samples\bin\KOSSerial\ComDeviceSimulator.exe
     文件       36864  2002-11-25 14:30  samples\bin\KOSSerial\KOSSerial.exe
     文件        1960  2002-11-25 14:54  samples\bin\KOSSerial\ReadMe_chn.txt
     文件        2062  2002-11-26 15:26  samples\bin\KOSSerial\ReadMe_enu.txt
     文件      155648  2002-12-10 11:37  samples\bin\KOSVB.exe
     文件       45056  2002-12-10 15:45  samples\bin\KOSVC.exe
     文件       40960  2002-12-03 16:43  samples\bin\KOSVC2.exe
............此处省略77个文件信息

评论

共有 条评论