The example embodiments are best understood from the following detailed description when read with the accompanying drawing figures. It is emphasized that the various features are not necessarily drawn to scale. In fact, the dimensions may be arbitrarily increased or decreased for clarity of discussion. Wherever applicable and practical, like reference numerals refer to like elements.
In the following detailed description, for purposes of explanation and not limitation, example embodiments disclosing specific details are set forth in order to provide a thorough understanding of an embodiment according to the present teachings. However, it will be apparent to one having ordinary skill in the art having had the benefit of the present disclosure that other embodiments according to the present teachings that depart from the specific details disclosed herein remain within the scope of the appended claims. Moreover, descriptions of well-known apparati and methods may be omitted so as to not obscure the description of the example embodiments. Such methods and apparati are clearly within the scope of the present teachings.
In the system 100, controller 120 monitors and/or controls instrument 140. [00023]
In operation, memory 220 stores executable code in designated memory locations. Processor 210 executes a software algorithm in accordance with the machine code stored in memory 220. The software algorithm executes instructions provided in a programming language used to construct the software algorithm. As described in more detail below, the programming language is configured to operate with real-time clock 236, and provides the ability to specify that an action is to be performed at an explicit time. In that regard, triggering device 230 employs real-time clock 236 to provide a running update of absolute time. In that case, when executing an instruction to schedule an action to be performed at an explicit time, the scheduled time, TS, for the action to be performed is loaded into register 232. Comparator 234 compares the clock time from clock 236, TCLOCK, against the scheduled time TS stored in register 232, and when the times are the same, then comparator 234 generates a hardware trigger signal (an edge, typically) and sends the trigger signal to the circuit to be activated. For example, where the action is to be performed by instrument 140 of
In practice, clock 236 advances at the granularity of the underlying crystal, so the scheduled time stored in register 232, TS, may fall between “ticks.” Thus, it is necessary for comparator 234 to check if the clock time from clock 236, TCLOCK≧TS, the scheduled time, rather than merely checking to see if the TCLOCK=TS. That means, however, that once the scheduled time TS is reached, comparator 236 will generate the hardware trigger signal on every subsequent clock tick. This is not what was intended. To address this issue, additional circuitry (not shown) is employed to make the action occur only once. One embodiment uses the output of the comparison to turn off an “enable bit” that causes the comparison to occur. In another embodiment, the circuit implements a small state machine, and outputs an edge if the TCLOCK<TS, on one clock tick and TCLOCK≧TS, on the next clock tick.
Because the system 100 has the ability to specify a trigger at an explicit time (e.g., 3:01 PM on 8 Jun. 2007), then the notion of a trigger in the past becomes meaningful, and there are even realistic cases in which it might occur. For example, suppose a program intends to set a trigger in the near future—say 20 milliseconds from now. If the current time is 9:07.061 then the program will calculate that the action should occur at 9:07.081. Now suppose that just before setting that trigger, the program is pre-empted by a high-priority task for 21 milliseconds. When the program resumes execution and sets the trigger, the time is now 9:07.082. So at this point, the program is waiting to schedule an event in the past.
How should the program be designed to handle this situation? The answer depends upon the specific circumstances. Consider the following four scenarios, each of which presents a different answer to that question.
Scenario One. Consider a case where the program is controlling a device to sample a short-lived event. For example, consider a program that controls a device to weigh a can as it passes by on a conveyor belt. In this case, if the scheduled action is performed later, it will produce an incorrect result. So an error should be signaled. However, downstream software may be aligning this data stream with others, so the device should still take the measurement and send it to the subsequent algorithms where it is normally used. So, scenario one involves situations where we want the operation to be performed even if slightly late, but where the late timing may lead to errors or problems in subsequent processes if it is not acknowledged and accounted for, and so an error should be signaled
Scenario Two. Consider a program that controls a valve on a tank to close the valve after emptying the tank. In this case if the scheduled action is performed a little late, in general there is no harm. So if the scheduled time for performing the operation has just passed and the operation has not yet been performed, then the action definitely should still be performed. Also, in that case, since there is no harm to anyone from the valve closing slightly late, no error should be signaled. So, scenario two involves situations where we want the operation to be performed even if slightly late, and where the late-timing of the operation is not going to cause problems for subsequent processes, and so we do not want to signal an error.
Scenario Three. Consider a program that controls a device to drop a cutting blade to separate finished parts moving along a conveyer belt. In this case, if the scheduled action is performed a little late, it will not only fail to achieve its objective, it will likely damage one or more finished parts. So if the scheduled time for performing the operation has just passed and the operation has not yet been performed, then the action definitely should not be performed. Also, in that case, an error should be signaled. So, scenario three involves situations where we do NOT want the operation to be performed even if slightly late, and where we want to signal an error.
Scenario Four. Consider a program that controls a device to sweep the crumbs out of a bakery oven after the bread is removed each time a new batch is baked. In this example, assume that the process has five seconds to perform the operation before the next batch is loaded into the oven. In that case, if a command to the device is four seconds late, then the operation should not be started as it will not have time to complete within the five second time window. Furthermore, since the operation is not essential and the oven presumably will be swept after the next batch is baked anyway, signaling an error may be costly if it stops a continuous process.
Another example of Scenario Four is when performing an operation late is harmless in and of itself, but it is wasteful or expensive. For example, consider a program that controls the timing of flashing a strobe light for a camera. If the strobe light is flashed after the camera has already taken a picture, it will not harm the picture-taking process, but it wastes battery power. Again, in this case the operation should not be performed. If an operation is not essential (because it is redundant, or subsequent steps can pick up what is missed, etc.) then a programmer may want not to signal an error even though the timing for the operation was late. So scenario four involves situations where we do NOT want the operation to be performed even if slightly late, and where it is desired not to signal any error.
Table 1 below illustrates the four scenarios described above.
To address these situations and issues, a system and method are provided that allow a programmer to specify all the desired semantics. In particular, in the embodiments of
The callback function of 310 is just one way for a programmer to choose whether to signal an error (for example, the programmer can pass in a function which does nothing, and that will have the effect of not signaling an error).
In the embodiment as shown in
Although
Performing an instruction with semantics for handling late-triggering events, as described above, requires support at the hardware level. More specifically, support is needed to detect accurately whether an event is scheduled in the past. Accordingly, in one embodiment, an input and an output are added to triggering device 230 of
Notice that even if the programmer does not want to signal an error (cases 2 and 4 in Table 1) the circuit still produces the ‘late’ output. The programmer can ignore this signal (by providing a null callback, by discarding a value returned through the action's name, or by ignoring the value returned through a parameter).
Assuming that the hardware support described above, or other provisions for handling late-triggering events, are provided,
The process 400 starts in a first step 402. Then, in a step 408, a controller 120 begins a software algorithm and starts real-time clock 236. In the process 400, the software algorithm is written using a programming language configured to operate with real-time clock 236, and supports at least one instruction that specifies semantics for a late trigger. Subsequently, in a step 410, an instruction is called that specifies an action to be triggered at an explicit time. The instruction may conform to the syntax of any of the instructions illustrated in
In a step 415, the scheduled time for the action, TS, is compared against clock time TCLOCK.
In a step 420, it is determined whether the current time is too early for the action to be performed. If so, then the instruction has arrived in time, and the process proceeds to step 432. In step 420, as explained above, some means must be provided to insure that this test is only false once so that the trigger is only generated once, and not on every subsequent clock tick. In step 432, the algorithm continues to compare the scheduled time for the action, TS, is compared against clock time TCLOCK. In step 434, it is determined again whether the current time is still too early for the action to be performed. If so, then the algorithm returns to step 432, and the loop of steps 432 and 434 is repeatedly performed until it is that the current time is no longer too early for the action to be performed. At that point, the algorithm proceeds to step 436 where the trigger is executed. After the trigger is executed in step 436, then in a step 450 it is determined whether the process should begin again at step 402, or end in step 460.
On the other hand, if it is determined in step 420 that the specified explicit time for the action, TS, has already passed, then in a step 442, in accordance with the specified late-trigger parameters of the instruction, it is determined whether the trigger should or should not be generated, and an error may or may not be processed, implementing any of the four scenarios of Table 1 above. If it is OK to trigger the event late, then in a step 444 the trigger is executed, and the process continues at a step 446. If it is not OK to trigger the event late, then the process continues at step 446 without executing the trigger. In the step 446, any function calls specified by the instruction are executed. Then, in the step 450 it is determined whether the process should begin again at step 402, or end in step 460.
Although the concepts disclosed herein have been described above in the context of a system including a controller and an instrument and a late event for an instruction for performing an action at an explicit time, it should be understood that the concepts extend to other contexts and syntactic forms. For example, Rule 4.4 of the Local Area Network eXtensions for Instrumentation (LXI) Standard, Revision 1.0 (23 Sep. 2005) (which is incorporated herein by reference) describes a network packet which may include action, time and parameters. It is possible to use such a network packet to provide an instruction to make a measurement at a time specified in the packet, or to set a parameter to a specified value at the time contained in the packet. In those cases, then the time specified in the packet is intended to be in the future, and thus the packet can be late. In accordance with the concepts described above, the parameters included in the packet may specify what to do in the event of a late packet, including whether or not to perform the instruction included in the packet. Other syntactic forms are also possible.
While example embodiments are disclosed herein, one of ordinary skill in the art appreciates that many variations that are in accordance with the present teachings are possible and remain within the scope of the appended claims. The embodiments therefore are not to be restricted except within the scope of the appended claims.