|
Iain Clarke wrote: so two overlapping ONs become one longer ON instead.
that is easier still. Use a queue or a ring-buffer as I mentioned, they can be used interchangeably, though a queue will require mutexing if it does not have implicitely shared in the design. When something is "turned on" put it on the on-queue.
When you output, check the on-queue, if anything is present, check it for expiration, if the time has expired, pop it off, if it has not expired, then send output. Pretty simple asynchronous operation. And you don't even have to do a mid-queue removal either. Even if item two has expired, and item one has not, you will want to output. When item 1 expires, you pop it off, check the next one for expiration, and pop it off. You only care if anything is left in the queue, i.e. the queue is not empty, then output.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Iain Clarke wrote: I have a series of inputs to my software.
Imagine... If Input A - turn an output on in 5 seconds for 2 second.
If Input B, turn an output on in 3 seconds for 2.5 seconds.
I deal with this pretty regularly, all our inputs are asynchronous. I guess I should ask, what is the output? Do you want to blend the output of two things during a "double on" situation? do you want to put one at higher priority? How exactly do you wish to handle a double on situation. Forget the implimentation at the moment, start from the statement of action. You have multiple inputs.... double off, no problem, no output. Single on, single off, single output, again no problem. So then comes the doozy, the exception case, double/many on, what do you see as the preferred output? what is the output? where is it going? Is .1 second check the preferred output format? would you alternate between any/all outputs? is there a priority involved where one output should always be first?
I have one situation with position data where sources number n, some unknown number at startup, 1 to many. The code channels the input to a variety of parallel threads to handle the data as rapidly as it comes in. The output is simply stored in an implicetly shared structure that is read from another thread, synced to video (60 times a second). The result is asynchronous output, though the time can be requested in synchronized form given time sync filtering.
In another case, my streaming debugger for embedded applications, many threads feed a ring buffer that feeds a transmit thread for sending debugging information. This allows for n threaded debugging or any system on a network. N threads feeds 1 thread via single channel shared structure similar to a queue (a ring buffer is just an over-glorified queue with fixed memory footprint).
You can always have a queue of "on" events, rather than check all states, setup another queue, though with a read-only option, probably as a vector or ring buffer because of the fixed memory state. Then you need only "push" an on-event onto the "active" state list. Another thread can read and process only the active states sending output, handling priorities, and "pop" completed activities. We do this for a state engine for script events which is always an asynchronous many to many relationship. My goal is always to keep things asynchronous as the input until the very last frame before display, then synchronize if necessary. But that is because I know my data input is always asynchronous, synchronizing it only lowers its accuracy, so I want to do as little as I have to of manipulation of data.
You can also simulate a threaded operation using any heart-beat hardware event from the host system, from idle calls, to timers, to screen refreshes (vsync), etc.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I replied to Leslie here[^].
It's a bit long to retype - but was "thanks for the help you two, and here are some facts I neglected..."
Iain.
|
|
|
|
|
Hi, i have SDI app with dialog based on CDialog class. I need to get pointer to client area to set some properties.
|
|
|
|
|
zarraza wrote: Hi, i have SDI app with dialog based on CDialog class
Do you have a dialog based app, or a SDI app, with the view based from CFormView? These are different things.
As for your second question, can't you not use
CWnd::GetDC / ReleaseDC?
What sort of properties are you talking about?
|
|
|
|
|
For simplify this lets say it is a SDI app with the view based on CFormView (if needet can be CDialog based).
In this view i want to set size of client area, because on client area i have to put dynamicaly variable number of buttons, and client area size have to be enought big, sometimes even bigger then screen size.
I don't know if GetDC/ReleaseDC can help resolve my problem.
|
|
|
|
|
oninitdialog / getclientrect
|
|
|
|
|
I don't know if i understand MSDN corectly, but there is said that GetClientRect() just return coordinates of client area respectively to window area, not handler of client area.
|
|
|
|
|
That is true - but the only thing you'll care about is the rectangle's width
or you can use MapWindowRect....
Iain.
|
|
|
|
|
If i add a button dynamicaly which is outside client area, the scroll bars doesn't appear and i have to resize window manually(by clicking mouse in corner at runtime) to see this button. It has to be a way to make those scrollbars visible and scrolling very big client area (eg if i want 1000 buttons on dialog or very big image).
|
|
|
|
|
CFormView is based on CScrollView. Normally you would call ResizeParentToFit at some point (or MFC will do it for you), what you want to do is provided by a call to SetScrollSizes after you add this "button which is outside the client area".
|
|
|
|
|
Thank you Roger i search for this solution for few days and couldn't find nothing usefull. I love You man.
|
|
|
|
|
Design a calculator, which should have the following:
sin x, cos x, tan x, Sq Root
Along with standard features and memory facility(M+,M-,MR,MC)
avishekbanerjee
|
|
|
|
|
This is a good assignment. Report back when you are done and tell us how it went.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
and you expect us to do your homework ?
bad pupil
|
|
|
|
|
|
Done.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It enters to stack you must wait for it(FIFO).
|
|
|
|
|
|
Hamid. wrote: but next time ask for specific question and also use of a simple search
yes, but next time, don't give help to lazy people like that guy who didn't even make the effort of searching the web and the codeproject by itself
|
|
|
|
|
I'm agree with you if I could search so he/she could search himself/herself but I guess maybe he/she needs to this help.;)
|
|
|
|
|
Hi,
When using a buffer to intermediary help to make use of some functions…
If I want to have in the buffer the content of an Array, then I make:
pBuffer = &Array[0];
file->Write (pBuffer , sizeof (Array));
And there is no problem because the array allocates contiguous memory to hold the members and the pointer says where the Array starts, and with the “size of (Array)” I say how many elements have to be written.
But doing the opposite…
::RegQueryValueEx (hWkKey, "SubKey", 0, &dwType, pBuffer, &lnLength);
if (dwType == REG_SZ)
szValue = pBuffer;
else if (dwType == REG_BINARY)
for (int i = 0; i < lnLength; i++)
Array[i] = *(pBuffer + i);
delete [] pBuffer;
pBuffer = NULL;
The usual assignation works with the string because internally is like a char* and then both uses the start direction to allocate the data in their place till a '\0' is founded, but it should be made using a for when writing the data into the array because there is no way to say how long the array is (like '\0' by the char*) (isn't it?)
Array = *pBuffer;
;
&Array = pBuffer;
Array = pBuffer;
&Array[0] = pBuffer;
;
The meaning of the errors (but C2109) and the reason to have them is clear, but...
Is there any other possibility to do it, or the “for” must be used?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
I am not sure what your question is but have a look at memcpy(...)
|
|
|
|
|
I have taken look to the documentation and it seems to be what I asked for. But...
Quote:
"The memcpy function copies count bytes of src to dest. If the source and destination overlap, this function does not ensure that the original source bytes in the overlapping region are copied before being overwritten. Use memmove to handle overlapping regions."
but in the example both makes exactly the same,
Function: memmove with overlap
Source: quick brown fox jumps over the lazy dog
Destination: brown fox jumps over the lazy dog
Result: The quick quick brown fox jumps over the lazy dog
Length: 49 characters
Function: memcpy with overlap
Source: quick brown dog jumps over the lazy fox
Destination: brown dog jumps over the lazy fox
Result: The quick quick brown dog jumps over the lazy fox
Length: 49 characters
then... why is it said?
Can you tell me an example where the quote of MSDN is true?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: then... why is it said?
what is "what" said? The part about overlapping source and destination? ????
|
|
|
|
|