Creating a multi-colored Line Timeline in Elasticsearch using Vega-lite - elastic-stack

I have been trying to create a timeline based off of the data that I get from a machine. The data that I receive includes the current timestamp, the state the machine is entering (ACTIVE, READY, FEED HOLD, STOPPED, UNAVAILABLE), the state the machine left, and the timestamp that the machine entered the last event.
I want to create a line which starts at the earliest filtered timestamp to the current timestamp, with the line being segmented based off of when an event changes. There's also setting the color of each segment, but I am using a Condition-Test block in order to handle that.
Functionally, my data looks like this:
#timestamp Jun 1, 2022 # 11:41:12.195
deviceName:XXXXXX
deviceUUID:YYYYYY
lastEvent:ACTIVE
Events.Execution.##data: READY
duration:256.811
The issue that I'm having is segmenting the line so that I can color each segment. I know that it is one color per line, so I would need to layer the lines. However, since I am doing this on a horizontal line, there's the risk that I lose segments. Since I'm looking to use this for management decisions, I need as much accurate information as possible.
Is there a way to create clearly defined segments and ensure there is no overlap using Vega-Lite?

Related

Infopath Repeating Table Replacing Looked Up Values in all Rows; Values Based on Two Seperate Fields

Here's the thought process and believe it or not I had it working and then it broke, now I am not sure why or how to fix it.
I have a secondary data source that is housed in a SharePoint list that contains billing rates for various tiers depending on the customer.
When you initially select a Tier and then the subsequent Positions under the daily billing area all is fine and dandy and values look up as they should.
However as is often the case someone will input the wrong Tier for the billing sheet and it would need to be changed to reflect the actual Tier. When this happens InfoPath is grabbing the value from the first row for the lookup and making it the value for all the position rate fields in the repeating table.
You can change them back, by selecting a different position and going back to the original position, however that is another step.
Seriously, this is the last bit for me to sort out before I can put this project behind me. I've included some screenshots of the groups and how they are laid out and the rules I have setup.
[Rules for Rate Tier field](https://i.stack.imgur.com/DO7e4.png)
[Rules for Position field](https://i.stack.imgur.com/JF8bh.png)
[Groups and Fields layout](https://i.stack.imgur.com/7etEq.png)
[Example of issue I am having](https://i.stack.imgur.com/aKD3t.gif)
I've tried everything from filtering the rate returned by the Position in the secondary source matching to the Position in the form which is activated conditionally when the Rate Tier equals a specific Tier. I've tried eval which I am not familiar with so I either got true or false but it never returned field contents.

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.

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.

'In-Crate' updates instead of client programs?

This is a simplified example scenario.
I collect interval temperature data from a room's heating, let's say every minute.
Additionally, there is a light switch, which sends its status (on/off) when someone switches the light on or off. All events are stored in crate with their timestamps.
I'd like to query all temperature readings while the light switch is in the "on"-state.
My design is to denormalize the data. So, each temperature event gets a new field, which contains the light switch status. My query breaks down to a simple filter then. However, I have only the events if someone presses the switch, but no continuous readings. So, I need to read out all light switch data, resemble the switch's state over time and update all temperature data accordingly.
Using crate, is there a way doing everything within crate using crate's SQL only, i.e. 'in-crate' data updates? I do not want to setup and maintain external client programs for such operations.
In more complex scenarios, I may also face the problem of reading a huge amount of data first via a single client program in order to update afterwards other data stored within the same data store. This "bottleneck" design approach worries me. Any ideas?
Thanks,
nodot

Delayed Execution on Edit with Google Apps Script

I have a relatively large spreadsheet (300 rows, 30 columns) that I color based on the values in the spreadsheet. I'm doing accessing the API minimally using only two accesses:
getValues(...) to access all the values of the data range.
setBackgrounds(...) to set all the backgrounds of the data range.
This runs in about half a second or less. However, it gets in the way if I make it run on every edit using onEdit(), but I also don't want it to be updated at regular time intervals when I'm not editing it, seems like a waste. Is there a good way to make the script run in a "delayed" way, updating at regular time intervals while I'm editing?
Firstly, I would say you should look at Google Sheets' conditional formatting (Format > Conditional formatting menu item in Sheets) -- you may be able to do much of what you need without involving Apps Script at all.
Failing that, you can set up a regular time-based trigger to check for edits and change the backgrounds appropriately. You can support this trigger with a separate onEdit() trigger to record what has changed internally. The flow goes like this:
A change is made and onEdit() triggers
The onEdit() trigger only records the changed cell locations to a local variable or Cache
A time-based trigger fires every minute/hour/whenever
The time-based trigger checks the cache for edited cells, alters their backgrounds, then clears them from the cache
That said, depending on your workflow this approach may not be much better than simply using a time trigger to change the cells directly.