1. 程式人生 > >iocomp (iplotx)之ActiveX/VCL工控儀表控制元件

iocomp (iplotx)之ActiveX/VCL工控儀表控制元件

說明書百度文庫:https://wenku.baidu.com/view/b3f38dbefd0a79563c1e7230.html

內容一:

全球1000多家企業所使用的ActiveX/VCL工控儀表控制元件

源自內容:https://www.evget.com/product/1489/

內容二:

iocomp是一個強大的工業控制元件。適用於vb/vc/vs.NET/Delphi/BCB(windows/Linux).囊括了常見的工業控制控制元件,詳見官網說明,原始碼可以到官網下載,也可以到我的資源庫下載:Iocomp.Full Source.v4.02.SP2.7zGettingStarted_iocomp手冊.rar

iplot控制元件安裝好了如圖示:

 

 

結合前面的博文:cport串列埠控制元件的應用,本例使用簡單iocomp控制元件中的一個簡單iplot控制元件,實現接收串列埠資料並顯示曲線。

將控制元件iplot拖進窗體。可以點右鍵/Edit設定常見的屬性。本例演示將只設置標題為空,並新增4路chanel。如圖:

接下來在串列埠接收事件中,畫出曲線即可。使用函式:AddXY(double x,double y);十分方便!!!

void __fastcall TForm1::comptRxChar(TObject *Sender, int Count)  
{  
  AnsiString Str;  
  int y=0;  
  compt->ReadStr(Str,Count);  
  memo_1->Text=memo_1->Text+Str;  
  y=StrToInt(Str);  
  for(int i=0;;i++)  
  {  
    iPlot1->Channel[0]->AddXY(i,y);  
  }  
}  

內容三:

寫在前面:
本次實驗的工作環境:WIN7 64為旗艦版   VS2013  Iocomp ActiveX 402SP1(所以對應的原始碼檔案就是就VisualCppMFCWrappersV4SP1)  
1、 新建一個基於MFC的對話方塊專案,命名為plot曲線繪製,並將兩個按鈕和一個文字框刪掉,建好的專案如下圖

2、在對話方塊的空白處右鍵-插入ActiveX控制元件-選擇iPlotX Control 


3、調整iPlotX Control控制元件的大小及其佈局


4、關聯控制元件變數,變數型別為CiPlotX,改成這個型別是因為為官方提供的原始碼中的類就是這麼命名的!當然你也可以更改原始檔中類的名字,總之,只要這兩個對應起來即可


5、刪除掉自動產生的兩個檔案


6、將官方提供的原始碼中以IPLOT開頭的原始檔和標頭檔案以及font.cpp、font.h、picture.cpp、picture.h複製到工程裡面,並新增進來(並不是所有的檔案都能用到,這個地方為了省事就一起復制進來了)


7、在 plot曲線繪製Dlg.cpp檔案中新增兩個標頭檔案(因為要用到裡面宣告的幾個函式)和額外的初始化程式碼


8、新增定時器訊息響應函式


9、編譯出錯,將這個包含檔案的1去掉,也就是改成
#include "iplotx.h"


10、編譯成功,執行結果如下


附:原始碼檔案包的下載地址

http://www.iocomp.com/Downloads/VisualCPPMFCWrappers.aspx

轉:https://blog.csdn.net/wwwlyj123321/article/details/78896975

內容四:

十步會用IOCOMP–iplotx控制元件

1、 新建專案-MFC-基於對話方塊 
2、 插入ActiveX控制元件-選擇iPlotX Control 
3、右擊該控制元件,新增變數,輸入變數名 
4、類嚮導-(Dlg結尾那個類)新增函式-IplotxInit(用於該控制元件基本引數設定) 
5、在Dlg.cpp中開頭處新增以下程式碼:

#import  "iPlotLibrary.tlb" named_guids
#include "atlbase.h"
using namespace iPlotLibrary;
CComPtr<iPlotLibrary::IiPlotX> PlotComponent;

6、在函式IplotxInit()中新增以下程式碼:

CWnd* pPlotWnd = GetDlgItem(IDC_IPLOTX1);
    IUnknown*  m_iUnknown;
    //Get iDispatch Inteface to Plot Component
    m_iUnknown = pPlotWnd->GetControlUnknown();
    m_iUnknown->QueryInterface(__uuidof(iPlotLibrary::IiPlotX), (LPVOID*)&PlotComponent);
    //Setup Channels
    PlotComponent->RemoveAllChannels();
    PlotComponent->AddChannel();
    PlotComponent->AddChannel();
    PlotComponent->AddChannel();
    PlotComponent->AddChannel();
    PlotComponent->AddChannel();
    PlotComponent->AddChannel();
    PlotComponent->XAxis[0]->Span = 5;
    PlotComponent->Labels[0]->Caption = "曲線圖";

    PlotComponent->GetChannel(0)->TitleText = "曲線1";
    PlotComponent->GetChannel(1)->TitleText = "曲線2";
    PlotComponent->GetChannel(2)->TitleText = "曲線3";
    PlotComponent->GetChannel(3)->TitleText = "曲線4";
    PlotComponent->GetChannel(4)->TitleText = "曲線5";
    PlotComponent->GetChannel(5)->TitleText = "曲線6";
7、類嚮導-新增訊息處理函式OnTimer(); 
8、在OnInitDialog()函式return TRUE前新增以下程式碼:

    IplotxInit();
    SetTimer(1, 10, NULL);
9、在函式OnTimer();中新增以下函式:

    static float i = 10;
    PlotComponent->GetChannel(0)->AddYElapsedSeconds(40*sin(0.01*i));//AddYNow((int)i);
    PlotComponent->GetChannel(1)->AddYElapsedSeconds(40 * cos(0.01*i));//AddYNow((int)i);
    PlotComponent->GetChannel(2)->AddYElapsedSeconds(40 * sin(0.01*i + 1));//AddYNow((int)i);
    PlotComponent->GetChannel(3)->AddYElapsedSeconds(40 * cos(0.01*i + 1));//AddYNow((int)i);
    PlotComponent->GetChannel(4)->AddYElapsedSeconds(40 * sin(0.01*i + 2));
    PlotComponent->GetChannel(5)->AddYElapsedSeconds(40 * cos(0.01*i + 2));
    i++;
    i++;
    i++;

10、按F5鍵。 
效果圖: 
 
原始碼下載:http://download.csdn.net/detail/cracent/9794944

轉:https://blog.csdn.net/Cracent/article/details/66968903