Axon Queries and How to
- 1 Examples and How To write Axon queries
- 1.1 Server URIs
- 2 Functions
- 2.1.1 Simple function
- 2.1.2 DrTargeDrTargetKw(Kw()
- 2.1.3 boxWisker()
- 2.1.4 siteMeterKwhWrite
- 2.1.5 countDownSubmeters:
- 2.1.6 countSubmeters:
- 2.1.7 finDateSpan:
- 2.1.8 finCommit:
- 2.1.9 computed tag
- 2.1.10 calculateMeteredData
- 2.2 Add a function to a pod
Examples and How To write Axon queries
Name | Axon query | Description |
---|---|---|
Find Unused Bacnet Connectors |
| Finds all bacnet connectors that are not being used |
Contains Search | Examples:
| looks for records that 'contain' the text specified in the 'contains' query |
Take point descriptions from the Connector and copy it onto a property tag on the point in FIN Stack. |
| This query takes every point coming from a bacnet connector and adds a string property tag called description and fills in the value of this tag with the description inside the BACnet device. |
priority for points |
| This will show you what level, and who wrote to a certain priority for points. |
create records via commit |
| This will allow the user to add a new record to the dataBase with a dis tag, action string, and a finActions marker |
add / edit tags on records |
| This will let you find a list of records that match the filter (Jason), and it will add the numberTest:88 tag to them. Or it will edit the tag if it already exists. |
Commit Records from Trio or just a grid |
| |
remove tags |
| -rochelle will find and remove all the rochelle tags, that have a jason marker |
delete/remove recrods |
| Finds all records that have the jason marker, and will remove them out of the dataBase. |
keep Cols |
| This takes a grid, in this example I just used the funcs function, and then only kept columns name,lib, and ID |
readAll then Fold |
| This finds all points, that are %, and it gives you the average for the curVal tag. Using the foldCol function. |
foldCols |
| This finds all point and unit, and then keeps just the id, curVal, and hisSize columns. Then it uses a foldCols function, and sums the curVal, and hisSize columns. |
uriPath | `http://host:81/a/b/file.txt`.uriPath | Takes a URI, and breaks out the path into a number of rows |
get date info |
| This query gets the current time, and then formats it so it's Month. |
Time Formats |
| YY Two digit year 07
YYYY Four digit year 2007
M One/two digit month 6, 11
MM Two digit month 06, 11
MMM Three letter abbr month Jun, Nov
MMMM Full month June, November
D One/two digit day 5, 28
DD Two digit day 05, 28
DDD Day with suffix 1st, 2nd, 3rd, 24th
WWW Three letter abbr weekday Tue
WWWW Full weekday Tuesday |
find all discover sessions, or find the devices that were previsouly discovered |
| |
start from a gird |
| Take a grid, and start working with it |
read a string and remove 1st 5 lines, then turn it back into a grid |
| |
Size |
| .size() from the grid will tell you how many rows you have |
First row |
| Gives you the first row |
first and second row |
| [0..1] will return the first 2 rows |
foldCol |
| This takes the area column and folds it using sum |
sort |
| This sorts it by the area column. sortr does a reverse sort |
Rename Col |
| This will rename the column to a different name |
Find a tag on a record ref |
| Finds all equipments and then looks for all of their siteRefs that the tag name dis = Short Pump. The -> is what allows you to goto that siteRefs record and find a tag that matches the dis name |
math on columns |
| Find sites, and do a map, then create a new column called delta, and multiple the area by the storeNum. Then we just keep 4 columns. |
find all tags on a record |
| Find all the tags on a certain record |
Nav Move |
| This uses a equip tree to move on record to a different record. IE... To take a point from one equipment, and move it to another equipment. navMove will look at navMeta, and it will make sure that the correct refs are on each record. |
contains |
| This one finds where the dis name contains "Car" |
sqlConn |
| sql Query that finds all of Assetworks buildings, where it == PHX |
goto and find tags |
| This read something, and find tags, or find refs, and then find tags. |
read point |
| find a point, then goto the equip, then goto the site, and then return the area tag |
try and map |
| What this function does is look and find every point, then use map to go through every row, and goto the equip, then the site, and return the area. The reason I put try there is because it was throwing an error, because one of the rows didn't have an equipRef, so now if it gets an error, it just returns 0. The reason we put area was only because we wanted to name the column in the grid. |
find crap, and use map |
| |
Multiple valuations and comparing each other |
| I fold the first axon query, and then I divide the 2nd axon query by itself. This is just cool :} Understanding maps is very important |
haystackCall |
| |
haystackCall Read |
| |
more |
| |
| finds histories that exist in nHaystack | |
| This let's you read a history from a haystack server, in this case nHaystack, and that do normal history stuff. | |
nav Uri |
| This is the way you can query a point or equip by using the navID... It will check the dis:"" or the navName:"" and return the result. :} |
Sync all Haystack histories |
| This will find all haystack histories, and it will sync them. IE... Pull the history out of the haystack client, and store it in FIN Stack |
finNavChildren |
| This will let you walk the tree |
finNavChildren fo down |
| This looks for the equp tree, and you pass in an ID |
finNavLevels |
| This shows you where you are at in the tree, |
NIagara Haystack query |
| This is how to read n Haystack SiteUri |
Haysatck url query | This is how to query direct from the browser | |
List and function in a list |
| This is a list with functions in them |
| ||
| ||
Dict |
| |
| ||
Grid |
| |
add meta data |
| Run this and you will see how to add meta data to a grid, and how to run a function in a grid |
get Meta data |
| This will get you data from the meta data |
convert units |
| .to converts things. ONly like dimensions. This exists in the units text |
| ||
add unit |
| add a unit or switch a unit with no conversion |
| Time Units- s,min,h,day,wk,mo,yr | |
| I can take today and - it from something else. Very cool | |
read csv file |
| Read csv file in my dataBase |
| ||
| ||
trap |
| get is [] and trap is -> ..... Get |
no exception |
| false makes it not return an error |
| ||
error message |
| Here is how you can throw an error message |
map |
| |
| ||
find the spread of something |
| This is great to see how much something hunted during a certain time. Great way |
find | readAll(site).map row => {dis: row->dis, areaTest: row->area} | |
readAll(site).findAll row => row ->area > 10_000 | ||
find points in every row | readAll(point).findAll row => row->navName.contains("Temp") | find point names by looping through a lot of crap |
add Haystack database | finCreateHaystackDb([@1902cc8c-adde74db], "sep:/" , true) | @... the id of the haystack connector and the true parameter is adding history to the points that don;t have it you can use it without the true part the "sep:/" is needed after Jarmy new changes - this is the default for Niagara and otherwise it can be: "/equip" |
default excluded tags when adding a database | finHaystackExcludedTags() | you will get all the default excluded tags you just need to add a new record in folio with finHaystackExcludedTags and after it the other markers that you want to exclude(so that you add some more to the excluded list) the default excluded ones are: "axSlotPath",axHistoryRef,siteUri,id" |
contains query | connExts().findAll val => val->ext.contains("haystack") | Take a grid, and findAll that contains haystack |
Debugging a connector | logSetLevel("haystack", "debug") | This puts the debugger on in skyspark. You then can look at the data in the console. |
Read Tag Values | readAllTagVals(point and temp and air,"equipRef") | This one will show you all the values of a tag, based on a filter. It will show all the unique values. It's pretty helpful actually |
Lint for a record | lint().find r => r->targetRef == 180082a9-d9aecffe | This will find the record Id for each lint error |
each rec | readAll(point and equipRef->ahuRef->id==@191d48c4-95263c67).each rec => rec.pointEmergencyOverride(67%) | write each point in a readAll |
map example | readAll(point and equipRef->ahuRef->id==@191d48c4-95263c67).map(rec => {result: rec.pointEmergencyOverride(67%)}) | The above each example is better then the above solution which is a map solution. The map solution outputs a dict, so that why we need the { } here |
boxWisker Test function below | readAll(point and sensor and temp and hisSize).map(r=>r.boxWisker(2012-05)) | Make sure the point has a history |
finPointSummary | readAll(site).finPointSummary(ahu and not rooftop,point and summary) | This will let us build a summary page for equipment and points. Kind of like FQL. The function takes 3 paramteres. 1. site or floor, or any record. 2. Takes a filter for equipment. IE... rooftop. 3. Takes a filter for a point. Typically this will be like floorSummary. So the the query to left does this. Finds the first site, and then finds equipment under that site that is an ahu and not a rooftop, then it finds all the points that have a summary tag on it. This will then return a grid with equips as rows, and points as colums |
readAllTagNames find kind | readAllTagNames(point).findAll r => r["kind"] == "Ref" | This will find all the tags, and it will let you find all the ref tags. This will be helpful in our search for tags. |
random grid | ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul","Aug","Sep","Oct","Nov","Dec"].toGrid.map((r,i)=>{dis:r->val, value:random(0..100), index: i+1}) | This let's you name a bunch of crap, and get a demo grid that comes out. :} |
week for a year | read(kw and hisSize).hisRead(lastYear).hisRollup(sum,1wk).map((r,i) => {ts: r->ts.format("MMM"), v0: r->v0, week:"Wk " + (i+1)}) | This won't show the right week if you don't do the entire year. IE... |
taskVarTree | taskVarTree(@195357e2-faf5560f,@19042bad-f79d61b9 ) | This query shows you a list of all Points/Tags/ and Variables on a particular program, and target. It finds the target, and then shows every point/tag/variable on the target, then it finds every ref on the target, and finds all of it's points/tags/varaibles. This is used in the UI to be able to auto complete creating variables. The function 1st parameter takes the program ID, the 2nd parameter takes the taret ID. |
do foo:read(projMeta); if (foo.has("dis")) foo->dis else context()->projName end | ||
taskVarsLinkedTo | taskVarsLinkedTo(@19a02c31-673132ee, @19042bad-73b30a28, "cool1") | This function is currently working on 1000, and will tell you all the places that this var is being used in. |
findAll Example | readAllTagNames(point).findAll r => r ->kind.contains("Number") | This is an example on how to go through a grid, and find all things that contains a certain text |
findAll with or | readAllTagNames(point).findAll r => (r ->kind.contains("Number")) or (r ->kind.contains("Str")) | This is an example of a find all with an or. |
nHaystack and haystack Sever | This shows you how to query all the sites in a haystack server. Doing a get out of haystack to fo a filter on points | |
hisRead | http://localhost:85/api/demo/hisRead?id=@Carytown.RTU-1.DischargePressure&range=today | Example of getting a his out of haystack via a get. |
hisRead date range | ||
eval and expr | Axon query in the url | |
set points in monitor mode | taskSetMonitorMode(@19a167ef-14270409, @19042bad-73b30a28, {setPoint: true, zoneTempSp: true, returnTemp: true, blah: true, writeTempPID: true, link1: true}) | This is used in Control logic and it lets you set points into a monitor mode. You can only set 8 points in at once. |
poll the points from monitor | taskMonitorPoll(@19a167ef-14270409, @19042bad-73b30a28, null) | This is how you poll the points in monitor mode |
tasksVarsLinkedTo | taskVarsLinkedTo(@19c3d30f-63117dc0, @19042bad-73b30a28, "zoneTempSp") | This finds all the other programs tasks that are using this Variable. Very helpful for troubleshooting |
programVarLocs | programVarLocs(@19c3d30f-63117dc0) | This finds all the locations in a program that the variable is used, and tells you if it's being set or not. |
one liner if statement | if (read(projMeta).has("dis")) read(projMeta)->dis else context()->projName | if this then tha |
obix Server | /api/demo/ext/obix | This is the path to the obix server. FIN Stack is a obix client and obix server. |
obix server | Server URIsThe following table summarizes the URIs of the Obix server API: Uri Object
------------------------------- -------------
/api/{proj}/ext/obix/ lobby
/api/{proj}/ext/obix/about/ about
/api/{proj}/ext/obix/batch/ batch op
/api/{proj}/ext/obix/watchService/ watch service
/api/{proj}/ext/obix/watch/{id}/ watch operations
/api/{proj}/ext/obix/query/{filter} query recs using filter
/api/{proj}/ext/obix/rec/{id|name}/ record
/api/{proj}/ext/obix/rec/{id|name}/{tag} tag
/api/{proj}/ext/obix/icon/{id}/{uri} icon tunnelling | Here are the options |
query or filter | http://finanalytics.j2inn.com:999/api/demo/ext/obix/query/curVal%3E5 | This is how you can query obix. query/and it takes a filter |
gridColKinds(grid) | [{dis:"Site-A", area:2300ft²}, {dis:"Site-B", area:3100ft²}, {dis:"Site-C", area:1950ft²}].toGrid().gridColKinds() | This will take any grid and return you a list of the unique tags, and tag counts |
scalar | age:34 | |
dictionary | {jason,brihhhs,name:"ddddd"} | |
list | ["dfsd","dsfsdf","SSSSS"] | |
Grid "list of Dictionaries" | [{age:45,lastName:"Briggs",ahu,temp,sensor},{age:45,lastName:"Briggs",sensor}] | |
Muliple points | readAll(point and equipRef->rooftop and hisSize>20).hisRead(2012-12-01).hisInterpolate() | This shows how you can show multiple points on a chart |
related graphics | readById(@19042bad-0aa06641).finGraphicOn(true) | This function will show you all the related graphics for a record |
grid to commit | ioReadCsv(`io/UF_Devices.csv`).floridaImport().toRecList.map( row => diff(null,row,{add})).commit() | this takes a grid, and commits it to the database |
read files out of a directory | ioDir(`io/`) | This let's us read files right out of a directory |
read a bacnet Schedule | read(bacnetConn).bacnetScheduleRead(@pointRef)
read(bacnetConn).bacnetScheduleRead("17:2") | This will read all the events from a bacnet Schedule |
write a weekly schedule to a bacnet Schedule point |
read(bacnetConn).bacnetScheduleWrite(@pointRef,scheduleHis(@scheduleRef,thisWeek() +1day , {timeline}))
read(bacnetConn).bacnetScheduleWrite("17:2",scheduleHis(@scheduleRef,thisWeek() +1day , {timeline})) | This will write all the events for a week into a bacnet Schedule |
finPointSummary | readAll(site).finPointSummary(ahu and rooftop,cmd and point) | Here is a cool way where point summary will just work :} |
zip selected records | ioZipEntry(`io/haystack/Archive.zip`,`/vav.trio`).ioReadTrio() | |
read csv file and return number of unique records | ao: ioReadCsv(`io/test/bacnetList.csv`).findAll(row => row->dis.contains(":")).map(r => {new:r->dis.split(":").get(-2)}).map(r => {test:r->new.split(".").get(-1)}).unique("test").size() | |
rebuildDocs() | rebuildDocs() | This should just do a fresh rebuild of the docs |
finBackupRecord() | finBackupRecord(@Gaithersburg.RTU-1,{files:true, references:true}) | This will create a backup of all the records with the specified equip ref @Gaithersburg.RTU-1 is the equip ref that will be present on all imported files in the graphicOn tag ( graphicOn: "equip and id==@Gaithersburg.RTU-1") |
finRestoreRecord() | finRestoreRecord(@1a026bc8-a4879a4b) | This will restore all the records with the specified id @1a026bc8-a4879a4b is the ref of the backUp created with the above function |
trio and commit it | ioReadTrio(`io/HUEBackup.trio`).toGrid().removeCols(["dis","mod"]).toRecList.map( row => diff(null,row,{add})).commit() | remove the dis tag first, before re-committing |
toAlarm() | read(point and temp).toAlarm( "myAlarm", {priority:77,alarmText:"This is a bad alarm",instructions:"1. Do this 2. Do that 3. Also this 4. Foo foo and foo",alarmType}) | this will put a target into alarm. |
toNormal() | read(point and temp).toNormal( "myAlarm", {priority:77,alarmText:"This is a bad alarm",instructions:"1. Do this 2. Do that 3. Also this 4. Foo foo and foo",alarmType}) | This will put the alarm back to normal |
find task for a certain target | tasks().findAll r=> r->targetRef == @19042bad-73b30a28 | |
find alarms by ID/target | navFilter("alarmTarget", readById(@19042bad-1077bbbc), null).alarms(2014-01-29) navFilter("alarmTarget", readAll(equip), null).alarms(today) | Find alarms for a particular target |
Find all alarms today, and the 3rd paramter is the last read timeStamp | navFilter("alarmTarget", null, null).alarms(today,null,"1739583508091440") or navFilter("alarmTarget", null, null).alarms(today,id==@20151006:overHeatedZone.overHeatedZone:1a17dcf9-7f7947ab,"1739583508091440") | The last paramter here allows you to see what alarms are new. The result of this query will give you a new number each time |
How to ack alarms | alarmAck([@20151006:overHeatedZone.overHeatedZone:1a17d935-2e1ab4be,]) | This is how to ack alarms |
find notes for a particular target | navFilter("noteTarget", @19042bad-73b30a28, null).notes({ }).noteSummary | |
find notes that are open for a target | navFilter("noteTarget", @19042bad-73b30a28, null).notes({ state:"open" }).noteSummary |