YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


Real time software and HMI Software with Trend Chart VC++ Source Code

 
 

What is Trend Display?

Trend Display is an area to show time dependent values in form of curves for different purposes. this is designed for real time software and HMI & SCADA Software For example if you want to monitor some hardware quantities that are time dependent such as voltage, temperature and something like these the Trend Display is a good area to display the changes of those signals value in different times.

How does it work?

For this purpose I've created a CFormView based class called CTrendView with related document and frame classes ( CTrendDoc and CTrendFrame ). By using these classes in a MDI project you can have a multiple documents Trend Display. It's very easy to use. Just you should register the Trend's document templates in InitInstance() method of application class.

Collapse | Copy Code
// declaration in header file 
CMultiDocTemplate* pDocTemplate;  
m_pTrendTemplate = new CMultiDocTemplate(IDR_TrendTestTYPE, 
        RUNTIME_CLASS(CTrendDoc), 
        // custom MDI child frame 
        RUNTIME_CLASS(CTrendFrame), 
        RUNTIME_CLASS(CTrendView)); 
AddDocTemplate(m_pTrendTemplate); 

Also because of using a CFormView class you need to add a dialog resource (IDD_FORMVIEW) to your project. Now you can open Trend Display in any way you desire for example through a menu or toolbar.

Collapse | Copy Code
void CTrendTestApp::OnTrendOpen() 
{ 
    m_pTrendTemplate->OpenDocumentFile(NULL); 
}

A ruler that moves horizontally, signifies the current time. This ruler moves pixel by pixel by a timer, which is used in CTrendView class. There is no need to any special code for invalidating the OnDraw function when Trend window moves, resize or disappears behind the other windows, because there is a buffer to hold the values for each signal.

Collapse | Copy Code
void CTrendView::DrawTrend() 
{ 
    m_pDC = GetDC(); 
    for(BYTE j=0 ; j < m_pDoc->m_noOfPoint ; j++) 
    { 
        CPen pen(PS_SOLID,1,m_pDoc->m_pPoint[j].Color); 
        m_OldPen = m_pDC->SelectObject(&pen); 
        for(int i=1 ; 
            i < m_pDoc->m_pPoint[j].BufferedValue.GetSize(); 
            i++) 
        { 
            m_portion = 
                (m_pDoc->m_pPoint[j].BufferedValue[i-1] -
                m_pDoc->m_pPoint[j].Min)
                / m_pDoc->m_pPoint[j].Range; 

            m_pDC->MoveTo(m_trendRect.left+i-1,
                int(m_trendRect.bottom - 
                m_portion*m_trendRect.Height())); 

            m_portion = (m_pDoc->m_pPoint[j].BufferedValue[i] - 
                m_pDoc->m_pPoint[j].Min)
                / m_pDoc->m_pPoint[j].Range; 

            m_pDC->LineTo(m_trendRect.left+i, 
                int(m_trendRect.bottom -
                m_portion*m_trendRect.Height())); 
        } 
        m_pDC->SelectObject(m_OldPen); 
    } 
    InvalidateRect(CRect(m_trendRect.left + 
        m_timeStep-1, m_trendRect.top, 
        m_trendRect.left+m_timeStep+1,m_trendRect.bottom)); 

    ReleaseDC(m_pDC); 
}

I didn't use any options for this project but it could has many options. For example the back ground color and signals color can be changeable and grids, scales and scan time as well. May be in my upcoming version I add these options to my code. But it's better that you put these possibilities as you desire. The attached demo project is created and compiled with MFC7, so to compile it, you need VS.NET but it's very easy to add source code to your MFC6 based project. Please feel free to send your comments, questions and suggestions about this Trend Display. Thank you in advance.

 

 

 

Copyright ?1998-2022 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net