1. 請下載兩個檔案
- NGO_CL_Installer.msi
- setup.exe
2. 安裝步驟如下:
3. VC++專案, 請於專案屬性加入下述兩點路徑
- Inlcude Path : c:\acl3app\src\common\inc
- Library Path : c:\acl3app\lib
4. 即可進行專案編譯
目前NGO common library完成度已接近80%, 起先顧及bug太多, 與方便修正的即時性, 皆先發佈source code給同仁編譯使用, 但這麼一來就容易造成版本的問題及維護整合的困難性
是該以library package的形式, 後續發佈給大家使用, 便想到以封裝成install檔案, 不知可行性如何??
經過實際試做後, 建議可以先針對下述兩點, 略做規劃:
第一. 要發佈哪些檔案??
1. common.lib (NGO common library)
2. mqoa.dll (MSMQ library)
3. msado15.dll (MS ADO library)
4. oncrpcms.dll (ONC rpc library for MS)
5. oncrpc.dll (ONC rpc library)
6. head file
第二. 要如何配置目錄路徑
c:\rcm3app
---> \lib (存放*.dll and *.lib)
---> \src\common\inc (存放*.h)
第三. 如何使用Visual Studio製作安裝檔? (可以參考下列推薦網站連結唷!!)
在建立新專案時, 總是要逐一設定專案屬性的輸出目錄 / include目錄 / library目錄, 雖有複製貼上的神技, 但有沒有方法可以變成自行定義的預設初始化路徑...
只要編輯下述兩個檔案, 即可輕輕鬆鬆建立新專案
x86 (win32) : Microsoft.Cpp.Win32.v100.props
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets\v100\Microsoft.Cpp.Win32.v100.props
x64 (win32) : Microsoft.Cpp.x64.v100.props
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsets\v100\Microsoft.Cpp.x64.v100.props
開啟編輯上述任一檔案時, 注意下面的文字結構, 黃色標示部份, 為自行定義加入的路徑變數, 存檔再重新開啟visual studio就可以看到, 已自動加入專案屬性的目錄路徑
<PropertyGroup>
<OutDir>$(AppBinPath)\</OutDir>
<IncludePath Condition="'$(IncludePath)' == ''">$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(AppDirPath)\src\common\inc;$(AppDirPath)\src\inc;</IncludePath>
<LibraryPath Condition="'$(LibraryPath)' == ''">$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64;$(AppDirPath)\lib;$(AppDirPath)\src;$(AppDirPath)\src\common\dll;</LibraryPath>
</PropertyGroup>
1. 作為讀取參數設定檔之用途
2. INI file format (內容嚴禁空白)
[SectionName]
key=value
[Host]
ipaddress=192.168.19.1
port=9999
[RCM3]
ipaddress=192.168.19.2
port=8888
PS: 將上述(2)內容存檔於C:\ipaddress.ini
ex:
#include “IniHandler.h”
main (void)
{
/* 建立 INI file handler */
IniHandler ini_hand;
/* 打開INI file */
ini_hand.open ("c:\\ipaddress.ini");
/* 讀取所有的Section Name */
vSectionNames_T names = ini_hand.readSectionNames ();vSection_T section;
/* 逐一以Section Name, 讀取該Section內所有的key value */
for (int i=0; i<(int)names.size(); i++) {
ap_log (DBUG, "get the tag %s", names[i].c_str());section.clear ();
/* 帶入section name, 讀取 key-value */
section = ini_hand.readKeyValues ((char *)names[i].c_str());/* 逐一印出key-value */
for (int j=0; j<(int)section.size(); j++) {
ap_log (DBUG, "key = %s, values = %s", section[j].key, section[j].value);
}
}
/* 關閉 INI file */
ini_hand.close ();
}
#設置計時器, 以給定的MQ為觸發對象
TimerHandler::TimerHandler (char *mq_name);
mq_name: process專屬的MQ名稱
ex:
TimerHandler timer (MQ_EDPLCRCV);
#新增定時觸發事件
TimerHandler::add (char *tm_name, int msec, int msg_id, void *msg, int msg_size);
tm_name: 定時事件名稱
msec : 間隔時間 (毫秒 milli-seconds)
msg_id: 觸發事件代碼
msg: 觸發資料
msg_size: 觸發資料長度
ex:
timer.add (“Timer_AliveMsg”, 30000, MSG_TIMER_ALIVEMSG, 0, 0);
timer.add (“Timer_Hello”, 30000, MSG_TIMER_HELLO, "hello world", strlen("hello world"));
#啟動/停止/重置
TimerHandler::set_enable (char *tm_name, bool run_it);
tm_name: 定時事件名稱
run_it: 啟動/重置(enable), 停止(disable)
ex:
timer.set_enable (“Timer_AliveMsg”, true);
timer.set_enable (“Timer_AliveMsg”, false);
#移除定時觸發事件
TimerHandler::remove (char *tm_name);
tm_name: 定時事件名稱
ex:
timer.remove ("Timer_AliveMsg");
#設置間隔時間 (milli-seconds)
TimerHandler::set_interval (char *tm_name, int msec);
tm_name: 定時事件名稱
msec: 間隔時間 (毫秒 milli-seconds)
ex:
timer.set_interval ("Timer_AliveMsg", 10000);
鋼捲資料, ex:鋼捲號碼1830912, 厚度12mm, 重量3600kg
範例一.
試將參數化資料, 以MSMQ傳送至pdimgr
#將鋼捲資料, 以參數化方式送出至MSMQ
ApMsgHandler ApMQ = ApMsgHandler (MQ_SYS);
msginfo_body_T msg_body; memset (&msg_body, 0x00, sizeof(msginfo_body_T));
msg_body.argv[0].i16 = (short) 12;
msg_body.argv[1].i32 = (int) 3600
memcpy (msg_body.argv[2].chr, "1830912", 7);ApMQ.send (MQ_PDIMGR, PdiMgrMsg::COILDATA, &msg_body);
#將鋼捲資料, 自MSMQ以參數化方式取出
ApMsgHandler ApMQ = ApMsgHandler (MQ_PDIMGR);
msginfo_body_T *pMsgData = (msginfo_body_T *)ApMQ.getMsgArg();short thickness = pMsgData->argv[0].i16;
int wgt = pMsgData->argv[1].i32;
char coilid[12] = "";
strcpy (coilid, pMsgData->argv[2].chr);
範例二.
試將連續性或結構性資料, 以MSMQ傳送至pdimgr
struct PDI {
char coilid[12]; // 鋼捲號碼
int thk; // 厚度
int wgt; // 重量
};
#將鋼捲資料, 以結構性方式送出至MSMQ
ApMsgHandler ApMQ = ApMsgHandler (MQ_SYS);
struct PDI pdi_data;
memcpy (pdi_data.coilid, "1820912", 7);
pdi_data.thk = 12;
pdi_data.wgt = 3600;
ApMQ.send (MQ_PDIMGR, EP01, &pdi_data, sizeof(pdi_data));#將鋼捲資料, 自MSMQ以結構性方式取出
ApMsgHandler ApMQ = ApMsgHandler (MQ_PDIMGR);
struct PDI *ptr = (struct PDI*)ApMQ.getMsgArg();struct PDI pdi_data;
memcpy (&pdi_data, ptr, sizeof(pdi_data));