====InEvent====
**InEvent** is a //method// (or type) of [[state_rules|rule]] used to assign a [[state|state]] to your asset.
===Parameters===
^Name^Usage^
|source|The ARDI event source to read from|
|name|The default status during the event|
|regex|The regular expression to match against the event name|
|subtype|The event attribute to read the //sub-type// from.|
|flip|If true, copy the 'type' to 'subtype' and vice-versa|
===Notes===
The 'regex' value should be a regular expression that is matched against the name of the **event**.
===Example Match===
Let's say you have the following event...
^Name^Start^End^Desc^Code^
|Failure Downtime|10:00AM|11:00AM|Conveyor Fault|FDC|
{
"name": "Line Down",
"method": "InEvent",
"source": "Downtimes"
}
//The rule will set any times between 10:00AM and 11:00AM to a status of **Line Down**. There is no secondary status.//
===Matching with Attributes===
If you want to name the status something //other// than the name of the event, you can use the '#' character before the name, followed by the name of the event attribute you're interested in.
For example,
{
"name": "#Code",
"method": "InEvent",
"source": "Downtimes"
}
...will give all times between 10:00AM and 11:00AM the status 'FDC'
===Regular Expression Matches===
You can extract information out of the event name with the **regex** parameter.
{
"name": "Line Down",
"regex": "(.*) Downtime",
"method": "InEvent",
"source": "Downtimes"
}
...will instead give a status of 'Failure' (taken by matching the pattern with the event name 'Failure Downtime').
===Extracting a Secondary Status===
You can set a [[secondary state|secondary state]] using the **subtype** parameter..
{
"name": "Line Down",
"regex": "(.*) Downtime",
"method": "InEvent",
"source": "Downtimes",
"subtype": "Desc"
}
//This will set any times from 10:00AM to 11:00AM to 'Failure:Conveyor Fault'.//