|
How do you "auto-scale" data points on a graph?
the data will be received at a constant frequency.
I will be receiving data from a CAN/bluetooth gateway on a vehicle.
How do I go about graphing and receiving those data points and putting them on both a line and bar graph?
Thanks.
|
|
|
|
|
This is a very generic question, but I'll give it a try:
1. Separate the data from the viewing of the same data...
2. use dynamic memory assignment if you don't know the amount of data that you'll need.
3. think about how many history do you need to maintain.
4. create a control derived from a CStatic called CGraph.
5. Override the OnPaint function of that control in order to draw the axis, the captions and the labels.
6. Draw each point depending on a scale factor.
7. if the graph needs to be scrolled, think about a scrolling bar... (think about drawing the part needed ni order to avoid to collapse too much the CPU)
Hope this helps...
|
|
|
|
|
I think you need to enable the "toolwindow" style (i.e. its equivalent in C#).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi !
I have a very basic question about C++ :
I want to allocate on the heap a two-dimensionnal array. I tried to do this :
int* pArray=new int[x][y];
but of course it didn't work, so I did that :
int* pArray=new int[x*y];
and each time I need to acces my array, I calculate the x/y position. It works, but still, I'm curious : is it possible to allocate memory in such a way that I can then use the usual notation for a multidimensionnal array : Array[x][y]=z.
Thank you for your help !
Jerome
|
|
|
|
|
int **pArray = new int*[x];
for(int i=0; i<x; i++)
pArray[x] = new int[y]; This will let you use pArray[x][y] = z . To deallocate this array, do this:
for(int i=0; i<x; i++)
delete [] pArray[x];
delete [] pArray; Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Great ! Thanks Ryan !
Jerome
|
|
|
|
|
You're welcome
BTW. That was one heck of a speedy reply
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi everyone!
I have to get the text from a ms word document (.doc) and save the text to a text file (.txt).
Have any of you guys done this? Or can you give me a hint where to start?
majo
|
|
|
|
|
Here's one way using Word Automation:
CString strFileName;
_Application app;
Documents docs;
_Document doc;
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
vtFalse((short) FALSE),
vtTrue((short) TRUE),
vtDoc((short) 0),
vtText((short) 2),
vtRtf((short) 6),
vtHtml((short) 8);
if (app.CreateDispatch("Word.Application") == TRUE)
{
docs = app.GetDocuments();
m_ebDocName.GetWindowText(strFileName);
doc = docs.Open(COleVariant(strFileName), vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
strFileName.Replace(".doc", ".txt");
doc.SaveAs(COleVariant(strFileName),
vtText,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional);
docs.Close(vtFalse, vtOptional, vtOptional);
app.Quit(vtOptional, vtOptional, vtOptional);
}
|
|
|
|
|
Thanks a lot!
I will try this...
majo
|
|
|
|
|
Here is a static PINT varible: temp.
I want to store the value "12" to *temp, and my program coded like below
static PINT temp;
* temp=12;
I can succeed in compiling it, but there is an error when running it:
The instruction at "0x00406a3a" referenced memory at"0x00000000". The memory could not be "written".
What is the problem? How can solve it?
Thank you in advance!
|
|
|
|
|
Try:
static PINT temp;<br />
temp = new int;<br />
*temp = 12;
|
|
|
|
|
Obviously temp doesn't point to anything. You need to point it to an integer before attempting to dereference it.
onwards and upwards...
|
|
|
|
|
I see, after seeing your explanation
Can I ask another question?
First I completet the below sentences:
PINT temp;
temp=new int;
Then I have a PVOID varible temp2,which is to be applied like
temp=(PINT)temp2;
Is it right after twice times of putting the pointer?
Thank you!
|
|
|
|
|
Hi all,
i have a SYSTEMTIME that represents the hour '03:02:25 PM' i want to
represent this time as STRING!
i am not using MFC, i use ATL/Win32API
can any1 help?
thanks in advanced,
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
strftime will probably do what you ask.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
thanks for the reply!
this is what i use:
void CSimpleDlg::SetStartTime(SYSTEMTIME& stStart)
{
wchar_t* wcStartTime = new wchar_t[MAX_SIZE_STRING_TIME];
wcsftime(wcStartTime,MAX_SIZE_STRING_TIME,L"%H:%M:%S",&stStart);
}
i get a compilation error regarding last parameter should be of 'tm' struct.how do i convert from SYSTEMTIME to tm?
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
you might also do it that way:
<br />
wchar_t* wcStartTime = new wchar_t[MAX_SIZE_STRING_TIME];<br />
swprintf(wcStartTime, "%i:%i:%i", stStart.wHour, stStart.wMinute, stStart.wSecond);<br />
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thanks a lot man, you really helped me.....
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
You're welcome!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi again,
i need another help....
i want the system to conver the time to string as given from the SYSTEMTIME
(i.e - if the SYSTEMTIME was 03:02:03 AM then the string should be 03:02:03 AM and if the SYSTEMTIME was 15:02:03 then the string should be accordingly 15:02:03)
can u help me again plz?
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Repeat the question... I'm a novice speaking english, but what you've written have nosense... (I think)
|
|
|
|
|
The values in the SYSTEMTIME structure are in no particular format. It's up to you to format them into a variable. For example:
char str[32];<br />
SYSTEMTIME st;<br />
GetSystemTime(&st);<br />
sprintf(str, "%02u:%02u:%02u", st.wHour, st.wMinute, st.wSecond);
|
|
|
|
|
The WIN32 api has some powerful functions for formatting SYSTEMTIME vars. See GetDateFormat and GetTimeFormat in the docs.
onwards and upwards...
|
|
|
|
|
Hello,
I have a problem ... I want to capture the desktop and save it in a 24Bit bitmap ... my desktop can be 256, 16bit or 32bit color.
How can I do that ? It works fine if the desktop is in 24bit ... but I want to convert a HBITMAP from 256, 16bit, 32bit to 24bit ... I hope I will not have to convert it manualy by saveing it byte by byte .... I hope there is something in windows that can take care of it ... because I saw 15Bit color and God knows many these types can be and I hope I don't have to take care of all... Please if anone can help me... !!! thanks !!!
|
|
|
|