|
Hello c++ friends!
I am currently working on a handy program that scans temperature/fan control for boat engines. However I am stuck at the moment, I want it to write the average values (average value, maximum values and minimum values) to a text file hourly/daily or whatever time i define. Below is some code..
This one works just fine, it writes current temperature to a text file once every second:
void CAnalogTag::StoreData (double dRawData, BOOL bLive)
{
double dValue;
EnterCriticalSection(&m_csAccess);
m_dPrevRawValue = m_dLatestRawValue;
m_dLatestRawValue = dRawData;
LeaveCriticalSection(&m_csAccess);
if (m_pSecondsBin && bLive)
m_pSecondsBin->StoreDataPoint(dRawData);
std::ofstream ScanFile ("scanfile.txt", std::ios_base::app);
ScanFile << "Temperature: " << dRawData << endl << "Offset: " << m_dOffset << "\n";
ScanFile.close();
}
""
That works just fine, I think below is where the values that i want are stored, but I don't know how or if it's even possible to extract them:
""
void CAnalogTag::StoreData(void *pData, void *pMinData, void *pMaxData, long nNumPts, int nTrendType)
{
CArray<double, double&=""> *pTrendData = (CArray<double,double&> *)pData;
CArray<double, double&=""> *pMinTrendData = (CArray<double,double&> *)pMinData;
CArray<double, double&=""> *pMaxTrendData = (CArray<double,double&> *)pMaxData;
// store an entire array of data to the bin
switch (nTrendType)
{
case trend_seconds:
if (m_pSecondsBin)
m_pSecondsBin->SetEntireTrend(pTrendData, pMinTrendData, pMaxTrendData, nNumPts);
break;
case trend_minutes:
if (m_pMinutesBin)
m_pMinutesBin->SetEntireTrend(pTrendData, pMinTrendData, pMaxTrendData, nNumPts);
break;
case trend_hours:
if (m_pHoursBin)
m_pHoursBin->SetEntireTrend(pTrendData, pMinTrendData, pMaxTrendData, nNumPts);
break;
case trend_days:
if (m_pDaysBin)
m_pDaysBin->SetEntireTrend(pTrendData, pMinTrendData, pMaxTrendData, nNumPts);
break;
}
}
""
Any help would be appreciated.. Been stuck here for the last few days, and i think my boss is losing his patience
Cheers,
Nalle
|
|
|
|
|
i'm a layman for VC++, can anyone be kind to recommend me a book for accidence.thanks a lot
|
|
|
|
|
Microsoft Press books can be preferred.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
thank you
|
|
|
|
|
Do you want to learning VC
whitesky
|
|
|
|
|
I used IHTMLBodyElement to set the background picture,but I can't set the repeat property,and background-position-x,background-position-y.
What can I do?
|
|
|
|
|
I have solved the problem.
;)
|
|
|
|
|
I'm trying to learn C++, so I'm just building some sample classes to get some experience. I have a matrix class in which I have implemented an addition operator that looks like this...
matrix operator + (matrix& toAdd)
{
// Create a zero matrix to output.
matrix output = matrix(toAdd.get_rows(), toAdd.get_cols(), 0);
// A temporary variable for the sum of each element
double val;
// Go through every element and add them together
// Stick the result in the output matrix
for(int i = 0; i < nrows; i++)
{
for(int j = 0; j < ncols; j++)
{
// The array indices are always 1 less
// than the row or column number
val = elements[i][j] + toAdd.get_el(i+1,j+1);
output.set_el(i+1, j+1, val);
}
}
return output;
}
It's nothing fancy... hopefully you won't need to see the whole class to understand the problem.
I wanted to pass it a matrix by reference in case the matrix is huge. I figure it'd probably be good form to add a const so that it is
matrix operator + (const matrix& toAdd)
but if I add that in, it doesn't compile. I get errors like
"passing 'const matrix' as 'this' argument of 'int matrix::get_rows()' discards qualifiers"
I get one of those errors for every time I use a member function of toAdd. Without const, everything's fine, but the matrix referred to as toAdd is vulnerable to changes. I am using gcc (or, more accurately, g++) to compile. Let me know if you need more information. Thanks!
-Mark
|
|
|
|
|
a const object can handled by a member function qualified by const
never say die
|
|
|
|
|
change your prototype into :
matrix operator + (const matrix& toAdd) const
for the same, if you say that the parameter toAdd is const , then toAdd.get_el() will crash if matrix::get_el() is not defined as const member function
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
MALDATA wrote: "passing 'const matrix' as 'this' argument of 'int matrix::get_rows()' discards qualifiers"
Make the get member functions const:
int matrix::get_rows() const<br />
{ ... }
You can only call const methods on a const object.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
codes here:
//////////////////////////////////////
// fill the screen with pure color
CWindowDC dc(NULL);
CRect rect;
GetWindowRect(&rect);
CBrush br;
br.CreateSolidBrush(RGB(255, 0, 0));
dc.FillRect(&rect);
the problem is :
I want to recover to the status that the screen is not filled , how to recover?
does InvalidateRect can do it ?
why I refresh the desktop, the screen is recovered to the old style?
please give me some help, waiting for answers online!
my Email is : xuwenq88@126.com
Just my interest for these common things
|
|
|
|
|
|
Simply to repaint the desktop use this
::InvalidateRect(0, NULL, TRUE);
nave
|
|
|
|
|
hello everyone!
I have just started learning VC++. Can anyone suggest me a good book for starting with VC++. I know C++ well. I dont have any idea of MFS, SDK etc.
Plz suggest me something,
Thanks,
|
|
|
|
|
I suggest posting this in the VC++/MFC forum. I am certain you'll get a lot of suggestions there.
Would help to know your technical/coding background.
|
|
|
|
|
This is the Visual C++ / MFC forum
|
|
|
|
|
Guess I was the one confused. Thought I was in suggestions at the time.
|
|
|
|
|
|
I'll second that recommendation. Best getting started book on MFC for any level programmer. Problem is it's out of print but worth the price the used copies are going for nowadays.
|
|
|
|
|
Which Book is in out of print, I hope u r not mentioned clearly.
|
|
|
|
|
sach!! wrote: have just started learning VC++. Can anyone suggest me a good book for starting with VC++. I know C++ well. I dont have any idea of MFS, SDK etc.
Learn VC++ in 21 days! good book to start Vc++ step by step!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
In a Grid control (TstringGrid of BC++) when I click on the scroll bar a message box appears and in parallel the scroller scroll down (in win xp os). But in win2000 the Scroller scrolls only after closing the message Box. Can any body tell how to change the behavior in XP so that it works like win2000?
|
|
|
|
|
Hello all! i have been working on a project that has several forms, and one of them must be opened in the second monitor if available, i am a newbie in c++ but is there any way to achieve this?
many might laugh at me because i am different, i laugh at them because they are the same
|
|
|
|
|
Hi,
I am using Visual Studio 2005. I was using some macros in my code. What I found was that I was unable to reference __LINE__ macro. The output of macros was wrong. I have created a sample and following is the code snippet -
#define TMP_THIS_FILE SimpleTrace_cpp<br />
#define TMP_EVAL(_value_) _value_<br />
#define TMP_(Id) TMP_EVAL(TMPFUNC_) ## TMP_EVAL(Id) ## TMP_EVAL(_) ## TMP_EVAL(TMP_THIS_FILE) ## TMP_EVAL(__LINE__)<br />
<br />
#define doTrace TMP_(CALL)
At line number 22 in my CPP file, If I make a call to -
doTrace();
Then the output should be
TMPFUNC_CALL_SimpleTrace_cpp22()
Instead the compiler is generating -
TMPFUNC_CALL_SimpleTrace_cpp()
And I get a compiler error saying
e:\projects\temp\temp\SimpleTrace.cpp(22) : error C3861: 'TMPFUNC_CALL_SimpleTrace_cpp': identifier not found
Any idea whats going wrong with the compiler? Also do I have to add any compiler switches to use __LINE__ in VS 2005?
S o h a i l K a d i w a l a
modified 21-Apr-21 21:01pm.
|
|
|
|