这段wicc脚本应该是通过odbc将数据写到access里的,具体看不明白,请高手指点一下。最好加上注释。
#include "apdefap.h"
int gscAction( void )
{
// WINCC:TAGNAME_SECTION_START
// syntax: #define TagNameInAction "DMTagName"
// next TagID : 1
// WINCC:TAGNAME_SECTION_END
// WINCC:PICNAME_SECTION_START
// syntax: #define PicNameInAction "PictureName"
// next PicID : 1
// WINCC:PICNAME_SECTION_END
__object *pADOCnnection;
__object *pADORecordSet;
//SYSTEMTIME sysTime;
static char s_strTime【21】;
float fJd,temp1;
#pragma code("kernel32.dll");
void GetLocalTime(SYSTEMTIME* lpst);
#pragma code();
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
if(!GetTagBit("放料记录")) return 0;
GetLocalTime(&sysTime);
sprintf(s_strTime,"%04d-%02d-%02d %02d:%02d:%02d",
sysTime.wYear, sysTime.wMonth, sysTime.wDay,
sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
pADOCnnection = __object_create("ADODB.Connection");
if( pADOCnnection != NULL )
{
pADOCnnection->Open("DSN=AAA");
if( pADOCnnection->State !=0 )
{
pADORecordSet = __object_create("ADODB.RecordSet");
if( pADORecordSet != NULL )
{
pADORecordSet->Open("SELECT * FROM CMJL",pADOCnnection,2,3);
pADORecordSet->AddNew();
pADORecordSet->Fields("放料时间")->Value = s_strTime;
pADORecordSet->Fields("下料仓号")->Value = GetTagByte("CM_CH");
pADORecordSet->Fields("仓下料设定值")->Value = GetTagFloat("CM_SET");
pADORecordSet->Fields("仓下料实际值")->Value = GetTagFloat("CM_RLL");
pADORecordSet->Update();
pADORecordSet->Close();
__object_delete(pADORecordSet);
}
}
pADOCnnection->Close();
__object_delete(pADOCnnection);
}
return 0;
}