Re: Design Problem




"J French" <erewhon@xxxxxxxxxx> schrieb im Newsbeitrag
news:43e74884.80776403@xxxxxxxxxxxxxxxxxxxxxxx
On Mon, 6 Feb 2006 12:34:41 +0100, "Ole Weigelt"
<o.weigelt@xxxxxxxxxxxxxx> wrote:

<snip>

My hunch is that there is a bunch of machines on the other end of the
COM Port, and that the 'instructions' contain a destination flag
- one machine is given a task
- while it is busy, he wants to send a task to another machine

If that is the case, then I think I can see a solution
- but ... more info would be helpful


We're coming closer.

What I have is a Building Management System (BMS) on the other side of
the
COM-Port. The tasks are instructions to the BMS.

The tasks are i.e.: open a window, wait x seconds, close it again. So far
for the pause.

Now, while the window is open, i need to be able to switch some lights.
That
is why the tasks need to be able to overlap.

During the whole thing, I need to listen for status messages and button
pushes that are reported through the same COM port.

Does that help?


Hi,

It sure does

Do you know that you will want to run Task2 when you send the Task1
data ?


No, the tasks are called by the data received through the COM port. For the
software, this is a random process.

If so then you could 'merge' the tasks into one mega-task and just
send that

If not, then you have a situation where Task1 is running, probably
paused for hours, and you suddenly decide to run Task2


This is exactly the situation.

Does it matter if Task1 and Task2 get interleaved ?
eg:
Task1.Line1
Task1.Line2
Task2.Line1
Task1.Line3
Task2.Line2

If not you could set up a list of scheduled tasks with a time against
each line, simply add new tasks to the end of the list and have a
routine that picks the next Task Line regardless of which task it
belongs to.

eg: Task1.Line1 16:00
Task1.Line2 16:00
Task1.Line3 16:40 ' wait 40 mins
Task1.Line4 16:40 ' immediately after Line2
Task2.Line1 16:03 ' added at 16:03 so immediate
Task2.Line2 16:04 ' wait 1 min

Scanning the list, you could pick of the Task.Line with the next
'expired' wait time, send it and delete the line

It would give natural priority to earlier Tasks, but that should be no
problem.

Recording each line sent in a log file would also provide an
interesting audit of exactly what happened, and when.

This method would only work if the Task list did not wait for
feedback, eg: the Task is executed blindly

Do you have 'feedback' within the Task ?
eg: Send command Wait until some feedback then send another command

Or does the system just pump out commands on a timed basis ?



This describes exactly what I would like to do.

I will answer the questions in a block:

It is no problem if the tasks get interleaved. In fact, this is what I want
to achieve.

The natural priority is not a problem either. This is a problem that occurs
on a BMS anyway, i.e. if two persons push the button for the same light from
different locations at the same time. So this problem has been taken care of
by somebody else.

Since it is a bus system with no scheduled communication, you never know if
and when an ACK ist sent. Thus, the software will not wait for responses. If
there are responses, they are collected through the COM port as simple
messages. The Software will react accordingly. But from the sender's side,
we just pump out the data.

The problem is, how to set up such a scheduler. The windows scheduler is not
a good idea, because the timing has to be accurate to the second. Not more,
but not less either.

Building my own scheduler? How would I do that? Array of Strings combined
with Date/Time? How would I shift the lines when the first item is sent?

Tricky thing for me...




.