Does event order matters in midi file - midi

I mean like the meta event comes first , then channel event, then sysevent , meta event etc.
In the picture there is one meta event that comes, then channel event, and in between what if we will shuffle the order?

Most of these settings are independent, i.e., it does not matter in which order the events are processed.
However, some settings are affected by the current value of some other setting. For example, the program change events also uses the current values of the bank MSB/LSB controllers (this is not used in your file). Or the channel prefix (FF 20) meta event specifies the channel associated with the following meta or system exclusive events.
So if you don't know the meaning of an event, you should not reorder it.

Related

Different Pseudo Clock for groups of Facts

I am new to drools / fusion (7.x) and am not sure how to solve this requirement. Assume I have event objects as Event{long: timestamp, id: string} where id identifies a physical asset (like tractor) and timestamp represents the time the event fired relative to the asset. In my scenario these Events do not arrive in my system in 'real-time', meaning they can be seconds, minutes or even days late. And my rules system needs to monitor multiple assets. Given this, when rules are evaluate the clock needs to be relative to the asset being monitored, it can't be a clock that spans assets.
I'm aware of Pseudo Clock, is there a way to assign Pseudo clocks per Asset?
My assumption is that a clock must always progress forward or temporal functions will not work properly. Take for the example the following scenario:
Fact A for Asset 1 arrive at 1:00 it is inserted into memory and rules fired. Then Fact B arrives for same Asset 1 at 2:00. It too is inserted and rules fired. Now Fact Z arrives for Asset 2 at 1:30 (- 30 minutes from clock). I'm assuming I shouldn't simply progress the clock backwards and evaluate, furthermore I'd want to set the clock back to 2:00 since that was the "latest" data I received. Now assume I am monitoring thousands of assets, all sending data at different times...
The best way I can think to address this is to keep a clock per asset and then save the engine state when each assets data is evaluated. Can individual KieSession's have different clocks, or is it at a container level?
Sample rule: When Fact 1 arrives after Fact 2 for the same Asset.
You're approaching the problem incorrectly. Regardless of whether you're using a realtime or psuedo clock, you're using a clock. You can't say "Fact #1 use clock A, and Fact #2 use clock B."
Instead you should be leveraging the metadata tags for events, specifically the #timestamp tag. This tag indicates to Drools that a specific field inside of the event is actually the timestamp for the Event, rather than the actual time the fact enters working memory.
For example:
import com.example.SampleEvent
declare SampleEvent
#role( event )
// this field is actually in the object, it's not the time the fact was inserted
#timestamp( createdDateTime )
end
Not knowing anything about what your rules are actually doing, the major issue I can foresee here is that if your rules rely on the temporal operators or define an expiry (#expires), they're not going to work and you'll need to redesign them. Especially for expirations: once an event expires, it is removed from working memory; when your out-of-band events come in any previously expired events are already gone and can't be worked against.
Of course that concern would be true regardless of whether you use #timestamp or your original "different psuedo clock" plan. Either way you're going to have to manage the fact that events cannot live forever in working memory -- you will eventually run out of resources and your system will crash. Events must be evicted at some point, so you'll need to design around that in both your models and your rules.

Filter Dart stream to allow only one event per second

Given a dart stream, how can I filter it so that there is maximum one value per minute?
Somthing like:
https://github.com/ReactiveX/RxJava/wiki/Filtering-Observables#throttlefirst
Background
I'm building a flutter app.
I use getPositionStream to get a stream of the location.
When I recieve a positionChange I update a GoogleMap.
However getPositionStream returns too many events, so I want to filter them to speed up the response.
EDIT
Note for #pskink comment
This should be emmiting max one location change each second?
getPositionStream(desiredAccuracy: LocationAccuracy.best).throttleTime(Duration(seconds: 1))

In Maximo, how do I get in between workflow process whether data in the table has been modified?

I want to show a different option to the user in workflow through input node, depending upon whether the user has modified the record or not.
Problem is if I would use a condition node with custom class to detect whether object has been modified by some person or not in between the workflow process then as soon as the person clicks on route workflow the save is automatically called and isModified() flag gets false, How do I get in condition node whether some person has modified the record or not.
I have to show different options to the user if he has modified and different option on routing workflow if he have not modified.
Sounds to me like you need to enable eAudit on the object and then to check whether eauditusername on the most recent audit record for that object bears the userid of the current user.
It's a little hokey and tempts fate, but if your condition node is early in the workflow's route when this button is pressed, you could try and check to see if the changedate on the object (assuming you are working with one of the many objects that has one) is within the last 5 seconds. There is a gap where the record could be routed twice within a few seconds, but the gap is fairly hard to hit. There is also a gap where if the system slows down at that point and takes more than 5 seconds to get to and run your condition, then it would appear to be not modified. You can play with the delay to find a sweet spot of the fewest false positives and negatives.

FIX order tracking

With respect to FIX 4.2 or greater:
Q1.a. How are incoming and outgoing sequence #’s correlated/linked? Is there a buyer specific FIX tag a buyer can embed/use explicitly for tracking upon submitting a buy order that is also included in subsequent incoming status message sequences from the broker?
Q1.b. If not, then how does a buyer manage/track individually several IOC buy orders that are submitted in quick succession or concurrently of securities which may or may not be identical, at different price levels, where units or shares are “filled” at varying rates?
Q1.a. How are incoming and outgoing sequence #’s correlated/linked?
They are not linked (i.e. they are independant). Any FIX application/engine (such as the QuickFIX family) maintains two sequence numbers per session, one for incoming and one for outgoing. See also this answer on Stack Overflow which pretty much tells you the same.
When using an engine like any of the QuickFIX family (QuickFIX, QuickFIX/J, QuickFIX/N), these will be managed for you and apart from some configuration vis-a-vis your counterparty you should not bother about managing these.
Q1.a. Is there a buyer specific FIX tag a buyer can embed/use explicitly for tracking upon submitting a buy order that is also included in subsequent incoming status message sequences from the broker?
These tags are already present in e.g. the FIX Order Single message (D) - ClOrdId:
Unique identifier for Order as assigned by the buy-side (institution, broker, intermediary etc.) [...]. Uniqueness must be guaranteed within a single trading day. Firms, particularly those which electronically submit multi-day orders, trade globally or throughout market close periods, should ensure uniqueness across days, for example by embedding a date within the ClOrdID field.
This field is mandatory when creating a new order using FIX Order Single, and is used the refer to the order in subsequent messaging (e.g. Execution Report, or Status messages).
Note that the ClOrdId changes when an order is changed using an Order Cancel/Replace Request <G>, i.e. you assign a new ClOrdId to the order when changing or canceling it.

Can I use Time as globally unique event version?

I found time as the best value as event version.
I can merge perfectly independent events of different event sources on different servers whenever needed without being worry about read side event order synchronization. I know which event (from server 1) had happened before the other (from server 2) without the need for global sequential event id generator which makes all read sides to depend on it.
As long as the time is a globally ever sequential event version , different teams in companies can act as distributed event sources or event readers And everyone can always relay on the contract.
The world's simplest notification from a write side to subscribed read sides followed by a query pulling the recent changes from the underlying write side can simplify everything.
Are there any side effects I'm not aware of ?
Time is indeed increasing and you get a deterministic number, however event versioning is not only serves the purpose of preventing conflicts. We always say that when we commit a new event to the event store, we send the new event version there as well and it must match the expected version on the event store side, which must be the previous version plus exactly one. If there will be a thousand or three millions of ticks between two events - I do not really care, this does not give me the information I need. And if I have missed one event on the go is critical to know. So I would not use anything else than incremental counter, with events versioned per aggregate/stream.