鋼捲資料, 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));
沒有留言:
張貼留言