Skip to content

lib-finTools 库参考 ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793357985/FIN+5.3.1+lib-finTools 中文整理基于 FIN 5.3.1

导读: 本页为 lib-finTools 的 API / 标签 / 函数参考文档。

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • lib
  • meta
  • funcs
  • def
  • addSimilarTypes(this, dict, thisType, percentMatch, types)
  • alarmActivityPeriods(alrm)
  • applyReplace(filter, tag, searchText, replaceText, chkbx)
  • breadcrumbs(id, iter: null, spEquipFound: null)
  • buildIsSiemens()
  • childrenCurVal2(equipList)
  • childrenCurVal3(equipList)
  • copyModbusFile(recId, path)
  • diffTypes(a, b)
  • finActionAddFilterForm()
  • finActionAddForm(filter, count, data: null)
  • finActionAddFun(filter, list)
  • finActionAddRepeatForm(filter, count, list)
  • finActionCatFilterForm()
  • finActionCatForm(filter, data: null)
  • finActionCatFunc(filter, data)
  • finAddChartToGroup(groupedCharts, group, newChart, vNum, point, current)
  • finAddGraphicThumbnail(graphicRef, thumbRef)
  • finAddTagsByColumn(stage: null, data: null, extra: null)
  • finAddTagsByName(id: null, refill: null)
  • finAddTagsByNameApply(grid, colName)
  • finAddTagsIoCsv(data: null)
  • finAddTzToPoint(pointId, basu: false)
  • finApplyEnumOptForm(stage: null, data: null)
  • finApplyNoteTags(selectedIds, tags)
  • finApplyUpdateConnectors(selectedIds, connType, existingConnectors, validConnector)
  • finBase64Decode(inp, checked: true)
  • finBase64Encode(inp)
  • finBatchAdvancedTagDP(num: null, sec: null, xtra: 0)
  • finBatchCloneScheduleApply(id, events, filter)
  • finBatchDeleteEventsForm(id: null, data: null, stage: null)
  • finBatchDeletePointsForm(selectedDicts: null, stage: null)
  • finBatchDeleteTagProvider(filter)
  • finBatchDeleteTagsApply(filter, tags)
  • finBatchDeleteTagsForm(id: null, selectedDicts: null)
  • finBatchRecordCreator(parentRec, recordType, objectNames, src)
  • finBatchRecordList(recordType, src)
  • finBatchRecordsEquipFilter(type, equipFilter)
  • finBatchRecordsFilter(type, filter, src)
  • finBatchUpdateRecords(dicts, keepName, keepMarkers, type, src: null, keepHis: true)
  • finBatchUpdateRecordsFilter(dicts, keepName, keepMarkers, type, filter, src: null, keepHis: true)
  • finBatchUpdateRecsCommit(libRec, filter, keepName, keepMarkers, keepHis, essential_markers, ignored, cmds)
  • finCertManagementForm(data: null)
  • finChildBooleanData(parentFilter, childFilter)
  • finChildNumberData(parentFilter, childFilter)
  • finCloneEquipPointTags(selectedDicts)
  • finCloneEventsApply(sourceId, events, targets)
  • finCloneEventsForm(id)
  • finCommandAuto(filtstr, levels)
  • finCommit(item, changes: null)
  • finCommitApplyBatchTags(filter, tags)
  • finCommitSites(recs)
  • finConflictingTags(tagarr, data: null)
  • finConnDebugForm(debugStr, nameStr)
  • finConnDebugInfo(id, selectedDicts, mobileMenu: false)
  • finConnectorTemplatePackageAddDevice(templateId, connId, data: null)
  • finConnectorTypes()
  • finCopyFromGraphicForm(id: null, stage: null, data: null)
  • finCopyTableData(tableData)
  • finCopyTag(filter, tag1, tag2, deleteOrig: true)
  • finCopyTagForm(id: null, stage: null)
  • finCreateAlarmTopicCommit(topicName, priorityData, tagsData, targetTagsData, topicId, folderPath)
  • finCreateAlarmTopicForm(topicId: null, folderPath: null)
  • finCreateEditTuningPolicyCommit(changesDict, id, folderPath: null)
  • finCreateEmbeddedLink(viewName, noChrome: true)
  • finCreateFormTemplate(funcName)
  • finCreateFromTemplate(tempList, isJob: null)
  • finCreateNoteTopicCommit(topicName, userList, tagsData, targetTagsData, topicId, folderPath)
  • finCreateNoteTopicForm(topicId: null, folderPath: null)
  • finCreatePod(step: -2, name: "", copyDefault: false, publish: false, ver: "", filter: "", func: "", addRes: null, createKind: "", mergeFn: true)
  • finCurWriteHisEditor(recs, writemode, conntype)
  • finCustomAhuCreate(equipRef, equipInfo)
  • finCustomAhuCreatePoints(equipRef, sensorList, cmdList, spList)
  • finCustomAhuPointProvider(equipRef, pointType, filterPoints)
  • finCustomAhuSelect(id, selectedDicts)
  • finCustomAhuSelectPoints(equipRef)
  • finDelEnumOptForm(name: null)
  • finDeleteAlarms(dates)
  • finDeleteTopicsCommit(topicList)
  • finDeleteTopicsForm(fromDbBuilder: false)
  • finDigestTimeCommit(alarmTime, noteTime)
  • finDigestTimeSettingsForm()
  • finDistinctConnRefs(filter)
  • finDownloadSavedRecordsForm(stage: null, data: null)
  • finDuplicateRec(id, countTimes: 1, excludeChildren: false)
  • finEditDescriptionForm(id)
  • finEditEnumOptForm()
  • finEditNoteTagsCommit(tagsToRemove, tagsToAdd)
  • finEditNoteTagsForm()
  • finEditSummaryCommit(summaryId, newName, newSumOn, newEquipFilter, newPointFilter)
  • finEditSummaryForm(summaryInfo, selected: null)
  • finEditSummaryPickForm()
  • finEditTags(id: null, tags: null, stage: null)
  • finEditTopicsForm()
  • finEditTopicsFormCommit(topicId)
  • finEnumOptForm(stage: null, data: null)
  • finExcelRowPaster()
  • finExcelSite()
  • finExec(src: null, globals: null, returnUpdated: false)
  • finExistingConnectors(selectedIds, connType: null)
  • finExtraCountSystems(rec)
  • finFileType(ioFile)
  • finFindAnyText(grid, searchString)
  • finFindBadChartPts(points)
  • finFindMarkers(record)
  • finFindRefs(object, depth: 1)
  • finFindTargetsForStrTagRename(targetTag, pointFilter, splitInput)
  • finFormAdvancedEditor(stage: null)
  • finFormAhuAirBalance(id)
  • finFormAlertOk(title, msg)
  • finFormApplyBatchTags(stage: null, data: null)
  • finFormBatchAdvancedTagEditor(stage: null, one: null, two: null, three: null)
  • finFormBatchDuplicate(id)
  • finFormChangeAddAhuRef(id, selectedDicts: null)
  • …(其余标题见英文正文)

API 正文(英文) ​

funcs ​

addSimilarTypesAxon function
alarmActivityPeriodsExample
applyReplaceAxon function
breadcrumbsAxon function
buildIsSiemensTrue or false if this is a Siemens build or not
childrenCurVal2Axon function
childrenCurVal3childrenCurVal3(equipList) Like childrenCurVal2 but also returns the ids of the children points
copyModbusFile
diffTypesAxon function
finActionAddFilterFormAxon function
finActionAddFormAxon function
finActionAddFunAxon function
finActionAddRepeatFormAxon function
finActionCatFilterFormAxon function
finActionCatFormAxon function
finActionCatFuncAxon function
finAddChartToGroupAxon function
finAddGraphicThumbnailAxon function
finAddTagsByColumnAxon function
finAddTagsByNameAxon function
finAddTagsByNameApplyAxon function
finAddTagsIoCsvAxon function
finAddTzToPointAdds a tz to a given point
finApplyEnumOptFormAxon function
finApplyNoteTagsAxon function
finApplyUpdateConnectorsAxon function
finBase64DecodeBase64 decoding function Turns a base64 encoded string into a string
finBase64EncodeBase64 encoding function Turns a string into a base64 encoded string
finBatchAdvancedTagDPBackend function for finFormBatchAdvancedTagEditor and finFormNHaystackBatchAdvancedTagEditor
finBatchCloneScheduleApplyAxon function
finBatchDeleteEventsFormAxon function
finBatchDeletePointsFormForm to delete points based on navName and equipRef
finBatchDeleteTagProviderAxon function
finBatchDeleteTagsApplyAxon function
finBatchDeleteTagsFormAxon function
finBatchRecordCreator
finBatchRecordList
finBatchRecordsEquipFilterAxon function
finBatchRecordsFilter
finBatchUpdateRecordsAxon function
finBatchUpdateRecordsFilterAxon function
finBatchUpdateRecsCommitAxon function
finCertManagementFormAxon function
finChildBooleanDatafinChildBooleanData(parentFilter, childFilter) This function will return a grid where each row lists the parent, the children currently on, the number of children currently off, and the total count of all matching children
finChildNumberDatafinChildNumberData(parentFilter, childFilter) This function will return a grid where each row lists the parent, the average of all children values, maximum value among the children, the smallest value among the children, and the total of all the children values
finCloneEquipPointTagsForm to clone the tags from the points of one equip to the corresponding points of other selected equips
finCloneEventsApplyAxon function
finCloneEventsFormAxon function
finCommandAutoAxon function
finCommitAxon function
finCommitApplyBatchTagsThis function applies the comma-separated tags to all records that match the filter
finCommitSitesAxon function
finConflictingTagsAxon function
finConnDebugFormThis form is called from finConnectorDebuggingInfo
finConnDebugInfoShows the debugging info of selected bacnet or haystack connectors from the builder app
finConnectorTemplatePackageAddDeviceAxon function
finConnectorTypesRead connector types
finCopyFromGraphicFormfinCopyFormGraphicForm(stage
finCopyTableDataAxon function
finCopyTagBackend for finCopyTagForm Usage
finCopyTagFormForm to clone tags from one place to another
finCreateAlarmTopicCommitUsed by the "Create Alarm Topic" form to create the alarmTopic record
finCreateAlarmTopicFormCreate a new alarm topic and chooses which alarm priority, tags, target tags to apply it to
finCreateEditTuningPolicyCommitAxon function
finCreateEmbeddedLinkAxon function
finCreateFormTemplateFunction to make a beginning form function instantly
finCreateFromTemplateAxon function
finCreateNoteTopicCommitUsed by the "Create Note Topic" form to create the noteTopic record
finCreateNoteTopicFormAllows the user to create a new note topic and choose which users, tags, and target tags to apply it to by assigning it to topicOn property
finCreatePodAxon function
finCurWriteHisEditorAxon function
finCustomAhuCreateAxon function
finCustomAhuCreatePointsAxon function
finCustomAhuPointProviderAxon function
finCustomAhuSelectAxon function
finCustomAhuSelectPointsAxon function
finDelEnumOptFormAxon function
finDeleteAlarmsAck/Delete Alarms within the datespan
finDeleteTopicsCommitAxon function
finDeleteTopicsFormAxon function
finDigestTimeCommitAxon function
finDigestTimeSettingsFormAxon function
finDistinctConnRefsRead all the distinct conn ref connectors
finDownloadSavedRecordsFormAxon function
finDuplicateRecDuplicates a record and it's children countTimes
finEditDescriptionFormForm to edit description, takes id
finEditEnumOptFormAxon function
finEditNoteTagsCommitThis function is used by the "Edit Note Tags" form
finEditNoteTagsFormThis form allows the user to add or remove existing tags from the noteTags list
finEditSummaryCommitAxon function
finEditSummaryFormAxon function
finEditSummaryPickFormAxon function
finEditTagsfinEditTags(id, tags) Form to edit the tags of a record
finEditTopicsFormA form that allows the user to select an alarm or note topic to edit
finEditTopicsFormCommitAxon function
finEnumOptFormAxon function
finExcelRowPasterAxon function
finExcelSiteAxon function
finExecThis will parse trio file into records then look for "function" tag in each record, then it will execute the function tag expression on the corresponding record
finExistingConnectorsAxon function
finExtraCountSystemsAxon function
finFileTypeAxon function
finFindAnyTextAxon function
finFindBadChartPtsAxon function
finFindMarkersGiven a dictionary, finFindMarkers will return a list of all marker tags found
finFindRefsReturn a grid with a new column called "val" that contains a JSON object with all the Refs found within that record
finFindTargetsForStrTagRenameAxon function
finFormAdvancedEditorAxon function
finFormAhuAirBalanceThis form Runs on AHUs that serve VAV zones
finFormAlertOkBring up an alert dialog that displays a text message
finFormApplyBatchTagsThis function takes no parameters, as the parameters get loaded from the form
finFormBatchAdvancedTagEditorSearches database for points with navNames that start with, end with, or contain the specified keywords and adds specified tags to those
finFormBatchDuplicateThis function takes a record ID, and it will copy and paste it X amount of times
finFormChangeAddAhuRefThis function will take and ID, and a list of selectedDicts
finFormCloneScheduleAxon function
finFormCommandAutoAxon function
finFormConflictingTagsAxon function
finFormConnTuningForm to add connTuningRef tags to filter results
finFormCopyBoundPointsAxon function
finFormCreateEditGraphicAxon function
finFormCreateNoteThis form will create a note on a target
finFormCreateSummaryAxon function
finFormCreateSummaryApplyAxon function
finFormCreateSummaryRefsAxon function
finFormCreateTuningPolicyAxon function
finFormCurWriteHisEditorAxon function
finFormCustomNameAxon function
finFormDisplayTagRenamesAxon function
finFormDuplicateScheduleDayThis is a form to duplicate one day from a schedule to one or more days on the same schedule
finFormEliminateOrphansAxon function
finFormEquipAuditLogThis function takes an ID, and will you the audit log for what has been changed in the time period
finFormEquipPointTagCloneAxon function
finFormEquipPointTagsProviderAxon function
finFormFuncsAxon function
finFormHaystackSyncToNiagaraApplies tags made in FIN
finFormHisImportForm to import history from a CSV file into a point
finFormManageZincLibraryForm to manage the records within the io/Records.zinc libraries
finFormModBusAxon function
finFormNHaystackBatchAdvancedTagEditorSearches haystack points with navNames that start with, end with, or contain the specified keywords and adds specified tags to those
finFormNavMetaAxon function
finFormNewOrEditTuningPolicyAxon function
finFormNoteTagsAxon function
finFormPointNotTzAxon function
finFormPointNotUnitAxon function
finFormPointPriorityViewerForm to view and auto points with priorities
finFormRecordTagCloneThis function takes an id, then it will pop up a form that let's you select the tags you want to clone
finFormReplaceAxon function
finFormRestoreTemplateAxon function
finFormSaveTemplateAxon function
finFormSelectTuningPolicyAxon function
finFormSetImmediateSubscriptionOffTimeAxon function
finFormStandardNameAxon function
finFormStringSearchCommitfinFormStringSearchCommit(data
finFormStringSearchTransForm interface for these functions
finFormStringSearchTransPrevAxon function
finFormStringSearchTransStatsBackend function for finFormStringSearchTrans
finFormSyncToCollAxon function
finFormTagDuplicateAxon function
finFormTagSplitAndRenameAxon function
finFormTempToRealForm to move prepared tempPoints into the project hierarchy
finFormTempToRealStatsAxon function
finFormTextAreaAxon function
finFormTextareaOkAxon function
finFormUniqueEquipTypesAxon function
finFormUniqueTagsEasyAxon function
finFormUpdateConnectorsAxon function
finFormWriteLevelsAxon function
finGenerateSampleTagValueAxon function
finGetMinutesFromCurAxon function
finGetPointRecordsGet records from the PointRecords.zinc file in the finToolsExt pod to display in the batch record creator
finGetUriFromRefAxon function
finGlobalControlThis function opens a form that allows users to select points via a filter, or it takes in selected points, that will then allow the user to invoke command actions to all the selected points
finGlobalControlActionsThis function is part of "Global Control"
finGlobalControlCheckEnumThis function is part of "Global Control"
finGlobalControlCommitThis function is part of "Global Control"
finGlobalControlDurFormThis function is part of "Global Control"
finGlobalControlFilterCheckThis function is part of "Global Control"
finGlobalControlFilterFormThis function is part of "Global Control"
finGlobalControlFilterTableThis function is part of "Global Control"
finGlobalControlFormThis function is part of "Global Control"
finGraphicsBatchTagsAxon function
finGraphicsDeleteRecsAxon function
finHardDeleteA function to delete records permanently
finHaystackHexReplaceFormAxon function
finHisImportFunction to import histories from a CSV file
finHisReadAddMetaAxon function
finHisReadBaseBuildChartsAxon function
finHisReadBaseGetHisAxon function
finHisReadBaseGetTzAxon function
finHisReadBaselineAxon function
finHisReadBaselineCoretakes the following parameters
finHisReadBaselineRollupAxon function
finHisReadBaselineStrPointAxon function
finHisReadBaselineStrPointFFantomized version of the finHisReadBaselineStrPoint function
finHisReadBaslineStatusAxon function
finHisReadComplexBaAxon function
finHisRewriteSpanhisRewriteSpan(hisRecs, startTime, endTime, rewriteFunc
finInvokeAxon function
finIsTagBlackListReturn whether the given tag is a member of the tag blacklist (see finTagBlackList())
finMacroProcess macro pattern with given scope of variable name/value pairs
finMassEditTagsAxon function
finMatchPointsToChartsAxon function
finModBusMapAxon function
finMoveTagBackend for finCopyTagForm Usage
finNavMetaCommitAxon function
finNavMetaDeleteFailFormAxon function
finNavMetaGetLevelsAxon function
finNavMetaWhoAmIThis function takes a Record, and it will return what the record is based on navMeta
finPodFiles
finPointActionsAxon function
finPointNotTzAxon function
finPointNumbersToEquipAxon function
finPostTrioFuncsAxon function
finPrecisionUsage
finProjectedCalcUsed for projecting the use of something like an electric meter's kWh
finReadAlarmTagsAxon function
finReadAlarmTagsSearchAxon function
finReadCloneEventsAxon function
finRecordsSources
finRefDisGet the dis of a ref
finRemoveAnimationEditorAxon function
finRemoveUnitsremoveUnits(number) Removes' the unit from a number passed in
finRenamePointsFormForm to change navNames of points if they match the filter
finRestorePod
finSampleHisReadBaseAxon function
finSaveEquipRecordsFormAxon function
finSaveFloorRecordsFormAxon function
finSavePointRecordsFormAxon function
finSaveRecordsAxon function
finSaveRecordsFormAxon function
finSaveRecordsSeparateAxon function
finSaveSiteRecordsFormAxon function
finSavedChartsfinSavedCharts(Rec id) Finds all the saved charts related to the record that is passed in
finSelectedConnectorTypesAxon function
finSelectedPointsAxon function
finSetImmediateSubOffTimeCommitAxon function
finShowEquipSummaryAxon function
finShowEquipSummaryRecurAxon function
finSoftDeleteA function to send records to the trash
finStrGetfunction
finStringSearchDictsFunction to search through a list of dicts and return only those that meet the defined criteria
finStringSplitDictsFunction to go through a list of dicts and split the specified column by the split character and put it together in a flexible way
finSuperTaggerfinSuperTagger
finSuperTaggerFormAxon function
finSyncPointsToDo
finSyncToCollAxon function
finTagBlackListReturn a grid of all those tags which should not be removed by the user
finTemplatesReturns records with templateOn from pods and the database
finThemeUsedThis function will return the theme that the user is using
finToNumberListFunction to import a string and output values 3-5 will output 3,4,5 starting-ending 4,5 will output 4,5 number1,number2..
finToggleImmediateSubscriptionsAxon function
finTuningPolicyGetStatsAxon function
finTuningPolicyStatsFormAxon function
finUnique
finUniqueConnectorsFind all the unique connectors of the given type, among the recs which match the given filter
finUniqueEquipTypesFind the uniqe types for the equips
finUniqueEquipTypes2Axon function
finUpdateRecordsIgnoredTagsAxon function
finUpdateRecordsIgnoredTags2Axon function
finUploadSavedRecordsFormAxon function
finValidConnectorsAxon function
finWriteBin
finWriteLevelsAxon function
finZincTagBatchEditGiven a list of recs and a tag name such as "schedule" which stores an Zinc encoded grid, apply a change to the row identified by the given tags
finZincTagBatchListGiven a list of recs and a tag name such as "schedule" which stores an Zinc encoded grid return a list of the unique dicts rows in the zinc tag values
findPod
findPointNamesAxon function
funcDefs
getEventsDataAxon function
getHisTagsAxon function
getPodVersion
hideRefAxon function
ignoredConnTagsAxon function
importModbus
ioCopyFile
ioCreateDir
ioExists
ioReadFileStr
ioUnzipPod
ioWriteFile
jaccardIndexAxon function
kioskImageImport
listFile
listOfEquipIdsAxon function
loadPodGraphic
markerOnlyAxon function
navDuplicate2This function calls navDuplicate using the parameters to duplicates records and then adjusts the names
padZeroAxon function
publishPodAxon function
readFileTrio
readFinToolsCsvRead a csv from the pod
runJob
sampleAddTagsAxon function
wrappedDiffRemoveAxon function
wrappedIoReadJsonAxon function
wrappedIoReadStrAxon function


def ​

func:addSimilarTypes ​

addSimilarTypes(this, dict, thisType, percentMatch, types) ​

Axon function


meta ​

deffunc:addSimilarTypes
isfunc
liblib:finTools
nameaddSimilarTypes
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(this,dict, thisType, percentMatch, types)=> do
  dblPerc : percentMatch / 100
  st:""
  n :0
  similarity:this.get("similarity")
  similarity.size.times (i=> do
    // similar
    if ((i != thisType) and (similarity[i] >= dblPerc)) do
      if (n> 0)
        st = st+(", ")
      n = n +1

      st = st+("@type" + padZero(i,3))
      st = st+(" (" + (similarity[i] * 100).floor + "%)")
      dict = dict.set("type"+ padZero(i,3)+"Missing", diffTypes(this, types[i]))
      dict = dict.set("type"+ padZero(i,3)+"Has",     diffTypes(types[i], this))
    end
  end)

  dict = dict.set("similarTypes", st)

  return dict
end


def ​

func:alarmActivityPeriods ​

alarmActivityPeriods(alrm) ​

Example:

readAll(equip or point).alarms(today).map(x=> x.set("periods",x.alarmActivityPeriods))

That sets the periods to be the timestamps and values


meta ​

deffunc:alarmActivityPeriods
isfunc
liblib:finTools
namealarmActivityPeriods

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(alrm) => do
  date2: d=> d.date

  getDatePeriods: (date, periods)=> do
    records: []
    lastEndTime: null

    (0 .. periods.size - 1).each i=> do
        cPeriod: periods[i]
        startMills: date.toJavaMillis.finRemoveUnits + (cPeriod->offset * 60000)
        endMills: startMills + (cPeriod->dur * 60000)

        startTime: startMills.fromJavaMillis(date.tz)
        endTime: endMills.fromJavaMillis(date.tz)

        if ((lastEndTime == null or lastEndTime.toJavaMillis != startTime.toJavaMillis) and cPeriod->offset > 0)
            records = records.add({ts: date, value: 0})

        if(endTime.toJavaMillis > now().toJavaMillis)
            endTime = now()
        else if (endTime.day != startTime.day)
            endTime = dateTime(now().date2, time(23,59,59), date.tz)
        if(lastEndTime != null and lastEndTime.toJavaMillis != startTime.toJavaMillis)
            records = records.add({ts: lastEndTime, value: 0})
        records = records.add({ts: startTime, value: 1})
        lastEndTime = endTime
    end
    if (lastEndTime != null) do
        records = records.add({ts: lastEndTime, value: 0})

        lateNight: dateTime(now().date2, time(23,59,59), date.tz)

        if (lastEndTime.toJavaMillis < lateNight.toJavaMillis)
            records = records.add({ts: lateNight, value: 0})
    end
    records
  end

  getDatePeriods(dateTime(now().date2, time(0,0,0), now().tz), alrm->periods.parseDiscretePeriods)
end


def ​

func:applyReplace ​

applyReplace(filter, tag, searchText, replaceText, chkbx) ​

Axon function


meta ​

deffunc:applyReplace
isfunc
liblib:finTools
nameapplyReplace
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter,tag,searchText,replaceText,chkbx)=>do
  if(chkbx.isList and chkbx.size > 0) recs: readAll(navName==chkbx[0])
  else recs: readAll(parseFilter(filter))
  diffs: []

  /*rsplit: (g,s)=> do
    h: []
    tmp: ""
    if(g.size > 0) do
      (0 .. g.size - 1).each x=> do
        if(g[x..x] != s) tmp = tmp + g[x..x]
        else do
          h = h.add(tmp)
          tmp = ""
        end
      end
      h = h.add(tmp)
    end
    h
  end

  //escape all characters found in regexes, but not * or #
  ["\\",".","[","]","^","\$","(",")","{","}","?","+","|"].each x=> searchText = searchText.replace(x, "\\"+x)
  //replace # with [\d]+
  //replace * with [\s\S]*
  searchText = searchText.replace("*","[\\s\\S]*").replace("#","[\\d]+").rsplit(",").sortr((x,y)=> x.size <=> y.size)*/

  regChars: [".","[","]","^","\$","(",")","{","}","?","+","|"]
  escChars: ["*","#"]
  escCharsTo: {"*": "[\\s\\S]*", "#": "\\d+"}
  escape: false
  splits: []
  newText: ""
  (0 .. searchText.size-1).each i=> do
    ch: searchText[i..i]
    if(escape) do
      if(regChars.contains(ch)) newText = newText + "\\\\\\" + ch
      else if(escChars.contains(ch)) newText = newText + "\\" + ch
      else if(ch == ",") newText = newText + ","
      else newText = newText + "\\\\" + ch
      escape = false
    end else do
      if(ch == "\\") escape = true
      else if(regChars.contains(ch)) newText = newText + "\\" + ch
      else if(escChars.contains(ch)) newText = newText + escCharsTo[ch]
      else if(ch == ",") do
        splits = splits.add(newText)
        newText = ""
      end else newText = newText + ch
    end
  end
  if(escape) newText = newText + "\\\\"
  splits = splits.add(newText).sortr((x,y)=> x.size <=> y.size)

  /*
  hello [world *
  hello \[world *

  hello [world \*
  hello \[world \*
  */

  recs.each row=>do
    changes: {}
    keepRef: row.get(tag)
    text: row.get(tag).toStr
    if(keepRef.isRef) text = "@"+text
    splits.each st=> do
      tmp: reFind(st, text)
      if(tmp != null) do
        val: text.replace(tmp,replaceText)
        if(keepRef.isBool)          val = parseBool(val,false)
        else if(keepRef.isDate)     val = parseDate(val,"YYYY-MM-DD",false)
        else if(keepRef.isDateTime) val = parseDateTime(val,"YYYY-MM-DD hh:mm:ss zzzz",now().tz,false)
        else if(keepRef.isNumber)   val = parseNumber(val,false)
        else if(keepRef.isRef) do
          if(val.startsWith("@"))   val = val[1 .. -1]
                                    val = parseRef(val,false)
        end
        else if(keepRef.isTime)     val = parseTime(val,"hh:mm:ss",false)
        else if(keepRef.isUri)      val = parseUri(val,false)
        changes = changes.set(tag,val)
      end
    end
    if(changes.names.size > 0) diffs = diffs.add(diff(row,changes))
  end

  if(diffs.size > 0) commit(diffs)
end


def ​

func:breadcrumbs ​

Axon function


meta ​

deffunc:breadcrumbs
isfunc
liblib:finTools
namebreadcrumbs

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, iter:null, spEquipFound: null) => do
    currentLevel: readById(id)
    parentEquip: null
    currentEquip: null
    breadCrumbs:[]
    levels: read(navMeta)->equipPath.split("/")[1..-2]

    if(iter == null) iter = 4 //if the first call set max

    /* !-----!switch these two if statements (commented one and first if below) to pass the main equip!-----!*/
    //if(iter > 0) do
    if(iter > 0 or spEquipFound != true) do
      levels.each level => do //search for appropriate level
        if(currentLevel.has(level)) do //level found

          if(level == levels[0])//if top level
            breadCrumbs = breadCrumbs.add({ id: id,
                                            displayName: currentLevel.dis,
                                            rightIconDirection: "right" })
          else if(level == "equip") do //if equip
             if(currentLevel.has("equipRef") == false) do  // if super-parent equip navLevel
               breadCrumbs = breadCrumbs.add({ id: id,
                                               displayName: currentLevel->navName,
                                               highlight })
               breadCrumbs = breadCrumbs.addAll(breadcrumbs(currentLevel->floorRef, iter - 1, true))
              end //end if super parent
              else do // if child equip navLevel
                breadCrumbs = breadCrumbs.add({ id: id,
                                                displayName: currentLevel->navName,
                                                leftIconDirection:"left" })
                breadCrumbs = breadCrumbs.addAll(breadcrumbs(currentLevel->equipRef, iter - 1, false))
              end //end if child
          end //end if equip
          else do//everything else
            breadCrumbs = breadCrumbs.add({ id: id,
                                            displayName: currentLevel.dis,
                                            rightIconDirection: "right" })
            breadCrumbs = breadCrumbs.addAll(breadcrumbs(currentLevel->siteRef, iter - 1))
          end //end everythign else

        end //end if level found
      end //end level search
    end//end if still going

    if(breadCrumbs.size > 4) //make sure highlighted equip stays up
      breadCrumbs = breadCrumbs.remove(3)

    /* testing, shows up in console
    breadCrumbs.each x=> echo(x)
    echo("")
    echo("") */

    return breadCrumbs
  end


def ​

func:buildIsSiemens ​

buildIsSiemens() ​

True or false if this is a Siemens build or not


meta ​

deffunc:buildIsSiemens
isfunc
liblib:finTools
namebuildIsSiemens

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  exts().find(x=> x.has("name") and x->name=="siemensGraphicResources") != null
end


def ​

func:childrenCurVal2 ​

childrenCurVal2(equipList) ​

Axon function


meta ​

deffunc:childrenCurVal2
disvariant of childrenCurVal with default value if curVal i...
isfunc
liblib:finTools
namechildrenCurVal2

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(equipList)=> do

  result: equipList.map(equip =>
  do
    children: navChildren("equip", equip).map(point => readById(point->id))
    children.each(child =>
    do
      childName:  child.dis

      if (child.has("navName"))
         childName = child->navName

      childName = childName.toTagName

      if (child.has("curVal")) do
        if(child->curVal == null) do
          if(child->kind == "Bool")
            equip = equip.set(childName,false)
          else if(child->kind == "Number")
            equip = equip.set(childName,0)
          else do
            if(child.has("enum"))
              equip = equip.set(childName,"missing")
          end
        end
        else
          equip = equip.set(childName, child->curVal)
      end
      else do
        if(child->kind == "Bool")
          equip = equip.set(childName,false)
        else if(child->kind == "Number")
          equip = equip.set(childName,0)
        else do
          if(child.has("enum")) do
            equip = equip.set(childName,"missing")
          end
          else
            equip = equip.set(childName, null)
        end
      end
    end)

    return equip
  end)

  return result
end


def ​

func:childrenCurVal3 ​

childrenCurVal3(equipList) ​

childrenCurVal3(equipList)

Like childrenCurVal2 but also returns the ids of the children points.


meta ​

deffunc:childrenCurVal3
isfunc
liblib:finTools
namechildrenCurVal3
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(equipList)=> do
  result: equipList.map(equip=> do
    children: navChildren("equip", equip).map(point => readById(point->id))
    children.each(child=> do
      childName:  child.dis

      if (child.has("navName")) childName = child->navName
      childName = childName.toTagName

      if (child.has("curVal")) do
        if(child->curVal == null) do
          if(child->kind == "Bool") equip = equip.set(childName,false)
          else if(child->kind == "Number") equip = equip.set(childName,0)
          else if(child.has("enum")) equip = equip.set(childName,"missing")
        end
        else equip = equip.set(childName, child->curVal)
      end
      else do
        if(child->kind == "Bool") equip = equip.set(childName,false)
        else if(child->kind == "Number") equip = equip.set(childName,0)
        else do
          if(child.has("enum"))  equip = equip.set(childName,"missing")
          else equip = equip.set(childName, null)
        end
      end

    equip = equip.set(childName+"Id", child->id)

    end)

    return equip
  end)

  return result
end


def ​

func:copyModbusFile ​

copyModbusFile(recId, path) ​


meta ​

deffunc:copyModbusFile
isfunc
liblib:finTools
namecopyModbusFile

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:diffTypes ​

diffTypes(a, b) ​

Axon function


meta ​

deffunc:diffTypes
isfunc
liblib:finTools
namediffTypes
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(a,b)=> do
  sb:""
  n : 0
  a.get("pointNames").each ((name)=> do
    if (not b.get("pointNames").has(name)) do
      if (n > 0)
        sb = sb + (",")
      sb = sb + name

      n = n+1
    end
  end)
  //echo("diffType " + sb)
  return sb
end


def ​

func:finActionAddFilterForm ​

finActionAddFilterForm() ​

Axon function


meta ​

appFormOnbuilder
deffunc:finActionAddFilterForm
distoLocale("j2FinToolsExt::addAction")
folderPathtoLocale("j2FinToolsExt::actionCategories")
formOnsite or floor or equip or (point and not schedule)
isfunc
liblib:finTools
namefinActionAddFilterForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body: [
  {name: "filterOne", editorType: "filter", prompt: toLocale("finStackExt::finFilter")+":", defVal: ""},
  {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
  {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {"dis":toLocale("j2FinToolsExt::addAction"),
  "name": "finActionCatAddForm",
  "body": body.toJSON,
  "cancelButton": "\$cancelButton",
  "commitButton": "\$commitButton",
  "commitAction": "finActionAddForm(\$filterOne, 1)",
  "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finActionAddForm ​

finActionAddForm(filter, count, data: null) ​

Axon function


meta ​

deffunc:finActionAddForm
isfunc
liblib:finTools
namefinActionAddForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter, count, data: null) => do

  fincats: readAll(finCategory).colToList("name")
  group: { name: "group", editorType: "group", horizontal: true}
  children:[{ name: "label", editorType: "label", text: "dis", width: 200}]

  fincats.each f => do
    children = children.add({ name: "label", editorType: "label", text: f.split("_")[0], width: 100})
  end
  children = children.add({ name: "label", editorType: "label", text: "expr", width: 200})

  qwerval: ""
  asdfval: ""
  zxcvval: ""
  if(data != null) do
    qwerval = data[0]
    asdfval = data[1]
    zxcvval = data[2]
  end

  body: [
    { editorType: "group",
      horizontal,
      children: children
    },

    { editorType: "group",
      horizontal: true,
      children: [
      {name: "qwer", editorType: "textinput", defVal: qwerval, width: 200},
      {name: "asdf", editorType: "numericstepper", width: 100, minVal: 1, maxVal: 10, defVal: asdfval},
      {name: "zxcv", editorType: "textinput", width: 200, defVal: zxcvval}
    ]},

    { name: "cancelButton",
      editorType: "button",
      label: toLocale("finStackExt::cancel"),
      controlBar: true
    },

    { name: "commitButton",
      editorType: "button",
      label: toLocale("finStackExt::coreApply"),
      controlBar: true
    }
  ]

  if(data != null) do
    body = body.insert(0, {name: "lkjlkj", editorType: "label", text: toLocale("j2FinToolsExt::invalidNumValOneThruTen")})
  end

   {
     "dis": toLocale("j2FinToolsExt::addAction"),
     "name": "finActionAddForm" + random(0..10000),
     "body": body.toJSON,
     "cancelButton": "\$cancelButton",
     "commitButton": "\$commitButton",
     "commitAction" : "finActionAddRepeatForm("+toAxonCode(filter)+", "+count+", [\$qwer, \$asdf, \$zxcv])",
     "finForm": marker()
   }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finActionAddFun ​

finActionAddFun(filter, list) ​

Axon function


meta ​

deffunc:finActionAddFun
isfunc
liblib:finTools
namefinActionAddFun

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter, list) => do
  pts: readAll(parseFilter(filter))

  pts.each p => do
    if(p.has("actions")) do
      a: p -> actions.ioReadZinc()
      a = a.add({dis: list[0], hvac: list[1], expr: list[2]})
    end else do
      a: [{dis: list[0], hvac: list[1], expr: list[2]}]
    end
    a = a.ioWriteZinc("")
    p.diff({action: a}).commit()
  end
end


def ​

func:finActionAddRepeatForm ​

finActionAddRepeatForm(filter, count, list) ​

Axon function


meta ​

deffunc:finActionAddRepeatForm
isfunc
liblib:finTools
namefinActionAddRepeatForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter, count, list) => do
  if(list[1] != "" and (list[1] < 1 or list[1] > 10)) do
    finActionAddForm(filter, count, list)
  end else do
    body: [
    { name: "labelOne", editorType: "label", prompt: toLocale("finStackExt::warning").upper, text: toLocale("j2FinToolsExt::aboutToModWarning").replace("{num}", count.toStr)},
    { name: "labelOne", editorType: "label", text: toLocale("j2FinToolsExt::continuePrompt")},
    { name: "checkOne", editorType: "checkbox", label: toLocale("j2FinToolsExt::continueAddingActions"), defVal: false},
    { name: "cancelButton", editorType: "button", label:toLocale("finStackExt::cancel"), controlBar: true},
    { name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {"dis":toLocale("j2FinToolsExt::addAction"),
    "name": "finActionAddRepeatForm",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "[finActionAddFun("+toAxonCode(filter)+", "+toAxonCode(list)+"), if(\$checkOne) finActionAddForm("+toAxonCode(filter)+", "+(count + 1)+") else 0][1]",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finActionCatFilterForm ​

finActionCatFilterForm() ​

Axon function


meta ​

appFormOnbuilder
deffunc:finActionCatFilterForm
distoLocale("j2FinToolsExt::actionCatPermission")
finActionCat✓
folderPathtoLocale("j2FinToolsExt::actionCategories")
formOnsite or equip or floor or (point and not schedule)
isfunc
liblib:finTools
namefinActionCatFilterForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body: [
  {name: "filterOne", editorType: "filter", prompt: toLocale("finStackExt::finFilter"), defVal:""},
  {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
  {name: "commitButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
  ]

  {"dis": toLocale("j2FinToolsExt::actionCatPermission"),
  "name": "finActionCatFilterForm",
  "body": body.toJSON,
  "cancelButton": "\$cancelButton",
  "commitButton": "\$commitButton",
  "commitAction": "finActionCatForm(\$filterOne)",
  "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finActionCatForm ​

finActionCatForm(filter, data: null) ​

Axon function


meta ​

deffunc:finActionCatForm
finActionCat✓
isfunc
liblib:finTools
namefinActionCatForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter, data: null) => do
  cou: 0
  fincats: readAll(finCategory).colToList("name")
  cact: "["
  group:{name: "group", editorType: "group", horizontal: true}
  children:[{name: "disLabel", editorType: "label", text: "dis", width: 200}]
  w: 5

  fincats.each f =>
  do
    children = children.add({
      name: "catLabel",
      editorType: "label",
      text: f.split("_")[0],
      width: 100
    })

    w = w + 1
  end

  children = children.add({name: "exprLabel", editorType: "label", text: "expr", width: 150})
  children = children.add({name: "orderLabel", editorType: "label", text: "order", width: 100})

  body: [
    {editorType: "group", horizontal: true, children: children},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  alreadyUsed: {}

  if (data != null)
  do
    data.each act =>
    do
      children: [{name: cou+"textOne", editorType:"textinput", defVal: act->dis, width: 200}]
      cact = cact + "{org: \"" + act->org + "\", dis: \$" + cou + "textOne, "

      fincats.each f =>
      do
        children = children.add({
          name: cou+"stepper"+toTagName(f),
          editorType:"numericstepper",
          defVal: if(act.has(f) and act.trap(f) != "") act.trap(f) else "",
          width: 100,
          minVal:1,
          maxVal: 10
        })

        cact = cact + toTagName(f) + ": [\$" + cou + "stepper" + toTagName(f) + "], "
      end

      children = children.add({name: cou+"textTwo", editorType: "textinput", defVal: act->expr, width: 200})
      children = children.add({name: cou+"order", editorType: "numericstepper", width: 100, minVal:0, defVal: cou})

      cact = cact + "expr: \$" + cou + "textTwo, order: \$" + cou + "order}, "
      body = body.add(group.set("children", children))
      cou = cou + 1
    end
  end
  else
  do
    readAll(parseFilter(filter)).findAll(x=> x.has("actions")).colToList("actions").unique.each acts =>
    do
      acts = acts.ioReadZinc

      acts.each act =>
      do
        ident: act->dis + act->expr

        if (not alreadyUsed.has(ident.toTagName))
        do
          alreadyUsed = alreadyUsed.set(ident.toTagName, 0)
          cact = cact + "{org: \""+ finBase64Encode(ident) +"\", dis: \$" + cou + "textOne, "
          children: [{name: cou+"textOne", editorType:"textinput", defVal: act->dis, width: 200}]

          fincats.each f =>
          do
            children = children.add({
              name: cou+"stepper"+toTagName(f),
              editorType:"numericstepper",
              defVal: if(act.has(f) and act.trap(f) != "") act.trap(f) else "",
              width: 100,
              minVal:1,
              maxVal: 10
            })

            cact = cact + toTagName(f) + ": [\$" + cou + "stepper" + toTagName(f) + "], "
          end

          children = children.add({name: cou+"textTwo", editorType: "textinput", defVal: act->expr, width: 200})
          children = children.add({name: cou+"order", editorType: "numericstepper", width: 100, minVal:0, defVal: cou})

          cact = cact + "expr: \$" + cou + "textTwo, order: \$" + cou + "order}, "
          body = body.add(group.set("children", children))
          cou = cou + 1
        end
      end
    end
  end

  cact = cact[0..-3] + "]"

  if (data != null)
  do
    body = body.insert(0, {name: "lkjlkj", editorType: "label", text: toLocale("j2FinToolsExt::invalidNumValOneThruTen")})
  end

  js: [
    "function checkJobStatus(jobHandle) {",
      "var promise;",
      "if (jobHandle === undefined) {",
        "promise = finstack.evalAll(['jobStatusAll().find(v => v->dis.startsWith(\"finActionCatFunc\") and v->started > "+now().toAxonCode+")']);",
      "} else {",
        "promise = finstack.evalAll(['jobStatusAll(\"'+jobHandle+'\")[0]']);",
      "}",
      "promise.then(function(event) {",
        "var jobStat = event.result[0].toObj(false, false, true);",
        "var isDone = jobStat['jobStatus'].startsWith('done');",
        "if (isDone) {",
          "window.top.app.HideLoader();",
        "} else {",
          "window.top.app.HideLoader();",
          "window.top.app.ShowLoader(languageManager['workingLoader']);",
          "setTimeout(function(){ checkJobStatus(jobStat['handle']); }, 2000);",
        "}",
      "});",
    "}",
    "window.top.app.ShowLoader(languageManager['workingLoader']);",
    "checkJobStatus();"
  ]

  {
    "dis":toLocale("j2FinToolsExt::actionCatPermission"),
    "name": "finActionCatForm" + random(0..10000),
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "jobRun(finActionCatFunc("+ toAxonCode(filter) +", "+cact+"))",
    "completeAction": js.concat("\n"),
    "width": if (w > 5) (w * 100) + 25 else null,
    "finForm": marker(),
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finActionCatFunc ​

finActionCatFunc(filter, data) ​

Axon function


meta ​

deffunc:finActionCatFunc
finActionCat✓
isfunc
liblib:finTools
namefinActionCatFunc

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter, data) => do
  fCat: readAll(finCategory).colToList("name")
  failed : false
  data.each x=> do
    fCat.each y=> do
      c: x.trap(y)
      if(c.size > 0 and (c[0] < 1 or c[0] > 10)) failed = true
    end
  end
  if(failed) do
    finActionCatForm(filter, data)
  end else do
    data = data.sort((x,y)=> x->order <=> y->order).map(x=> x.set("org", x->org.finBase64Decode).set("dis", x->dis.trim))

    findData: q => do
      data.find(r => r->org == q->dis + q->expr)
    end

    readAll(parseFilter(filter)).findAll(x=>x.has("actions")).each p => do
      a: p -> actions.ioReadZinc()
      a = a.findAll action => do
        not(action.findData -> dis == "")
      end

      a = a.map action => do
        fD: action.findData
        if(fD -> dis != action -> dis) action = action.set("dis", fD->dis)
        if(fD -> expr != action -> expr) action = action.set("expr", fD->expr)
        action = action.set("order", fD->order)

        fCat.each fC => do
          c: fD.trap(fC)
          if(c.size() > 0) action = action.set(fC, c[0])
          else action = action.remove(fC)
        end
        action
      end
      a = a.sort((x,y) => x->order <=> y->order).map(x=> x.remove("order"))
      colNames: a.toGrid.removeCols(["dis", "expr", "hvac_finCat"]).colNames
      a = a.toGrid.reorderCols(["dis", "expr", "hvac_finCat"].addAll(colNames)).ioWriteZinc("")
      p.diff({actions: a}).commit()
    end
  end
end


def ​

func:finAddChartToGroup ​

finAddChartToGroup(groupedCharts, group, newChart, vNum, point, current) ​

Axon function


meta ​

baseChart✓
deffunc:finAddChartToGroup
isfunc
liblib:finTools
namefinAddChartToGroup
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(groupedCharts, group, newChart, vNum, point, current) => do
  curGroup: groupedCharts.find(v => v->groupName == group)

  if(point->kind == "Str") newChart = finHisReadBaselineStrPointF(newChart, point.dis).addMeta(newChart.meta).addColMeta("ts", newChart.col("ts").meta)

  joinFailed: false

  if(curGroup != null) do
    groupedCharts = groupedCharts.map(row => do
      if(row->groupName == group) do
        try row.set("charts", row->charts.join(newChart, "ts").sort("ts"))
        catch do
          joinFailed = true
          row
        end
      end else row
    end)
  end

  if(curGroup == null or joinFailed) do
    newChart = newChart.addMeta({dis: toLocale("j2FinToolsExt::compareRecent"), hisStart: current.meta->hisStart, hisEnd: current.meta->hisEnd, hisLimit: 10000})
    try newChart = newChart.addMeta({hisInterval: current.meta->hisRollupInterval.toStr, hisIntervalUnit: current.meta->hisRollupInterval.unit}) catch ""
    newChart = newChart.addColMeta("ts", current.col("ts").meta)
    groupedCharts = groupedCharts.add({groupName: if(joinFailed) group + "1" else group, charts: newChart.addMeta({joinFailed})})
  end

  return groupedCharts
end


def ​

func:finAddGraphicThumbnail ​

finAddGraphicThumbnail(graphicRef, thumbRef) ​

Axon function


meta ​

baSuExec✓
deffunc:finAddGraphicThumbnail
isfunc
liblib:finTools
namefinAddGraphicThumbnail
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(graphicRef, thumbRef) => do
  dothestuff: (gref, tref)=> do
    readById(gref).diff({thumbnail: tref, finThumb:"✓"}).commit
  end

  try baSuExec(dothestuff, curFunc(), [graphicRef, thumbRef])
  catch dothestuff(graphicRef, thumbRef)
end


def ​

func:finAddTagsByColumn ​

finAddTagsByColumn(stage: null, data: null, extra: null) ​

Axon function


meta ​

appFormOnfolio
deffunc:finAddTagsByColumn
distoLocale("j2FinToolsExt::addTagsByCol")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
isfunc
liblib:finTools
namefinAddTagsByColumn
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, data: null, extra: null) => do
  query:{
    "dis": toLocale("j2FinToolsExt::addTagsByCol"),
    "name": "finAddTagsByColumn"+random(0..1000),
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "finForm": marker(),
    "helpDoc": "/wiki/display/FINStack/Add+Tags+By+Column"
  }

  if(stage == null)
  do
    body:[
    {name: "table", editorType: "table", prompt: toLocale("j2FinToolsExt::pasteExcelTagger") +":", pasteTo, height: 200},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
    ]

    query.set("body", body.toJSON).set("commitAction", "finAddTagsByColumn(2, \$table)").toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 2)
  do
    names: data.toGrid.colNames
    dind: names.index(names.find(x=> x.lower.contains("name")))
    if(dind == null) dind = 0
    markers: []
    data.toGrid.each x=> do
      if(x.has("marker")) markers = markers.addAll(x->marker.split(",").map(y=> y.trim))
    end

    body:[
      {
        name: "combo",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::selectNavNameCol")+":",
        dataProvider: names.toAxonCode,
        labelField: "val",
        selectedValueTags: "val",
        defIndex: dind
      },

      {
        name: "list",
        editorType: "list",
        prompt: toLocale("j2FinToolsExt::tagsToAdd")+":",
        dataProvider: names.addAll(markers).unique.toAxonCode+".findAll(x=> x != \$combo and x != \"marker\")",
        labelField: "val"
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    js: [
      "function checkJobStatus(jobHandle) {",
        "var promise;",
        "if (jobHandle === undefined) {",
          "promise = finstack.evalAll(['jobStatusAll().find(v => v->dis.startsWith(\"finAddTagsByColumn\") and v->started > "+now().toAxonCode+")']);",
        "} else {",
          "promise = finstack.evalAll(['jobStatusAll(\"'+jobHandle+'\")[0]']);",
        "}",
        "promise.then(function(event) {",
          "var jobStat = event.result[0].toObj(false, false, true);",
          "var isDone = jobStat['jobStatus'].startsWith('done');",
          "if (isDone) {",
            "window.top.app.HideLoader();",
          "} else {",
            //"var msg;",
            //"if (jobStat != null && jobStat != undefined) { msg = window.languageManager['loaderLoading'] + jobStat['progress'] + '%'; }",
            //"else { msg = window.languageManager['loaderLoading'] + '0%'; }",
            "window.top.app.HideLoader();",
            "window.top.app.ShowLoader(languageManager['addingTagsMsg']);",
            "setTimeout(function(){ checkJobStatus(jobStat['handle']); }, 2000);",
          "}",
        "});",
      "}",
      "window.top.app.ShowLoader(languageManager['addingTagsMsg']);",
      "checkJobStatus();"
    ]

    query.merge({
      body: body.toJSON,
      commitAction: "jobRun(finAddTagsByColumn(3, "+ data.toAxonCode +", \$combo))",
      completeAction: js.concat("\n")
    }).toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 3)
  do
    tags: data.toGrid.colNames.findAll(x => x != extra)
    tmp: {}
    val: ""

    data.each x =>
    do
      readAll(parseFilter(extra +"=="+ x.trap(extra).toAxonCode)).each y =>
      do
        tmp = {}
        tags.each z=>
        do
          if(x.has(z))
          do
            val = x.trap(z)

            if(z == "marker") val = val.split(",").map(g=> g.trim).each g=> tmp = tmp.set(g.toTagName, marker())
            else if(val == "marker") tmp = tmp.set(z, marker())
            else tmp = tmp.set(z, val)
          end
        end

        y.diff(tmp).commit
      end
    end
  end
end


def ​

func:finAddTagsByName ​

finAddTagsByName(id: null, refill: null) ​

Axon function


meta ​

appFormOnbuilder,folio
deffunc:finAddTagsByName
distoLocale("j2FinToolsExt::addTagsByName")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
formOnfoo or site or floor or equip or (point and not schedule...
isfunc
liblib:finTools
namefinAddTagsByName

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id:null, refill: null)=> do
  filter:"point"
  body: []
  colNameDefVal: "navName"
  pasteTableDefVal: "[]"

  if (refill != null)
  do
    filter = refill["filterStr"]
    colNameDefVal = refill["colName"]
    pasteTableDefVal = refill["pastedData"].toAxonCode

    if (colNameDefVal.isEmpty)
      body = body.add({name: "colNameMissingLabel", editorType: "label", text: toLocale("j2FinToolsExt::provideColName")})
    else
      body = body.add({name: "pasteTableMissingLabel", editorType: "label", text: toLocale("j2FinToolsExt::pasteExcelDataErrPrompt")})
  end
  else if (id != null)
  do
    rec:id.toRec

    if(rec.has("site"))
      filter = "point and siteRef==@"+id
    else if(rec.has("floor"))
      filter = "point and floorRef==@"+id
    else if(rec.has("equip"))
      filter = "point and equipRef==@"+id
  end

  body = body.addAll([
    {
      name:"filter",
      editorType:"filter",
      defVal:filter
    },
    {
      name:"colName",
      prompt:toLocale("finStackExt::gTypeColumn"),
      editorType:"textinput",
      defVal:colNameDefVal
    },
    {
      name: "table",
      editorType: "table",
      prompt: toLocale("j2FinToolsExt::copyPasteTableToExcel")+":",
      height:200,
      copyFrom,
      dataProvider:"sampleAddTags(\$colName,\$filter)",
      toolTip:"Right click on this grid and click copy. Then paste this into Excel and edit it. After that copy it from excel and paste below."},
    {
      name: "pastedData",
      editorType: "table",
      pasteTo,
      dataProvider:pasteTableDefVal,
      prompt: toLocale("j2FinToolsExt::pasteExcelTagger") + ":",
      height:200},

    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    { name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ])

  js: [
    "function checkJobStatus(jobHandle) {",
      "var promise;",
      "if (jobHandle === undefined) {",
        "promise = finstack.evalAll(['jobStatusAll().find(v => v->dis.startsWith(\"finAddTagsByNameApply\") and v->started > "+now().toAxonCode+")']);",
      "} else {",
        "promise = finstack.evalAll(['jobStatusAll(\"'+jobHandle+'\")[0]']);",
      "}",
      "promise.then(function(event) {",
        "var jobStat = event.result[0].toObj(false, false, true);",
        "var isDone = jobStat['jobStatus'].startsWith('done');",
        "if (isDone) {",
          "window.top.app.HideLoader();",
        "} else {",
          "window.top.app.HideLoader();",
          "window.top.app.ShowLoader(languageManager['addingTagsMsg']);",
          "setTimeout(function(){ checkJobStatus(jobStat['handle']); }, 2000);",
        "}",
      "});",
    "}",

    "if (\$pastedData && (\$pastedData).length > 0 && \$colName && colName !== '')",
    "{",
      "window.top.app.ShowLoader(languageManager['addingTagsMsg']);",
      "checkJobStatus();",
    "}"
  ]

  {
    "dis": toLocale("j2FinToolsExt::addTagsByName"),
    "name": "addTagsByNameForm" + (if (refill != null) random(0..1000) else ""),
    "width":700,
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "if (isEmpty(\$pastedData) or isEmpty(\$colName)) finAddTagsByName("+id.toAxonCode+", {pastedData: \$pastedData, colName: \$colName, filterStr: \$filter}) else jobRun(finAddTagsByNameApply(\$pastedData,\$colName))",
    "completeAction": js.concat("\n"),
    "helpDoc":"/wiki/display/FINStack/Add+Tags+by+Name",
    "finForm": marker(),
    "refreshTrees": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finAddTagsByNameApply ​

finAddTagsByNameApply(grid, colName) ​

Axon function


meta ​

deffunc:finAddTagsByNameApply
isfunc
liblib:finTools
namefinAddTagsByNameApply
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(grid,colName)=> do
  grid.each( row=> do
    name :row.get(colName).toStr
    navLevel: if(row.has("navLevel")) row->navLevel else ""
    filter : "readAll(" + (if(navLevel != "") "(" + navLevel + ") and" else "" ) + " (" + colName +" or dis)).findAll(r=> if(r.has(\""+colName+"\")) reMatches(r\"" +name +"\",r.get(\""+colName+"\").toStr) else reMatches(r\""+name+"\",r.dis()) )"

    founds: eval(filter)

    specialTags:[]
    tags :if(row.get("addTags") != null) row.get("addTags") else ""
    tagArr :{}
    if(tags != "") do
      tagItems : tags.split(",")
      tagItems.each(it=> do
        if(it.index(":")>=0) do
          kv: it.split(":")
          tagArr = tagArr.set(kv.get(0),kv.get(1))
        end
        else do
          if(it.startsWith("-")) do
            tagArr = tagArr.set(it.replace("-",""),removeMarker())
            specialTags = specialTags.add(it.replace("-",""))
          end
          else do
            tagArr = tagArr.set(it,marker())
            specialTags = specialTags.add(it)
          end
        end
      end)
    end
    row.each( (v,k)=> do
      if(k != colName and k != "navLevel" and k != "addTags" and v != "" and v != null) do
        tagArr = tagArr.set(k,v)
      end
    end)

    dic:{}
    tagArr.each( (v,k)=> do
      if(isStr(v)) do
        v = v.toStr
        if(parseNumber(v,false) != null)
          dic = dic.set(k, parseNumber(v))
        else if(v.toStr.lower == "false" or v.toStr.lower == "true")
          dic = dic.set(k, parseBool(v.toStr.lower))
        else if(parseDateTime(v,"YYYY-MM-DD'T'hh:mm:SS.FFFFFFFFFz zzzz",now().tz,false) != null)
          dic = dic.set(k, parseDateTime(v,"YYYY-MM-DD'T'hh:mm:SS.FFFFFFFFFz zzzz",now().tz))
        else if(parseDate(v,"YYYY-MM-DD",false) != null)
          dic = dic.set(k, parseDate(v,"YYYY-MM-DD"))
        else if(parseTime(v,"hh:mm:SS",false) != null)
          dic = dic.set(k, parseTime(v,"hh:mm:SS"))
        else if(v.startsWith("@")) do
          r:parseRef(v.replace("@",""),false)
          dic = dic.set(k,r)
        end
        else if(v == "M") do
          dic = dic.set(k,marker())
          if(k == "sensor" or k=="cmd" or k=="sp")
            specialTags = specialTags.add(k)
        end
        else
          dic = dic.set(k, v.toStr.replace("\"", ""))
      end
      else
        dic = dic.set(k,v)

    end)

    pointTag:""
    if(specialTags.size > 0)
      specialTags.each(t=>do
        if((t == "cmd" or t == "sp" or t == "sensor") and pointTag != "")
          pointTag = t
      end)
    //echo("point tag:"+pointTag)
    founds.each(r=> do
      newRec: r
      dic.each( (val,k)=> do
        newRec = newRec.set(k,val)
      end)
      apply:{}

      newRec.stripUncommittable.each((v,k) => do
        if(v != null) do
          if((k == "sensor" or k=="cmd" or k=="sp") and (newRec.has("point")) and (k != pointTag) and pointTag != "")
            apply = apply.set(k,removeMarker())
          else if (not finIsTagBlackList(k))
            apply = apply.set(k,v)
        end
      end)

      //echo("applyRec:" +apply)
      commit(diff(r,apply))
    end)
  end)
end


def ​

func:finAddTagsIoCsv ​

finAddTagsIoCsv(data: null) ​

Axon function


meta ​

deffunc:finAddTagsIoCsv
isfunc
liblib:finTools
namefinAddTagsIoCsv
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(data: null) => do
  if(not data.isStr) do
    body: [
    {name: "filter", editorType: "filter", prompt: toLocale("finStackExt::finFilter")+":", defVal: "point"},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {"dis": toLocale("j2FinToolsExt::addTagsFromCsv"),
    "name": "finAddTagsIoCsv",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "finAddTagsIoCsv(\$filter)",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end else do
    csv: 0
    try csv = ioReadCsv(`io/finAddTagsIoCsv.csv`) catch do
      csv = ioReadCsv(`fan://j2FinToolsExt/assets/finAddTagsIoCsv.csv`)
      csv.ioWriteCsv(`io/finAddTagsIoCsv.csv`)
    end
    points: []
    tdat: ""
    csv.each x=> do
      tdat = data
      if(x.has("filter")) tdat = tdat + " and (" + x->filter + ")"
      points = readAll(parseFilter(tdat)).map(y=> if(y.has("navName")) y else if(y.has("dis")) y.set("navName",y->dis) else y.set("navName",y.dis))
      if(x.has("contains")) points = points.findAll(y=> x->contains.split(",").map(z=> y->navName.contains(z.trim)).findAll(z=> z).size > 0)
      if(x.has("startsWith")) points = points.findAll(y=> x->startsWith.split(",").map(z=> y->navName.startsWith(z.trim)).findAll(z=> z).size > 0)
      if(x.has("endsWith")) points = points.findAll(y=> x->endsWith.split(",").map(z=> y->navName.endsWith(z.trim)).findAll(z=> z).size > 0)
      points.each y=> y.diff(eval("{"+x->applyTags+"}")).commit
    end
  end
end


def ​

func:finAddTzToPoint ​

finAddTzToPoint(pointId, basu: false) ​

Adds a tz to a given point. Function tries to apply parent site's tz to point. If site has no tz, local tz is used instead.


meta ​

baSuExec✓
deffunc:finAddTzToPoint
isfunc
liblib:finTools
namefinAddTzToPoint
timez✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(pointId, basu:false) => do
  wrapper: (id, tiz) => do
    readById(id).diff({tz: tiz}).commit
  end

  //function to find tz
  findTz:(point) => do
    curSite: null

    if(point.has("siteRef")) do
      curSite = readById(point->siteRef)
      if(curSite.has("tz"))
        return curSite->tz
    end

    return now().tz
  end

  timezone: findTz(readById(pointId))

 if(not basu) readById(pointId).diff({tz: timezone}).commit
 else baSuExec(wrapper, curFunc(), [pointId, timezone])
end


def ​

func:finApplyEnumOptForm ​

finApplyEnumOptForm(stage: null, data: null) ​

Axon function


meta ​

appFormOnfolio
deffunc:finApplyEnumOptForm
distoLocale("j2FinToolsExt::applyEnumOpts")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
isfunc
liblib:finTools
namefinApplyEnumOptForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage:null, data:null) => do
  enumRec: read(enumMeta,false)

  if(enumRec == null) do
    return {"dis": toLocale("j2FinToolsExt::applyEnumOpts"),
      "name": "finApplyEnumOptForm0",
      "body": [
        {name:"lbl",editorType:"label", text: toLocale("j2FinToolsExt::configEnumOptsFirst")},
        {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
      ].toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end

  if(stage == null) do
    sets : []
    enumRec.each((v,k) => if(k != "id" and k != "dis" and k != "enumMeta" and k != "mod") sets = sets.add({val:k}) )

    body : [
      {name: "query", editorType:"filter", prompt: toLocale("finStackExt::pointFilter")+":"},
      {name: "setPick", editorType:"combobox",dataProvider: sets.toJSON,
        labelField: "val", selectedValueTags: "val", defIndex: 0,
         prompt: toLocale("j2FinToolsExt::optsSetName")+":"},
      {name: "writable", editorType:"checkbox",defVal:false, prompt:toLocale("j2FinToolsExt::makeWritable")},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]
    {"dis": toLocale("j2FinToolsExt::applyEnumOpts"),
      "name": "finApplyEnumOptForm",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "finApplyEnumOptForm(1,{query:\$query, setName:\$setPick.toTagName, writable:\$writable})",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})

  end else if(stage == 1) do
    points : readAll(parseFilter("(" + data->query + ") and point"))
    enumStr : enumRec.trap(data->setName).ioReadZinc.toRecList.map(r => r->name).concat(",")
    points.each( p => do
      if(data->writable) do
        diff(p, {kind:"Str", curConvert:"enumNumberToStr(" + data->setName + ")", writeConvert:"enumStrToNumber(" + data->setName + ")", enum: enumStr }).commit
      end
      else do
        diff(p, {kind:"Str", curConvert:"enumNumberToStr(" + data->setName +")",writeConvert:removeMarker(), enum: enumStr }).commit
      end
    end)

    {"dis": toLocale("j2FinToolsExt::applyEnumOpts"),
      "name": "finApplyEnumOptForm1",
      "body": [
        {name:"lbl",editorType:"label", text: toLocale("j2FinToolsExt::pointsWereAffected").replace("{count}", points.size.toStr)},
        {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
      ].toJSON,
      "commitButton": "\$commitButton",
      "commitAction": "",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finApplyNoteTags ​

finApplyNoteTags(selectedIds, tags) ​

Axon function


meta ​

deffunc:finApplyNoteTags
disSet tags to certain notes
helpUsage finApplyNoteTags([@1121212-2323232,@1121212-12121]...
isfunc
liblib:finTools
namefinApplyNoteTags

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(selectedIds, tags) => do
   changes:{}
   tags.each tag=> do
     changes= changes.set(tag.lower(),marker())
   end
   selectedIds.each id => do
     note: read(parseFilter("id == " + id.toAxonCode))

     if(tags.size > 0)
       commit(diff(note,changes))
   end
end


def ​

func:finApplyUpdateConnectors ​

finApplyUpdateConnectors(selectedIds, connType, existingConnectors, validConnector) ​

Axon function


meta ​

deffunc:finApplyUpdateConnectors
isfunc
liblib:finTools
namefinApplyUpdateConnectors

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(selectedIds, connType, existingConnectors, validConnector) => do

  connRef: connType + "ConnRef"
  recList : finSelectedPoints(selectedIds)

  recList.each rec => do
    rec.each((v,k) => do
      if ((k == connRef) and existingConnectors.contains(v)) do
        commit(diff(rec, {connRef: validConnector->id}.set(connRef, validConnector->id)))
      end
    end)
  end

end


def ​

func:finBase64Decode ​

finBase64Decode(inp, checked: true) ​

Base64 decoding function Turns a base64 encoded string into a string.


meta ​

deffunc:finBase64Decode
isfunc
liblib:finTools
namefinBase64Decode

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finBase64Encode ​

finBase64Encode(inp) ​

Base64 encoding function Turns a string into a base64 encoded string


meta ​

deffunc:finBase64Encode
isfunc
liblib:finTools
namefinBase64Encode

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finBatchAdvancedTagDP ​

finBatchAdvancedTagDP(num: null, sec: null, xtra: 0) ​

Backend function for finFormBatchAdvancedTagEditor and finFormNHaystackBatchAdvancedTagEditor


meta ​

deffunc:finBatchAdvancedTagDP
isfunc
liblib:finTools
namefinBatchAdvancedTagDP

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(num: null, sec: null, xtra: 0) => do //belongs to finFormBatchAdvancedTagEditor and finFormNHaystackBatchAdvancedTagEditor
  spsort: inp=> inp.sort(r=> if(r.has("filter")) 1 else -1).sort(r=> if(r.has("filter") and (r->filter.contains("and sp") or r->filter.contains("and cmd"))) -1 else 1)

  if(isBool(num)) do
    x: []
    if(xtra > 0) (1..xtra).each y=> x = x.add({tagsToAdd: "", filter: ""}.set(sec, "")) //add extra columns

    fncs: funcs(finApplyFilters).findAll(y=> y.has("name")) //get stuff from functions
    tmp: []
    fncs.each y=> do
      try eval(y->name+"()").each g=> tmp = tmp.add(g) catch 0
    end

    out: []
    try stuff: ioReadTrio(`io/finApplyFilters.trio`) catch stuff: [] //get stuff from files

    out = out.addAll(stuff.findAll(r=> r.has(sec)).map(r=> r.set("selected", num)))
    out = out.addAll(tmp.findAll(r=> r.has(sec)).map(r=> r.set("selected", num)))

    if(out.size == 0) out = [ //default data
      {startsWith: "stuff,stuff", filter: "and stuff", tagsToAdd: "stuff,stuff"},
      {endsWith: "stuff,stuff", filter: "and stuff", tagsToAdd: "stuff,stuff"},
      {contains: "stuff,stuff", filter: "and stuff", tagsToAdd: "stuff,stuff"}
      ].findAll(r=> r.has(sec)).map(r=> r.set("selected", num))

    x.addAll(out.spsort)
  end
  else []
end


def ​

func:finBatchCloneScheduleApply ​

finBatchCloneScheduleApply(id, events, filter) ​

Axon function


meta ​

deffunc:finBatchCloneScheduleApply
isfunc
liblib:finTools
namefinBatchCloneScheduleApply
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, events, filter)=> do
  rec :id.toRec
  kind:rec->kind
  targets:eval(filter).findAll(r=> r->kind==kind and r->id != rec["id"])

  targets.each(t=>do
    if(t.get("scheduleGrid").isEmpty or t.get("scheduleGrid")==null) do
      change:{
        "scheduleGrid": {
          "start": 00:00:00,
          "end": 00:00:00,
          "weekdays":"sun,mon,tue,wed,thu,fri,sat",
          val: null,
          defaultEvent: marker()
        }
      }

      commit(diff(t,change))
    end
  end)

  srcEvents: readById(id)->scheduleGrid
  newEvents:[]
  events.each e=> do
    if(e != "mon" and e != "tue" and e != "wed" and e != "thu" and e != "fri" and e != "sat" and e != "sun" and newEvents.find(nr => e == nr->dis) == null)
      newEvents = newEvents.add({dis:e,week:""})
    else do
      matches:srcEvents.findAll(se=> se.has("weekly") and se.has("weekdays") and se->weekdays.contains(e))
      matches.each(m=> do
        if(newEvents.find(nr=>(m->dis)== nr->dis and m->weekdays == nr->dis)==null)
          newEvents = newEvents.add({dis:m->dis,week:m->weekdays})
      end)

    end
  end

  // fetch the new ros
  newRows: []
  srcEvents.each nr => do
    if (nr.has("dis") and newEvents.find(e => e->dis == nr->dis and (nr.has("weekly")==false or (e->week== nr->weekdays)) ) != null) do
      newRows = newRows.add(remove(nr, "usedBy"))
    end
  end

  // function for figuring out if we want to keep a given row
  keepRow: (r) => do
      if (r.has("weekly")) return true
      if (r.has("defaultEvent")) return true
      if (not r.has("dis")) return true

      ok: true
      newRows.each nr => do
        if(nr.has("weekly") and r.has("weekly") and (nr->dis==r->dis and nr->weekdays==r->weekdays))
          ok = false
        else if (nr->dis == r->dis)
          ok = false
      end

      return ok
  end

  // look up each target
  targets.each t =>
  do
      oldRec: readById(t->id)

      if(oldRec["scheduleGrid"] == null or oldRec["scheduleGrid"].isEmpty)
        throw toLocale("j2FinToolsExt::invalidTargetSchedule") + " " + toLocale("j2FinToolsExt::mustDefineTagSchedule")

      // fish out the old rows
      oldGrid: oldRec["scheduleGrid"]

      // construct new grid
      ls: []
      found: false

      oldGrid.each r => do
          // insert the new rows just before the first "weekly" row
          if ((r.has("weekly") and not found) or r.has("defaultEvent")) do
              found = true
              newRows.each nr => do
                if(ls.find(mr=>if(nr.has("weekly") and mr.has("weekly")) (mr->dis == nr->dis and (nr->weekdays==mr->weekdays)) else (mr->dis == nr->dis) ) == null)
                  ls = ls.add(nr)
              end
          end

          // keep the row if we should
          if (keepRow(r) and (ls.find(mr=>if(mr.has("weekly") and r.has("weekly")) (mr->dis == r.dis() and mr->weekdays==r->weekdays) else (mr->dis==r.dis())) == null)) do
            ls = ls.add(r)
          end
      end

      // done
      newGrid: toGrid(ls)
      newRec: oldRec.set("scheduleGrid", newGrid)
      newRec2:{}

      newRec.each((val,k)=> do
        if(val == null)
        do
          if(k == "curVal")
          do
            if(newRec->kind == "Bool")
              newRec = newRec.set(k,false)
            else if(newRec->kind == "Number")
              newRec = newRec.set(k,0)
            else if(newRec->kind == "Str")
            do
              if(newRec.has("enum") and newRec->enum != "")
              do
                newRec = newRec.set(k,newRec->enum.split(",")[0])
              end
              else newRec = newRec.set(k,"")
            end
          end

          else
          do
            if(rec.has(k) and rec.get(k) != null)
              newRec = newRec.set(k ,rec.get(k))
          end
        end

        if(newRec.get(k) != null and not finIsTagBlackList(k) and reFind("^next*", k) == null)
          newRec2 = newRec2.set(k,newRec.get(k))
      end)

      commit(diff(oldRec, newRec2))
  end
end


def ​

func:finBatchDeleteEventsForm ​

finBatchDeleteEventsForm(id: null, data: null, stage: null) ​

Axon function


meta ​

deffunc:finBatchDeleteEventsForm
distoLocale("j2FinToolsExt::deleteEvents")
formOnschedule
isfunc
liblib:finTools
namefinBatchDeleteEventsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id: null, data: null, stage: null) => do
  if(stage == null) do
    id = id.toRec

    body: [
      {
        name: "events",
        editorType: "list",
        prompt: toLocale("j2FinToolsExt::deleteSelectedEvents").replace("{name}", id.dis),
        listType: "checkbox",
        dataProvider: "readById(@"+id->id+")->scheduleGrid.finGridFilter(dis).map(x=> x.set(\"dis\",x->dis.finBatchDeleteEventsForm(null,2)))",
        labelField: "dis",
        selectedValueTags: "dis",
        height: 175
      },

      {
        name: "scheds",
        editorType: "list",
        prompt: toLocale("j2FinToolsExt::deleteEventsFromSelectedSchedule"),
        listType: "checkbox",
        dataProvider: "readAll(schedule and id!=@"+id->id+").findAll(x=> x->scheduleGrid.finGridFilter(dis).findAll(y=> index(\$events,finBatchDeleteEventsForm(y->dis,null,2))!=null).size > 0)",
        labelField: "dis",
        selectedValueTags: "id",
        height: 175
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {
      "dis": toLocale("j2FinToolsExt::deleteEvents"),
      "name": "finBatchDeleteEventsForm",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "finBatchDeleteEventsForm(@"+id->id+",[\$events,\$scheds],1)",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(stage == 1)
  do
    toAscii: g=> g.finBatchDeleteEventsForm(null,2)
    data = data.set(1,data[1].add(id))
    tmp: []

    data[1].each x=> do
      tmp = x.readById->scheduleGrid
      tmp = tmp.findAll(y=> not y.has("dis") or data[0].index(y->dis.toAscii) == null)
      x.readById.diff({scheduleGrid: tmp.toGrid}).commit
    end
  end else if(stage == 2) do
    (0..id.size - 1).map(h=> id[h..h]).findAll(h=> h[0] < 256 and h[0] >= 32).concat("")
  end
end


def ​

func:finBatchDeletePointsForm ​

finBatchDeletePointsForm(selectedDicts: null, stage: null) ​

Form to delete points based on navName and equipRef


meta ​

deffunc:finBatchDeletePointsForm
distoLocale("j2FinToolsExt::batchDeletePoints")
formOnsite or floor or equip or (point and not schedule)
isfunc
liblib:finTools
namefinBatchDeletePointsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(selectedDicts: null, stage: null) => do
  t: (g)=> g.toAxonCode

  if(stage == null)
  do
    if (selectedDicts != null)
      selectedDicts = selectedDicts.toRecList
    else
      selectedDicts = []

    ids: []
    sd: []
    nm: ""

    selectedDicts.each x =>
    do
      nm = x.finNavMetaWhoAmI
      if(nm == "point")
      do
        ids = ids.add(x->equipRef)
        sd = sd.add(x->id)
      end
      else if(nm == "equip")
        ids = ids.add(x->id)
      else
        ids = ids.addAll(readAll(parseFilter(nm+"Ref == @"+x->id) and equip).toRecIdList)
    end

    dval: if (ids.size > 0) "id==@"+ids.unique.concat(" or id==@") else ""

    if(sd.size == 0)
    do
      sd = readAll(point and equipRef and navName)
      tmp: if (not dval.isEmpty) readAll(parseFilter(dval) and equip).colToList("id") else readAll(equip).colToList("id")
      sd = sd.findAll(x=> tmp.index(x->equipRef) != null)
      sd = sd.unique("navName").sort("navName").toRecIdList
    end

    body: [
      {name: "efilt", editorType: "filter", prompt: toLocale("j2FinToolsExt::equipFilter"), defVal: dval},
      {
        name: "plist",
        editorType: "list",
        prompt: toLocale("j2FinToolsExt::uniqueNavNames"),
        listType: "checkbox",
        labelField: "navName",
        selectedValueTags: "navName",
        dataProvider: "try (if(\$efilt.isEmpty or \$efilt=="+dval.t+") "+sd.t+".toRecList else "+
          "readAll(point and equipRef and navName).findAll(x=> readAll((parseFilter(\$efilt)) and equip).colToList(\"id\").index(x->equipRef) != null)"+
          ").unique(\"navName\").toGrid.sort(\"navName\") catch []"
      },
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {
      "dis": toLocale("j2FinToolsExt::batchDeletePoints"),
      "name": "finBatchDeletePointsForm",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "finBatchDeletePointsForm([\$efilt, \$plist], 1)",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 1)
  do
    filter: readAll(parseFilter(selectedDicts[0]) and equip)
    navnames: selectedDicts[1]
    branchesToRefresh: []
    jsRefresh: ""

    body: [
      {name: "label", editorType: "label", text: toLocale("finStackExt::pointsStateWarning")},
      {name: "label", editorType: "label", text: toLocale("finStackExt::folioFilesDeleteMsg").replace("{0}", ":")},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::no"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::yes"), controlBar: true}
    ]

    num: 0
    navnames.each x =>
    do
      num = 0

      filter.each y =>
      do
        branchesToRefresh = branchesToRefresh.add(y->id)
        num = num + readCount(point and equipRef==y->id and navName==x)
      end

      body = body.add({
        name: "label",
        editorType: "label",
        text: "        "+ toLocale("j2FinToolsExt::numPointsWithNavName").replace("{num}", num.toStr).replace("{name}", x.toStr)
      })
    end

    //construct tree resfresh srt
    branchesToRefresh.unique().each branch =>
    do
      jsRefresh = jsRefresh + "window.app.RefreshBuilderTreeNodeForId('"+branch.toAxonCode+"'); "
    end

    //body = body.add({name: "label", editorType: "label", text: "\nAre you sure you want to continue?"})

    {
      "dis": toLocale("finStackExt::confirm"),
      "name": "finBatchDeletePointsFormStage2",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "each("+navnames.t+", y=> readAll(point and equipRef and navName).findAll(x=> "+
        "readAll(("+selectedDicts[0]+") and equip).colToList(\"id\").index(x->equipRef) != null).finGridFilter(navName==y).finSoftDelete)",
      "completeAction": "try { " + jsRefresh +" } catch { return 0; }",
      "refreshTrees": marker(),
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finBatchDeleteTagProvider ​

finBatchDeleteTagProvider(filter) ​

Axon function


meta ​

deffunc:finBatchDeleteTagProvider
isfunc
liblib:finTools
namefinBatchDeleteTagProvider

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter) => do
    readAllTagNames(parseFilter(filter)).findAll(r =>
        not finIsTagBlackList(r->name))
end


def ​

func:finBatchDeleteTagsApply ​

finBatchDeleteTagsApply(filter, tags) ​

Axon function


meta ​

deffunc:finBatchDeleteTagsApply
isfunc
liblib:finTools
namefinBatchDeleteTagsApply

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter,tags) => do

  //echo("finBatchDeleteTagsApply: " + filter)

  tagDict: eval(concat(["{", tags.map(val => "-" + val).concat(","), "}"]))

  recs: readAll(parseFilter(filter)).findAll(rec => tags.any(v => rec.has(v)))
  recs.each r => commit(diff(r, tagDict))

  if (recs.size == 1)
      finFormAlertOk(toLocale("j2FinToolsExt::batchDeleteTags"), toLocale("j2FinToolsExt::recWasMod"))
  else
      finFormAlertOk(toLocale("j2FinToolsExt::batchDeleteTags"), toLocale("j2FinToolsExt::recWasModMulit").replace("{num}", recs.size.toStr))
end


def ​

func:finBatchDeleteTagsForm ​

finBatchDeleteTagsForm(id: null, selectedDicts: null) ​

Axon function


meta ​

appFormOnfolio,builder
deffunc:finBatchDeleteTagsForm
distoLocale("j2FinToolsExt::batchDeleteTags")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
formOnfoo
isfunc
liblib:finTools
namefinBatchDeleteTagsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id: null, selectedDicts: null) => do
  js: [
    "function checkJobStatus(jobHandle) {",
      "var promise;",
      "if (jobHandle === undefined) {",
        "promise = finstack.evalAll(['jobStatusAll().find(v => v->dis.startsWith(\"finBatchDeleteTagsApply\") and v->started > "+now().toAxonCode+")']);",
      "} else {",
        "promise = finstack.evalAll(['jobStatusAll(\"'+jobHandle+'\")[0]']);",
      "}",
      "promise.then(function(event) {",
        "var jobStat = event.result[0].toObj(false, false, true);",
        "var isDone = jobStat['jobStatus'].startsWith('done');",
        "if (isDone) {",
          "window.top.app.HideLoader();",
        "} else {",
          //"var msg;",
          //"if (jobStat != null && jobStat != undefined) { msg = window.languageManager['loaderLoading'] + jobStat['progress'] + '%'; }",
          //"else { msg = window.languageManager['loaderLoading'] + '0%'; }",
          "window.top.app.HideLoader();",
          "window.top.app.ShowLoader(languageManager['deletingTagsMsg']);",
          "setTimeout(function(){ checkJobStatus(jobStat['handle']); }, 2000);",
        "}",
      "});",
    "}",
    "window.top.app.ShowLoader(languageManager['deletingTagsMsg']);",
    "checkJobStatus();"
  ]

  if (selectedDicts == null or selectedDicts.size < 2)
  do
    body: [
      {
        name: "filter",
        editorType: "filter",
        prompt:toLocale("finStackExt::finFilter"),
        //toolTip: "A filter for the objects"
      },

      {
        name: "tags",
        editorType: "list",
        listType: "checkbox",
        prompt: toLocale("j2FinToolsExt::selectTagsToDelete"),
        height: 175,
        dataProvider: "try finBatchDeleteTagProvider(\$filter) catch []",
        labelField: "name",
        selectedValueTags: "name",
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
    ]

    {
      "dis": toLocale("j2FinToolsExt::batchDeleteTags"),
      "name": "foo",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "jobRun(finBatchDeleteTagsApply(\$filter,\$tags))",
      "completeAction": js.concat("\n"),
      //"confirm": "You are about to batch delete tags for recs matching the filter \$filter. Are you sure?",
      "helpDoc":"/wiki/display/FINStack/Batch+Delete+Tags",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else
  do
    selFilter: "\"" + selectedDicts.map() (row => "(id == @" + row->id.toStr + ")").concat(" or ") + "\""
    selDis: "[" + selectedDicts.map() (row => "\"" + row.dis + "\"").concat(",") + "]"

    body: [
      {
        name: "selectedItems",
        editorType: "list",
        prompt: toLocale("finStackExt::selectItems"),
        dataProvider: selDis,
        labelField: "val",
        height: 100,
        selectedValueTags: "val"
      },

      {
        name: "tags",
        editorType: "list",
        listType: "checkbox",
        prompt: toLocale("j2FinTools::uniqueTags"),
        height: 175,
        dataProvider: "try finBatchDeleteTagProvider(" + selFilter + ") catch []",
        labelField: "name",
        selectedValueTags: "name",
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
    ]

    {
      "dis": toLocale("j2FinToolsExt::batchDeleteTags"),
      "name": "foo",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "jobRun(finBatchDeleteTagsApply(" + selFilter + ",\$tags))",
      "completeAction": js.concat("\n"),
      //"confirm": "You are about to batch delete tags for recs matching the filter \$filter. Are you sure?",
      "helpDoc":"/wiki/display/FINStack/Batch+Delete+Tags",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finBatchRecordCreator ​

finBatchRecordCreator(parentRec, recordType, objectNames, src) ​


meta ​

deffunc:finBatchRecordCreator
isfunc
liblib:finTools
namefinBatchRecordCreator

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finBatchRecordList ​

finBatchRecordList(recordType, src) ​


meta ​

deffunc:finBatchRecordList
isfunc
liblib:finTools
namefinBatchRecordList

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finBatchRecordsEquipFilter ​

finBatchRecordsEquipFilter(type, equipFilter) ​

Axon function


meta ​

deffunc:finBatchRecordsEquipFilter
isfunc
liblib:finTools
namefinBatchRecordsEquipFilter

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(type, equipFilter)=>do
  equipFilter = equipFilter.trim
  if(equipFilter == null or equipFilter == "") return readAll(parseFilter(type),false)

  recs:null
  try recs= readAll(parseFilter(equipFilter,false),false) catch(er) recs = null
  if(recs != null and recs.size > 0 ) do
    r:recs[0]
    if(r.has("site")) do
      recs = readAll(parseFilter("equip and (" + recs.toRecList.map(s=>"siteRef==@"+s->id.toStr).concat(" or ") + ")"),false)
    end
    if(r.has("floor")) do
      recs = readAll(parseFilter("equip and (" + recs.toRecList.map(f=>"floorRef==@"+f->id.toStr).concat(" or ") + ")"),false)
    end

    if(r.has("equip")) do
      if(type == "equip")
        return recs
      else if(type == "point") do
        if(r.has("point"))
          return recs
        else do
          eqRefs : recs.toRecList.map(eq=>"equipRef==@"+eq->id.toStr)
          return readAll(parseFilter(type + " and (" + eqRefs.concat(" or ") + ")"))
        end
      end
    end

    if(r.has("point")) do
      if(type == "point")
        return recs
      else if(type == "equip") do
        eqRefs : recs.toRecList.map(eq=>"id==@"+eq->equipRef.toStr)
        return readAll(parseFilter(type + " and (" + eqRefs.concat(" or ") + ")"))
      end
    end
  end
  [].toGrid()
end


def ​

func:finBatchRecordsFilter ​

finBatchRecordsFilter(type, filter, src) ​


meta ​

deffunc:finBatchRecordsFilter
isfunc
liblib:finTools
namefinBatchRecordsFilter

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finBatchUpdateRecords ​

finBatchUpdateRecords(dicts, keepName, keepMarkers, type, src: null, keepHis: true) ​

Axon function


meta ​

deffunc:finBatchUpdateRecords
disUpdate records from library
isfunc
liblib:finTools
namefinBatchUpdateRecords

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(dicts,keepName,keepMarkers,type,src:null, keepHis:true)=> do

  //logInfo("finTools","keepHis:"+keepHis)
  //echo("finBatchUpdateRecords:" + dicts + ", keepName:"+keepName + ", keepMarkers:"+keepMarkers)
  ids:[]
  dicts.each(dict=> do
    dict.each((lpoint,mpoint)=> do
      id:lpoint.replace("@","")
      if(ids.index(id) == null)
        ids = ids.add(id)
    end)
  end)

  libPoints: finBatchRecordList(type,src).findAll(p=> ids.index(p->id.toStr) != null)

  cmds:["cmd","sp","sensor"]
  equip_essentials:["equip",  "elec", "gas", "water", "steam" ]
  point_essentials:["point", "sensor", "cmd", "sp", "his", "enum"]
  essential_markers:equip_essentials.addAll(point_essentials)

  //update records
  if(libPoints != null and libPoints.size > 0) do
    dicts.each(dict=> do
      dict.each((lp,mp) => do
        //library rec
        lPoint:libPoints.find(p=>p->id.toStr == lp.replace("@",""))
        ignored:finUpdateRecordsIgnoredTags2(lPoint)

        finBatchUpdateRecsCommit(lPoint,"id==@" + mp.replace("@",""),keepName, keepMarkers, keepHis, essential_markers, ignored, cmds)
      end)
    end)
  end
end


def ​

func:finBatchUpdateRecordsFilter ​

finBatchUpdateRecordsFilter(dicts, keepName, keepMarkers, type, filter, src: null, keepHis: true) ​

Axon function


meta ​

deffunc:finBatchUpdateRecordsFilter
disUpdate Recrods From Library with Filter
isfunc
liblib:finTools
namefinBatchUpdateRecordsFilter

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(dicts,keepName,keepMarkers,type,filter, src:null, keepHis:true)=>do

  ids:[]
  dicts.each(dict=> do
    dict.each((lpoint,mpoint)=> do
      id:lpoint.replace("@","")
      if(ids.index(id) == null)
        ids = ids.add(id)
    end)
  end)
  filter = filter.trim
  libPoints: finBatchRecordsFilter(type,"",src).findAll(p=> ids.index(p->id.toStr) != null)

  cmds:["cmd","sp","sensor"]
  equip_essentials:["equip",  "elec", "gas", "water", "steam" ]
  point_essentials:["point", "sensor", "cmd", "sp", "his",  "enum"]
  essential_markers:equip_essentials.addAll(point_essentials)
  //echo("finBatchUpdateRecordsFilter "+filter)
  recs: readAll(parseFilter(filter))
  if(recs.size > 0 ) do
    r: recs[0]

    if(r.has("site")) do
      recs = readAll(parseFilter("equip and (" + recs.toRecList.map(s=>"siteRef==@"+s->id.toStr).concat(" or ") + ")"),false)
    end
    if(r.has("floor")) do
      recs = readAll(parseFilter("equip and (" + recs.toRecList.map(f=>"floorRef==@"+f->id.toStr).concat(" or ") + ")"),false)
    end
    pointfilter:""
    if(r.has("equip")) do
      if(type== "equip")
        pointfilter = recs.toRecList.map(eq=>"id==@"+eq->id.toStr).concat(" or ")
      else if(type == "point")
        pointfilter = type + " and ("+ recs.toRecList.map(eq=>"equipRef==@"+eq->id.toStr).concat(" or ") +")"
    end
    if(r.has("point")) do
      if(type== "equip")
        pointfilter = recs.toRecList.map(eq=>"id==@"+eq->equipRef.toStr).concat(" or ")
      else if(type == "point")
        pointfilter = "("+ recs.toRecList.map(eq=>"id==@"+eq->id.toStr).concat(" or ") +")"
    end

    //logInfo("finTools","finBatchUpdateRecordsFilter " + pointfilter + "|| "+ libPoints.size + " dicts:"+dicts)
    if(libPoints != null and libPoints.size > 0) do
      dicts.each(dict=> do
        dict.each((lp,mp) => do
          //library rec
          lPoint:libPoints.find(p=>p->id.toStr == lp.replace("@",""))
          ignored: finUpdateRecordsIgnoredTags2(lPoint)

          mPoint:read(parseFilter("id=="+mp))
          effectedFilter : pointfilter + " and (navName==\"" + mPoint->navName + "\""
          if(mPoint.has("kind"))
            effectedFilter = effectedFilter + " and kind==\"" + mPoint->kind +"\")"
          else
            effectedFilter = effectedFilter + ")"
          finBatchUpdateRecsCommit(lPoint,effectedFilter,keepName, keepMarkers, keepHis, essential_markers, ignored, cmds)
        end)
      end)
    end
  end
end


def ​

func:finBatchUpdateRecsCommit ​

finBatchUpdateRecsCommit(libRec, filter, keepName, keepMarkers, keepHis, essential_markers, ignored, cmds) ​

Axon function


meta ​

deffunc:finBatchUpdateRecsCommit
isfunc
liblib:finTools
namefinBatchUpdateRecsCommit
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(libRec,filter,keepName, keepMarkers, keepHis, essential_markers, ignored, cmds)=>do
  //device rec
  mPoints:readAll(parseFilter(filter)) //,false
  //library rec
  lPoint:libRec
  connTags:ignoredConnTags(lPoint)
  hisTags: getHisTags()
  //logInfo("finTools","filter:"+filter + "| db points :" + mPoints.toRecList.toStr + "| libPoint:"+ lPoint.toStr)
  if(mPoints != null) do
    mPoints.each( mPoint => do
      if(mPoint != null and lPoint != null) do
        changes:{}
        removeChanges:{}
        transientChanges: readByIdTransientTags(mPoint->id)
        if(not keepHis) do
          mPoint.each((val,prop)=> do
            isHis: hisTags.find(t=>t==prop) != null
            if(isHis)
              removeChanges = removeChanges.set(prop, removeMarker())
          end)

        end

        if(keepMarkers == false) do
          mPoint.each((val,prop)=> do
            notIgnoredTag: (ignored.find(t=>t==prop) == null) and (connTags.find(t=> t == prop) == null)

            if(val == marker() and notIgnoredTag) do
              essTag:essential_markers.find(t=>t== prop)

              if(essTag == null and lPoint.get(prop)== null)
                changes = changes.set(prop,removeMarker())
            end
          end)

        end

        lPoint.each((val,prop)=> do
          nVal:val
          if((nVal != null and changes.get(prop) != removeMarker()) or prop=="haystackPoint")  do
            notIgnoredTag: (ignored.find(t=>t==prop) == null) and (connTags.find(t=> t == prop) == null)

            if(prop == "unit") do
              if(mPoint.missing("unit") or mPoint.get("unit") == null or mPoint.get("unit") == "")
                changes = changes.set("unit",nVal)
            end
            else if(prop == "navName" or prop == "dis") do
              if(keepName==false)
                changes = changes.set(prop,nVal)
            end
            else if(prop == "haystackPoint") do
              changes = changes.set(prop,marker())
            end
            else if(notIgnoredTag) do
              if(mPoint.has("point")) do
                if( cmds.index(prop) != null) do
                  isCmd:cmds.find( c=>mPoint.has(c)) != null
                  if(not isCmd)
                    changes = changes.set(prop,nVal)
                  else do
                    removeCmds: cmds.findAll(c=> mPoint.has(c) and c != prop)
                    changes = changes.set(prop,nVal)
                    removeCmds.each(c=> changes = changes.set(c,removeMarker()))

                  end
                end
                else
                  changes = changes.set(prop,nVal)
              end
              else
                changes = changes.set(prop,nVal)
            end
          end
        end)

        if(lPoint.has("writable")) do
          changes = changes.set("writable",marker())
        end
        else do
          if(mPoint.has("writable"))
            changes = changes.set("writable",removeMarker())
        end

        //logInfo("finTools","before changes:"+changes)
        if(not removeChanges.isEmpty) do
          logInfo("finTools","removeChanges: "+removeChanges)
          removeChanges.each((val, prop) => do
            if(not transientChanges.has(prop))
              changes = changes.set(prop, val)
          end)
        end
        //logInfo("finTools","before keepHis:"+changes)
        if(keepHis) do
          hisTags.each(t => do
            if(changes.has(t))
              changes = remove(changes,t)
          end)

        end

        changes = changes.set("haystackPoint", removeMarker())

        //logInfo("finTools","after changes:"+changes)
        diff(mPoint, changes).commit
      end
    end)
  end
end


def ​

func:finCertManagementForm ​

finCertManagementForm(data: null) ​

Axon function


meta ​

appFormOnconnectors
deffunc:finCertManagementForm
distoLocale("j2FinToolsExt::addConnCert")
isfunc
liblib:finTools
namefinCertManagementForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(data: null) => do
  if(data == null) do
    body: [
      {
        name: "conn",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::finFormHTTPSConnector"),
        labelField: "dis",
        selectedValueTags: "id",
        defIndex: 0,
        dataProvider: "readAll(bacnetConn).addRows(readAll(haystackConn)).finGridFilter(uri).findAll(x=> x->uri.toStr.startsWith(\"https\")).sort(\"dis\")"
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {
      "dis": toLocale("j2FinToolsExt::finFormCertManHeader"),
      "name": "finCertManagementForm",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "finCertManagementForm(\$conn)",
      "helpDoc": "/wiki/display/FINStack/Adding+HTTPS+Connector+Certificate",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  ///////
  else do
    ioDelete(`io/cacerts`)
    url: readById(data)->uri.toStr.replace("//",toChar(8)).split("/")[0].replace(toChar(8),"//")
    try do
      asdf: certAddForUri(url.parseUri)
      ioMove(`io/jssecacerts`,`io/cacerts`)
      body: [
        {name: "label", editorType: "label", text: toLocale("finBacnetExt::finAddedCert")+" "+url},
        {name: "label", editorType: "label", prompt: toLocale("finStackExt::instructions"), text: toLocale("j2FinToolsExt::finCertFromOne").replace("{name}", asdf[1]->val.replace("\\","/"))},
        {
          name: "label",
          editorType: "label",
          text: replace(toLocale("j2FinToolsExt::finOverwriteTwo")+" "+asdf[1]->val+"/cacerts with "+replace(asdf[0]->val,"jssecacerts","cacerts"),"\\","/")
        },

        {name: "label", editorType: "label", text: toLocale("finBacnetExt::finCertFormThree")},
        {name: "label", editorType: "label", text: toLocale("finBacnetExt::finCertFormRestart")},
        {name: "label", editorType: "label", text: toLocale("finBacnetExt::finCertFormMultWarning")},

        {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::done"), controlBar: true}
      ]
    end catch
      body: [
        {name: "label", editorType: "label", prompt: toLocale("finStackExt::regError"), text:toLocale("j2FinToolsExt::couldNotGetCert").replace("{fileLocation}",url)},
        {name: "label", editorType: "label", text: toLocale("finBacnetExt::finCertFormErrorPrompt")},
        {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::done"), controlBar: true}
      ]

    {"dis": toLocale("finBacnetExt::finCertFormManHeader"),
      "name": "finCertManagementForm",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "helpDoc": "/wiki/display/FINStack/Adding+HTTPS+Connector+Certificate",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finChildBooleanData ​

finChildBooleanData(parentFilter, childFilter) ​

finChildBooleanData(parentFilter, childFilter)

This function will return a grid where each row lists the parent, the children currently on, the number of children currently off, and the total count of all matching children.

parentFilter should be a string query to identify parents childFilter should be a string query to identify children

Children with no curVal, not of type Boolean, and with curStatus not "ok" are ignored.

EX: finChildNumberData("site and foo", "cool")


meta ​

childData✓
constructfinChildBooleanData("site", "air")
deffunc:finChildBooleanData
isfunc
liblib:finTools
namefinChildBooleanData

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(parentFilter, childFilter) => do
  parents: readAll(parseFilter(parentFilter))
  parentKind: ""
  parentRefTag: ""
  children: null
  on: 0
  off: 0
  total: 0
  results: []
  navLevels: read(navMeta)->equipPath.split("/")[1..-1]

  if(parents.size > 0) do
    parents.each parent => do

      navLevels.each navLevel => do
        if(parent.has(navLevel)) do
          parentKind = navLevel
          parentRefTag = parentKind + "Ref"
        end //end if level found
      end //end navLevels loop

      children = readAll(parseFilter(childFilter + " and " + parentRefTag + "==" + parent->id + " and curStatus == \"ok\" and cur and kind == \"Bool\""))

      if(children.size > 0) do
        children.each child => do
          total = total + 1
          if(child->curVal == true)
            on = on + 1
          else if(child->curVal == false)
            off = off + 1
        end//end children loop
      end//end if there are children

      results = results.add({id: parent->id, onCount: on, offCount: off, totalCount: total})
      on = 0
      off = 0
      total = 0
    end //end parent loop
  end //end if there are parents
  return results
end //end func


def ​

func:finChildNumberData ​

finChildNumberData(parentFilter, childFilter) ​

finChildNumberData(parentFilter, childFilter)

This function will return a grid where each row lists the parent, the average of all children values, maximum value among the children, the smallest value among the children, and the total of all the children values.

parentFilter should be a string query to identify parents childFilter should be a string query to identify children

Children with no curVal, not of type Numeric, and with curStatus not "ok" are ignored.

EX: finChildNumberData("site and foo", "zone and temp and sensor")

If children have mismatching values, for example temperature and percentage, an error will be returned.


meta ​

childData✓
constructfinChildNumberData("site", "zone and temp and sensor")
deffunc:finChildNumberData
isfunc
liblib:finTools
namefinChildNumberData

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(parentFilter, childFilter) => do
  parents: readAll(parseFilter(parentFilter))
  parentKind: ""
  parentRefTag: ""
  children: null
  units:""
  max: 0
  min: 0
  avg: 0
  sum: 0
  results: []
  navLevels: read(navMeta)->equipPath.split("/")[1..-1]

  if(parents.size > 0) do
    parents.each parent => do

      navLevels.each navLevel => do
        if(parent.has(navLevel)) do
          parentKind = navLevel
          parentRefTag = parentKind + "Ref"
        end //end if level found
      end //end navLevels loop

      children = readAll(parseFilter(childFilter + " and " + parentRefTag + "==" + parent->id + " and curStatus == \"ok\" and cur and kind == \"Number\""))

      if(children.size > 0) do
        min = children[0]->curVal
        units = children[0]->unit
        try do
          children.each child => do
            sum = sum + child->curVal
            if(child->curVal > max)
              max = child->curVal
            if(child->curVal < min)
              min = child->curVal
          end//end children loop
          avg = sum / children.size
        end catch throw toLocale("j2FinToolsExt::mismatchUnitTypeErr")
      end//end if there are children

      results = results.add({id: parent->id, avg: avg, max: max, min: min, sum: sum})
      avg = 0
      max = 0
      sum = 0
      min = 0
    end //end parent loop

  end //end if there are parents
  return results
end //end func


def ​

func:finCloneEquipPointTags ​

finCloneEquipPointTags(selectedDicts) ​

Form to clone the tags from the points of one equip to the corresponding points of other selected equips.


meta ​

deffunc:finCloneEquipPointTags
distoLocale("j2FinToolsExt::cloneEquipPointTags")
folderPathtoLocale("j2FinToolsExt::batchEditAndClone")
formOnequip
isfunc
liblib:finTools
namefinCloneEquipPointTags

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(selectedDicts) => do
  if(selectedDicts.isList) do
    selectedDicts = selectedDicts.toGrid.colToList("id")

    body:[
      {name: "site", editorType: "combobox", prompt: toLocale("j2FinToolsExt::site"), dataProvider: "readAll(site).sort(\"dis\")", labelField: "dis", selectedValueTags: "id", defIndex: 0},

      {
        name: "equip",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::equipToClonePtTagsFrom") + ":",
        dataProvider: "try readAll(equip and siteRef==\$site).sort(\"navName\") catch []",
        labelField: "dis",
        selectedValueTags: "id",
        defIndex: 0
      },

      {name: "filter", editorType: "filter", prompt: toLocale("j2FinToolsExt::equipFilter")+":", defVal: "id==@"+ selectedDicts.concat(" or id==@")},

      {
        name: "list",
        editorType: "list",
        prompt: toLocale("j2FinToolsExt::equipsToClonePtTagsTo"),
        dataProvider: "try readAll(parseFilter(\$filter) and equip).map(x=> x.set(\"selected\",true)) catch []",
        listType: "checkbox",
        labelField: "dis",
        selectedValueTags: "id",
        defValTagName: "selected"
      },

      {name: "chkbx", editorType: "checkbox", label: toLocale("j2FinToolsExt::equipsToClonePtTagsTo"), defVal: false},

      {
        name: "props",
        editorType: "list",
        prompt: toLocale("j2FinToolsExt::selectPropertiesToClone")+":",
        listType: "checkbox",
        labelField: "prop",
        selectedValueTags: "prop",
        defValTagName: "sel",
        dataProvider: "try readAll(parseFilter(\"point and equipRef==\$equip\")).map(x=> x.stripUncommittable.findAll((a,b)=> x.has(b) and x.trap(b) != marker()))"+
                      ".removeCols([\"mod\",\"id\",\"siteRef\",\"floorRef\",\"equipRef\"]).colNames.sort.map(x=> {prop: x, sel: \$chkbx}) catch []"
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {
      "dis": toLocale("j2FinToolsExt::cloneEquipPointTags"),
      "name": "finCloneEquipPointTags",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "finCloneEquipPointTags({equip: \$equip, list: \$list, props: \$props})",
      "helpDoc": "/wiki/pages/viewpage.action?pageId=63963161",
      "finForm": marker(),
    }.toGrid.addMeta({formExecute: marker()})
  end
  ////////////////////////////////
  else if(selectedDicts.isDict) do
    equip: selectedDicts->equip
    list: selectedDicts->list
    props: selectedDicts->props
    points: readAll(point and equipRef==equip)
    tmp: {}
    tags: {}
    list.each x=> do
      readAll(point and equipRef==x).each y=> do
        tmp = points.find(z=> y->navName == z->navName)
        if(tmp != null) do
          tags = {-sp, -sensor, -cmd}
          tmp.findAll((a,b)=> tmp.has(b) and (tmp.trap(b) == marker() or props.index(b) != null)).each((c,d)=> tags = tags.set(d,c))
          y.diff(tags).commit
        end
      end
    end
  end
end


def ​

func:finCloneEventsApply ​

finCloneEventsApply(sourceId, events, targets) ​

Axon function


meta ​

deffunc:finCloneEventsApply
isfunc
liblib:finTools
namefinCloneEventsApply

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(sourceId, events, targets) => do

    // fetch the new ros
    newRows: []
    readById(sourceId)->scheduleGrid.each nr => do
        if (nr.has("dis") and events.find(e => e == nr->dis) != null) do
            newRows = newRows.add(remove(nr, "usedBy"))
        end
    end

    targets.each(t=>do
      r:readById(t)
      if(r.get("scheduleGrid").isEmpty or r.get("scheduleGrid")==null) do
        change:{
          "scheduleGrid": {
            "start": 00:00:00,
            "end": 00:00:00,
            "weekdays":"sun,mon,tue,wed,thu,fri,sat",
            val: null,
            defaultEvent: marker()
          }
        }
        commit(diff(r,change))
      end
    end)
    // function for figuring out if we want to keep a given row
    keepRow: (r) => do
        if (r.has("weekly")) return true
        if (r.has("defaultEvent")) return true
        if (not r.has("dis")) return true

        ok: true
        newRows.each nr => do
          if(nr.has("weekly") and r.has("weekly") and (nr->dis==r->dis and nr->weekdays==r->weekdays))
            ok = false
          else if (nr->dis == r->dis)
            ok = false
        end

        return ok
    end

    // look up each target
    targets.each id => do
        oldRec: readById(id)

        // fish out the old rows
        oldGrid: oldRec["scheduleGrid"]

        // construct new grid
        ls: []
        found: false
        oldGrid.each r => do
            // insert the new rows just before the first "weekly" row
            if (r.has("weekly") and not found) do
                found = true
                newRows.each nr => do
                    ls = ls.add(nr)
                end
            end

            // keep the row if we should
            if (keepRow(r))
                ls = ls.add(r)
        end

        // done
        newGrid: toGrid(ls)
        newRec: oldRec.set("scheduleGrid", newGrid)
        transients: {}
        okTags: ["point","cur","his","hisFunc"]
        newRec.names.each x=> do
          if(x.finIsTagBlackList and not okTags.contains(x)) do
            transients = transients.set(x, newRec[x])
            newRec = newRec.remove(x)
          end
        end
        transients = transients.remove("id").remove("mod")
        commit(diff(oldRec, newRec))
        oldRec->id.readById.diff(transients, {transient}).commit
    end
end


def ​

func:finCloneEventsForm ​

finCloneEventsForm(id) ​

Axon function


meta ​

deffunc:finCloneEventsForm
distoLocale("j2FinToolsExt::cloneEvents")
formOnschedule
isfunc
liblib:finTools
namefinCloneEventsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do

  kind: readById(id)->kind

  body: [
    {
      name: "events",
      editorType: "list",
      listType: "checkbox",
      prompt: toLocale("j2FinToolsExt::cloneSelectedEventsFrom").replace("{name}", readById(id).dis),
      height: 175,
      dataProvider: "finReadCloneEvents(@" + id + ")",
      labelField: "dis",
      selectedValueTags: "dis",
    },
    {
      name: "targets",
      editorType: "list",
      listType: "checkbox",
      prompt: toLocale("j2FinToolsExt::cloneSelectedEventsTo"),
      height: 175,
      dataProvider: "readAll(schedule and kind == \"" + kind + "\" and id != @"+id+").map(x=> x.set(\"dis\", x.dis)).sort(\"dis\")",
      labelField: "dis",
      selectedValueTags: "id",
    },
    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    { name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
  ]

  {
     "dis": toLocale("j2FinToolsExt::cloneEvents"),
     "name": "foo",
     "body": body.toJSON,
     "cancelButton": "\$cancelButton",
     "commitButton": "\$applyButton",
     "commitAction": "finBatchCloneScheduleApply(@" + id + ",\$events,\"readAll(\" + (\$targets).map(t=>\"id==@\"+t).concat(\" or \") + \")\")",
     "helpDoc": "/wiki/display/FINStack/Clone+Events",
     "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})

end


def ​

func:finCommandAuto ​

finCommandAuto(filtstr, levels) ​

Axon function


meta ​

deffunc:finCommandAuto
isfunc
liblib:finTools
namefinCommandAuto

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filtstr, levels) => do
  readAll(parseFilter(filtstr+" and writable")).each rec => do
    levels.each level=> do
      pointWrite(rec->id, null, level, "finCommandAuto")
    end
  end
end


def ​

func:finCommit ​

finCommit(item, changes: null) ​

Axon function


meta ​

constructfinCommit({foo,-bar,age:99})
deffunc:finCommit
examplereadAll(site).finCommit({foo,-bar,age:99}) read(site).fi...
helpThis function basically uses a diff, and a commit functi...
isfunc
liblib:finTools
namefinCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(item, changes: null) => do
    dicts:  item.toRecList

    dicts.each(dict =>
    do
        if (changes != null)
        do
            transientTags: readByIdTransientTags(dict->id)
            applyTransient:{}
            applyPersistent:{}
            commits:[]
            changes.each((val,tag) => do
              if(transientTags.has(tag))
                applyTransient = applyTransient.set(tag, val)
              else
                applyPersistent = applyPersistent.set(tag, val)
            end)

            if(not applyPersistent.isEmpty) do
              logInfo("finCommit", toLocale("j2FinToolsExt::ignoreTransientTags").replace("{boolVal}", applyTransient.toStr))
              diff(dict, applyPersistent).commit
            end
            else if(not applyTransient.isEmpty) do
              logInfo("finCommit", toLocale("j2FinToolsExt::transientTags").replace("{boolVal}", applyTransient.toStr))
              diff(dict, applyTransient,{transient}).commit
            end
        end
        else
        do
            diff(null, dict, {add}).commit()
        end
      end)

  dicts.size()
end


def ​

func:finCommitApplyBatchTags ​

finCommitApplyBatchTags(filter, tags) ​

This function applies the comma-separated tags to all records that match the filter. Both variables are strings.


meta ​

constructfinCommitApplyBatchTags("point and foo", "myPoint, myTag...
deffunc:finCommitApplyBatchTags
isfunc
liblib:finTools
namefinCommitApplyBatchTags

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter,tags) => do
  readAll(parseFilter(filter)).toRecList.map(r => diff(r, ("{" + tags + "}").eval)).commit
end


def ​

func:finCommitSites ​

finCommitSites(recs) ​

Axon function


meta ​

deffunc:finCommitSites
isfunc
liblib:finTools
namefinCommitSites

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(recs) => do

  // pick a site at random to act as the template
  template: read(site)

  // list of essential tags
  essentials: [
      "area",
      "geoCountry",
      "geoAddr",
      "geoCity",
      "geoState",
      "geoPostalCode",
      "tz",
      "weatherStationRef" ]

  // commit each record
  recs.each r => do

      // make sure there is a site marker tag
      r = r.set("site", marker())

      // if there are any missing essentials, copy them from the template
      essentials.each e => do
        if ((not r.has(e)) and template.has(e))
          r = r.set(e, template.get(e))
      end

      // ensure area has square ft
      if (r.has("area"))
          r = r.set("area", parseNumber(r.get("area") + "ft²"))
      else
          r = r.set("area", parseNumber("10000ft²"))

      commit(diff(null, r, {add}))
  end

end


def ​

func:finConflictingTags ​

finConflictingTags(tagarr, data: null) ​

Axon function


meta ​

deffunc:finConflictingTags
isfunc
liblib:finTools
namefinConflictingTags

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(tagarr, data: null) => do
  tagarr = tagarr.remove(0)
  type: ""
  count: 0
  stuff: {}

  if (data != null and data.isStr)
    data = data.parseNumber

  tagarr.each x=>
  do
    //stuff = readAll(navName==x[1] and sp and sensor or navName==x[1] and sp and cmd or navName==x[1] and cmd and sensor or navName==x[1] and not cmd and not sp and not sensor)
    stuff = readAll(navName == x[1] and ((sp and sensor) or (sp and cmd) or (cmd or sensor) or (not cmd and not sp and not sensoe)))

    if(data == null or data == 0)
    do
      if(not isBool(x[0]))
      do
        type = x[0]

        stuff.each y=>
        do
          echo(type.toAxonCode)
          if(type == "cmd") y.diff({cmd, -sp, -sensor}).commit
          else if(type == "sensor") y.diff({sensor, -sp, -cmd}).commit
          else if(type == "sp") y.diff({sp, -cmd, -sensor}).commit

          count = count + 1
        end
      end
    end

    else
    do
      stuff.each y=>
      do
        if(data == 1) y.diff({cmd, -sp, -sensor}).commit
        else if(data == 2) y.diff({sensor, -sp, -cmd}).commit
        else if(data == 3) y.diff({sp, -cmd, -sensor}).commit

        count = count + 1
      end
    end
  end

  toLocale("j2FinToolsExt::pointsWereAffected").replace("{count}", count.toStr)
end


def ​

func:finConnDebugForm ​

finConnDebugForm(debugStr, nameStr) ​

This form is called from finConnectorDebuggingInfo. Will show all the debugging info of selected connectors, separated by connector names.


meta ​

connDebug✓
deffunc:finConnDebugForm
isfunc
liblib:finTools
namefinConnDebugForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(debugStr, nameStr) => do

 body: [
  {name: "nameLabel", editorType: "label", text:toLocale("j2FinToolsExt::debugInfoFor").replace("{name}", nameStr)},
  {name: "debugInfo", editorType: "textarea", defVal: debugStr, editable: false, encapsulate: true, height: 300},
  {name: "applyButton", editorType: "button", label: toLocale("finStackExt::okay"), controlBar: true}
  ]

  {
    "dis": toLocale("j2FinToolsExt::debugInfo"),
    "name": "connDeBugForm",
    "body": body.toJSON,
    //"cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "",
    "helpDoc": "/wiki/display/FINStack/Debug+Info",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finConnDebugInfo ​

finConnDebugInfo(id, selectedDicts, mobileMenu: false) ​

Shows the debugging info of selected bacnet or haystack connectors from the builder app.


meta ​

appFormOnbuilder
connDebug✓
deffunc:finConnDebugInfo
distoLocale("j2FinToolsExt::debugInfo")
folderPathtoLocale("finStackExt::rightMenuConnectors")
formOnbacnetConn or haystackConn
isfunc
liblib:finTools
namefinConnDebugInfo

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, selectedDicts, mobileMenu: false) => do

  //echo(selectedDicts)
  connType: readById(id)
  debugInfo: ""
  connName: "" //connType.dis

  selectedIds : [id.toRec]
    if(selectedDicts != null)
      selectedIds= selectedDicts.map(r => r.toRec)

  if(selectedDicts.size == 1) do
    connType = readById(id)
    connName = connType.dis

    debugInfo = connDetails(id)
  end //end if
  else do
    selectedDicts.each conn => do
      connType = readById(conn->id)
      connName = connType.dis

      if(debugInfo == "") do
        debugInfo = "----------" + connName + "----------\n"
      end else do
        debugInfo = debugInfo + "\n\n----------" + connName + "----------\n"
      end

      debugInfo = connDetails(id)
    end //end selected loop

    connName = toLocale("j2FinToolsExt::multipleConnectors")
  end //end else

  if (mobileMenu ==  null or not mobileMenu) finConnDebugForm(debugInfo, connName)
  else return {debugInfo: debugInfo, connName: connName}

end


def ​

func:finConnectorTemplatePackageAddDevice ​

finConnectorTemplatePackageAddDevice(templateId, connId, data: null) ​

Axon function


meta ​

deffunc:finConnectorTemplatePackageAddDevice
isfunc
liblib:finTools
namefinConnectorTemplatePackageAddDevice

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(templateId, connId, data: null) => do
  connRefs: finConnExts().toGrid.colToList("tag").unique // use finConnExts instead of connReadAllConns (required after SkySpark 3.1.12 upgrade)
  conn: readById(connId)
  connRef: conn.names.find(x=> connRefs.contains(x)) //get the conn type
  navs: read(navMeta)->equipPath.replace("[","").replace("]","").split("/").findAll(x=> x!="").unique
  timezone:  if (conn["tz"] == null or conn->tz == "") now().tz else conn->tz

  if(not data.isDict) data = {} //job progress stuff
  //data = {ts: isJob, pcntMin: cou / sze, pcntMax: (cou + 100) / sze}
  pcntMin: 0
  pcntMax: 100

  if(data.has("pcntMin")) pcntMin = data->pcntMin
  if(data.has("pcntMax")) pcntMax = data->pcntMax

  pcntStep: (pcntMax - pcntMin) / 5
  newSiteName: "Mock Site"   // get the heirarchy names from the connector
  newFloorName: "Mock Floor" // use these instead of imported site/floor names
  newAhuName: null
  equipDiff: {}

  //get the description and location data from the connector
  if(conn.has("bacnetConn")) do
    if(conn.has("description") and conn->description.trim != "") do
      desc: split(conn->description + "..", ".")
      if(desc[0] != "") newSiteName = desc[0]
      if(desc[1] != "") newFloorName = desc[1]
      if(desc[2] != "") newAhuName = desc[2]
    end

    if(conn.has("location") and conn->location.trim != "") do
      loc: split(conn->location + ".", ".")
      if(loc[0] != "") equipDiff = equipDiff.set("roomName", loc[0])
      if(loc[1] != "") equipDiff = equipDiff.set("tenantName", loc[1])
    end
  end

  //make/use a tenant record if this exists
  if(equipDiff.has("tenantName")) do
    tenantRef: read(tenant and dis==equipDiff->tenantName, false)

    if(tenantRef == null) tenantRef = diff(null, {tenant, dis: equipDiff->tenantName}, {add}).commit->id
    else tenantRef = tenantRef->id

    equipDiff = equipDiff.merge({-tenantName, tenantRef: tenantRef})
  end

  //tell us if this is a site/floor/equip/point or not
  isInHeirarchy: r=> do
    navs.find(x=> r.has(x)) != null
  end

  //tell us if a record is a connector
  isConnector: r=> do
    connRefs.find(x=> r.has(x)) != null
  end

  //exit if it can't find the connType
  if(connRef == null)
    return -1

  connRef = connRef + "Ref"
  jobProgress(1 * pcntStep + pcntMin, "") //job progress 20%

  imported: []
  cloneRef: null

  //import the fst
  thisRec: readById(templateId, false)

  //get it from a pod
  if(thisRec == null) do
    qname: templateId.toStr
    pod: "fan://" + qname[0..qname.index("::") -1]
    relto: "/" + qname[qname.index("::")+2 .. -1] + "/"
    imported = finRestoreFile(pod.parseUri, {returnImported, relTo: relto, addOrigId}, false, null)
    cloneRef = read(clone and dis==qname, false) //create clone for pod template

    if(cloneRef == null)
      cloneRef = diff(null, {clone, dis: qname}, {add}).commit

    cloneRef = cloneRef->id
  end

  //get it from an uploaded file
  else do
    imported = finRestoreFile(thisRec, {returnImported, addOrigId}, false, null)

    if(not thisRec.has("clone")) //add clone to file template
      thisRec.diff({clone}).commit

    cloneRef = templateId
  end

  imported = imported.findAll(x=> x.has("id") and readCount(id==x->id) > 0) //ignore fake recs

  //exit if nothing was imported
  if(imported.size == 0)
    return -2

  jobProgress(2 * pcntStep + pcntMin, "") //job progress 40%

  //apply the new site/floor names to the sites/floors
  imported = imported.map rec=> do
    if(rec.has("site")) rec = rec.diff({dis: newSiteName, tz: timezone}).commit
    else if(rec.has("floor")) rec = rec.diff({dis: newFloorName, tz: timezone}).commit
    else if (rec.isInHeirarchy) rec = rec.diff({tz: timezone}).commit

    rec
  end

  //inject the new ahu here
  if(newAhuName != null) do
    flr: imported.find(x=> x.has("floor"))

    if(flr != null) do
      ahueqp: read(ahu and navName==newAhuName and floorRef->dis==flr->dis and siteRef->dis==flr->siteRef->dis, false)
      ahuData: []

      if(ahueqp == null)
      do
        ahuEq: {
          floorRef: flr->id, siteRef: flr->siteRef, ahu, equip,
          disMacro: "\$siteRef \$navName", navName: newAhuName, tz: now().tz
        }

        navMetaList: read(navMeta)->equipPath.split("/").findAll(v => v != "")

        // try to load ahu.fst from pod
        try
        do
          podUri: "fan://" + qname[0..qname.index("::") -1]
          ahuRelTo: "/ahu/"

          ahueqp = finRestoreFile(podUri.parseUri, {returnImported, relTo: ahuRelTo, addOrigId}, false, null).findAll(x=> x.has("id") and readCount(id==x->id) > 0) //.find(v => v.has("ahu"))
          ahuData = ahueqp.findAll(v => finNavMetaWhoAmI(v) == null and not (v.has("pointCount") and v.has("equipCount") and v.has("siteCount"))) //.map(r => r.merge({floorRef: flr->id, siteRef: flr->siteRef}))
          ahueqp = ahueqp.find(v => v.has("ahu"))

        end
        catch (er)
        do
          echo(toLocale("j2FinToolsExt::noAhuFst"))
          echo(er)
        end

        if (ahueqp != null)
        do
          navMetaList.each x =>
          do
            if (ahueqp[x+"Ref"] != null)
            do
              tempRec: readById(ahueqp[x+"Ref"], false)

              if (tempRec != null)
              do
                try do
                  finGraphicOn(tempRec).finHardDelete
                end catch echo("failed")

                tempRec.finHardDelete
              end
            end
          end

          ahueqp = ahueqp.diff({
            floorRef: flr->id, siteRef: flr->siteRef, ahu, equip,
            disMacro: "\$siteRef \$navName", navName: newAhuName, tz: now().tz
          }).commit
        end
        else
          ahueqp = diff(null, ahuEq, {add}).commit
      end

      equipDiff = equipDiff.set("ahuRef", ahueqp->id)
      imported = imported.addRow(ahueqp.set("ignore", marker())).addRows(ahuData)

    end
  end

  //delete sites and floors that already exist
  //also save what their ids should be replaced with in their children
  idRemap: {} //{"old-id": @new-id}
  toDelete: [] //site and floors to delete

  imported = imported.findAll rec =>
  do
    if(rec.has("site") or rec.has("floor"))
    do
      dup: null

      if(rec.has("site")) dup = read(site and dis==rec->dis and id!=rec->id and not origImportId, false) //find site with same name but different id
      else dup = read(floor and dis==rec->dis and siteRef->dis==rec->siteRef->dis and id!=rec->id and not origImportId, false) //find floor with same name and site but different id

      if(dup == null) do
        rec = rec.diff({-origImportId}).commit
        true //keep if it's unique
      end else do //delete and remap the id
        toDelete = toDelete.add(rec)
        idRemap = idRemap.set(rec->id.toStr, dup->id)
        false
      end
    end else true //keep anything else
  end

  toDelete.each x=> try x.finHardDelete catch(e) logErr("finConnectorTemplatePackageAddDevice", toLocale("j2FinToolsExt::deleteError"), e)

  imported = imported.map rec=> do //update the site/floor recs that were changed
    if(rec.has("site") or rec.has("floor")) rec = rec->id.readById
    rec
  end

  //exit if nothing is left
  if(imported.size == 0)
    return -3

  jobProgress(3 * pcntStep + pcntMin, "") //job progress 60%

  diffs: [] //{id: @id, diff: {...}}
  connTagDiff: {}.set(connRef, connId).set("connRef", connId) //{bacnetConnRef: @23423-4234}
  recordsToDelete: []

  findTuningRec: (curTuningRef) => //(curTune, dupTune) =>
  do
    curPolicy: readAll(connTuning and origImportId == curTuningRef.toStr)

    // make sure its the tuning policy that is being kept
    if (curPolicy.size > 1)
    do
      max: curPolicy[0]
      maxCount: readCount(connTuningRef == max->id)

      curPolicy.each poli =>
      do
        newCount: readCount(connTuningRef == poli->id)

        if (newCount > maxCount)
        do
          max = poli
          maxCount = newCount
        end
      end

      curPolicy = max
    end
    else
      curPolicy = curPolicy[0]

    dupTune: read(connTuning and dis == curPolicy->dis and origImportId != curPolicy->origImportId, false)

    // there might already be an identical tuning policy
    if (dupTune != null)
    do
      curProps: curPolicy.names

      isMatch: not dupTune.names.any(prop =>
      do
        curProps = curProps.findAll(z => z != prop)

        if (not contains(["id", "mod", "origImportId", "templateTs"], prop))
        do
          if (prop == "pollTime")
            return dupTune[prop].to("s") != curPolicy[prop].to("s")

          return dupTune[prop] != curPolicy[prop]
        end

        return false
      end)

      // is a complete match
      if (isMatch and curProps.size == 0)
      do
        if (not recordsToDelete.contains(curPolicy->id))
          recordsToDelete = recordsToDelete.add(curPolicy->id)

        return dupTune
      end
    end

    return curPolicy
  end

  //go through each one and fix the connRef
  //also delete non site/floor/equip/point recs if the origImportId already exists
  imported.each rec=> do
    try
    do
      // is a connector
      if(rec.isConnector)
      do
        if (rec.has("connTuningRef") and readCount(connTuning and origImportId == rec->connTuningRef.toStr) > 0)
        do
          tunePol: findTuningRec(rec->connTuningRef)

          readById(connTagDiff->connRef).diff({connTuningRef: tunePol->id}).commit
        end

        rec.finHardDelete //delete incomming connectors
      end

      else
      do
        recDiff: {}

        if(data.has("ts")) //also adds templateTs to everything that is imported
          recDiff = recDiff.merge({templateTs: data->ts})
        if(rec.has("siteRef") and idRemap.has(rec->siteRef.toStr))
          recDiff = recDiff.merge({siteRef: idRemap[rec->siteRef.toStr]})
        if(rec.has("floorRef") and idRemap.has(rec->floorRef.toStr))
          recDiff = recDiff.merge({floorRef: idRemap[rec->floorRef.toStr]})
        if(rec.has(connRef))
          recDiff = recDiff.merge(connTagDiff)

        // re-assign tuning policies
        if(rec.has("connTuningRef") and readCount(connTuning and origImportId == rec->connTuningRef.toStr) > 0)
        do
          tunePol: findTuningRec(rec->connTuningRef)

          recDiff = recDiff.merge({connTuningRef: tunePol->id})
        end

        // part of equip tree?
        if(rec.isInHeirarchy)
        do
          recDiff = recDiff.set("origImportId", removeMarker())

          if(rec.has("equip")) //equip specific stuff
          do
            recDiff = recDiff.merge({cloneRef: cloneRef})

            if(not rec.has("ignore") and readCount(parseFilter("point and equipRef=="+rec->id.toAxonCode+" and "+connRef)) > 0)
            do
              recDiff = recDiff.merge(equipDiff)
              if(rec.has("dis")) recDiff = recDiff.set("dis", conn.dis)
              if(rec.has("navName")) recDiff = recDiff.set("navName", conn.dis)
            end
          end

          diffs = diffs.add({id: rec->id, diff: recDiff})
          //diffs = diffs.add(rec.diff(recDiff))
        end
        else //check if it already exists
        do
          if(rec["origImportId"] == null or readCount(origImportId == rec->origImportId and id != rec->id) == 0) //no doesnt exist, keep
          do
            //recDiff = recDiff.set("origImportId", removeMarker())

            if(rec.has("contentOn") and rec.has("fileId") and rec->fileId != rec->id) //deal with om manuals
            do
              omRec: read(origImportId == rec->fileId.toStr, false)

              if(omRec != null)
                recDiff = recDiff.set("fileId", omRec->id) //.set("origImportId", removeMarker())
            end
            else if(rec.has("graphicOn") and rec.has("fin5")) //deal with graphics
            do
              try
              do
                rec->id.finFixTemplateGraphic

                if (rec.has("thumbnail") and rec->thumbnail.isRef)
                do
                  thumbRec: read(origImportId == rec->thumbnail.toStr, false)

                  if (thumbRec != null)
                    recDiff = recDiff.set("thumbnail", thumbRec->id)
                end
              end
              catch(e) logErr("finConnectorTemplatePackageAddDevice", toLocale("j2FinToolsExt::graphicError"), e)
              //rec = readById(rec->id)
            end

            if(recDiff.names.size > 0)
              diffs = diffs.add({id: rec->id, diff: recDiff})
              //diffs = diffs.add(rec.diff(recDiff))
          end
          else
          do
            logInfo("finConnectorTemplatePackageAddDevice", toLocale("j2FinToolsExt::deletingDuplicateNamedRec").replace("{name}", rec.dis).replace("{recId}", rec->id.toAxonCode))
            recordsToDelete = recordsToDelete.findAll(p => p != rec->id)
            rec->id.finHardDelete //yes does exist, delete
          end
        end // end already exists
      end
    end
    catch(e) logErr("finConnectorTemplatePackageAddDevice",  toLocale("j2FinToolsExt::unknownError"), e)
  end

  jobProgress(4 * pcntStep + pcntMin, "") //job progress 80%

  //diffs.commit
  diffs.map(x=> x->id.readById.diff(x->diff, {force})).commit

  // delete items
  if (recordsToDelete.size > 0)
    recordsToDelete.unique.readByIds.finHardDelete

  connId.readById.diff({wizardConnector: true, cloneRef: cloneRef}).commit //fix up connector rec
end


def ​

func:finConnectorTypes ​

finConnectorTypes() ​

Read connector types


meta ​

deffunc:finConnectorTypes
isfunc
liblib:finTools
namefinConnectorTypes

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finCopyFromGraphicForm ​

finCopyFromGraphicForm(id: null, stage: null, data: null) ​

finCopyFormGraphicForm(stage: null, data: null)

Form to copy elements from one graphic to many other graphics.


meta ​

deffunc:finCopyFromGraphicForm
distoLocale("j2FinToolsExt::copyFromGraphic")
folderPathtoLocale("j2FinToolsExt::graphicTools")
formOnfin5
isfunc
liblib:finTools
namefinCopyFromGraphicForm
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id: null, stage: null, data: null) => do
  if(stage != 1 and stage != 2) do
    types: [
      {d:toLocale("finStackExt::events"),v:"event"},
      {d:toLocale("finStackExt::programs"),v:"program"},
      {d:toLocale("finStackExt::remoteAssets"),v:"remoteAsset"},
      {d:toLocale("j2FinToolsExt::script"),v:"((src or fileRef) and script)"},
      {d:toLocale("j2FinToolsExt::style"),v:"((src or fileRef) and style)"},
      {d:toLocale("finStackExt::virtualPoints"),v:"virtualPoint"}
    ].map(x=> x.set("formSel",true))

    ind: 0
    try ind = readAll(fin5).sort("dis").colToList("id").index(id) catch 0

    body: [
      {
        name: "grph",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::graphicToCopyFrom")+":",
        dataProvider: "readAll(fin5).sort(\"dis\")",
        labelField: "dis",
        selectedValueTags: "id",
        defIndex: ind
      }, //graphic

      {
        name: "type", editorType: "list", prompt: toLocale("j2FinToolsExt::elementTypes")+":", listType: "checkbox", dataProvider: types.toAxonCode, labelField: "d", selectedValueTags: "d,v", defValTagName: "formSel"
      }, //element types

      {
        name: "chkb", editorType: "checkbox", label: toLocale("finStackExt::fileRecordSelectAll"), defVal: true
      }, //select all

      {
        name: "elem", editorType: "list", prompt: toLocale("j2FinToolsExt::elementsToCopy")+":", listType: "checkbox", labelField: "dis", selectedValueTags: "name", defValTagName: "formSel",
        dataProvider: "try finCopyFromGraphicForm(0,1,[[\$grph], [\$type], [\$chkb]]) catch [{dis:\"No Results\"}]"
      }, //elements

      {
        name: "tgrh", editorType: "list", prompt: toLocale("j2FinToolsExt::graphicsToCopyTo")+":", listType: "checkbox",
        dataProvider: "readAll(fin5 and id!=\$grph).sort(\"dis\")", labelField: "dis", selectedValueTags: "id", defIndex: 0
      }, //copy to

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {"dis": toLocale("j2FinToolsExt::copyFromGraphic"),
    "name": "finCopyFromGraphicForm",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "finCopyFromGraphicForm(0,2, [\$grph, \$elem, \$tgrh])",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 1) do
    t: readFinFile(data[0][0])
    r: []
    /*t.finGridFilter(parseFilter(concat(data[1][0].map(x=> x->v)," or "))).sort((x,y)=> x->name.lower <=> y->name.lower).map(x=> x.merge({formSel:data[2][0]}))*/
    data[1][0].each x=> do
      r = r.addAll(t.finGridFilter(parseFilter(x->v)).map(y=> y.set("formSel",data[2][0]).set("dis",y->name+" ("+x->d+")")).toRecList)
    end
    r.toGrid.sort("dis")
  end
  //////////////////////
  else if(stage == 2) do
    t: readFinFile(data[0]).finGridFilter(parseFilter("name==\""+data[1].concat("\" or name==\"")+"\""))
    errs: 0
    data[2].each x=> do
      try readFinFile(x).addRows(t).writeFinFile(x)
      catch errs = errs + 1
    end
    if(errs == 0) errs = toLocale("finStackExt::no")

    body: [
    {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::graphicsProcessed").replace("{num}",data[2].size.toStr)},
    {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::numErros").replace("{num}",errs.toStr)},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]

    {"dis": toLocale("j2FinToolsExt::copyFromGraphic"),
    "name": "finCopyFromGraphicForm2",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end

//readFinFile(@1eeda388-f06313ba).finGridFilter( virtualPoint or remoteAsset or program or event or (((src or fileRef) and style) or ((src or fileRef) and script)))


def ​

func:finCopyTableData ​

finCopyTableData(tableData) ​

Axon function


meta ​

deffunc:finCopyTableData
isfunc
liblib:finTools
namefinCopyTableData

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(tableData) => do

  tableData.each row => do
      commit(diff(null, row, {add}))
  end

end


def ​

func:finCopyTag ​

finCopyTag(filter, tag1, tag2, deleteOrig: true) ​

Backend for finCopyTagForm

Usage: finCopyTag(filter, tag1, tag2, deleteOrig: true)

Clones tag value to a specified tag.

Filter is filter to apply to. Tag1 is tag whose value to clone. Tag2 is tag to create/clone to. DeleteOrig is flag to remove original tag being cloned.


meta ​

deffunc:finCopyTag
isfunc
liblib:finTools
namefinCopyTag

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(filter,tag1,tag2,deleteOrig:true) => do
  filter = readAll(parseFilter(filter)).findAll(x=> x.has(tag1))
  filter.each x=> do
    tagVal: x.trap(tag1)
    tmp: {}.set(tag2,tagVal)
    if(deleteOrig) tmp=tmp.set(tag1,removeMarker())
    x.diff(tmp).commit
  end
end


def ​

func:finCopyTagForm ​

finCopyTagForm(id: null, stage: null) ​

Form to clone tags from one place to another


meta ​

appFormOnfolio
deffunc:finCopyTagForm
distoLocale("j2FinToolsExt::copyTags")
folderPathtoLocale("j2FinToolsExt::batchEditAndClone")
formOnsite or siteRef
isfunc
liblib:finTools
namefinCopyTagForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id: null, stage: null) => do
  if(stage.isStr)
    try stage = stage.parseNumber
    catch ""

  js: [
    "function checkJobStatus(jobHandle) {",
      "var promise;",
      "if (jobHandle === undefined) {",
        "promise = finstack.evalAll(['jobStatusAll().find(v => v->dis.startsWith(\"{FUNC_NAME}\") and v->started > "+now().toAxonCode+")']);",
      "} else {",
        "promise = finstack.evalAll(['jobStatusAll(\"'+jobHandle+'\")[0]']);",
      "}",
      "promise.then(function(event) {",
        "var jobStat = event.result[0].toObj(false, false, true);",
        "var isDone = jobStat['jobStatus'].startsWith('done');",
        "if (isDone) {",
          "window.top.app.HideLoader();",
        "} else {",
          //"var msg;",
          //"if (jobStat != null && jobStat != undefined) { msg = window.languageManager['loaderLoading'] + jobStat['progress'] + '%'; }",
          //"else { msg = window.languageManager['loaderLoading'] + '0%'; }",
          "window.top.app.HideLoader();",
          "window.top.app.ShowLoader(languageManager['{ACTION_VERB}']);",
          "setTimeout(function(){ checkJobStatus(jobStat['handle']); }, 2000);",
        "}",
      "});",
    "}",
    "window.top.app.ShowLoader(languageManager['{ACTION_VERB}']);",
    "checkJobStatus();"
  ]

  if(stage == null)
  do
    body: [
    {name: "radio", editorType: "radio", label: toLocale("j2FinToolsExt::moveTag")+":", group: "group1", selectedValue: 2},
    {name: "radio", editorType: "radio", label: toLocale("j2FinToolsExt::renameTag")+":", group: "group1", selectedValue: 1, defVal: true},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "commitButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
    ]

    {"dis": toLocale("j2FinToolsExt::copyTags"),
    "name": "finCopyTagForm",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "finCopyTagForm("+id.toAxonCode+", \$radio)",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 1)
  do
    if(id == null) dv: ""
    else dv: readById(id).finNavMetaWhoAmI

    body: [
      {name: "filt", editorType: "filter", prompt: toLocale("finStackExt::finFilter")+":", defVal: dv},

      {
        name: "tag1",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::tagToCopy")+":",
        labelField: "val",
        defIndex: 0,
        dataProvider: "try readAll(parseFilter(\$filt)).colNames.sort catch []",
        selectedValueTags: "val"
      },

      {name: "tag2", editorType: "textinput", prompt: toLocale("j2FinToolsExt::tagToCreate")+":", defVal: ""},
      {name: "ckbx", editorType: "checkbox", label: toLocale("j2FinToolsExt::deleteOrigTag"), defVal: true},

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {
      "dis": toLocale("j2FinToolsExt::copyTags"),
      "name": "finCopyTagForm1",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "jobRun(finCopyTag(\$filt, \$tag1, \$tag2, \$ckbx))",
      "completeACtion": js.concat("\n").replace("{FUNC_NAME}", "finCopyTag").replace("{ACTION_VERB}", toLocale("j2FinToolsExt::copyingTagsMsg")),
      "refreshTrees": marker(),
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 2)
  do
    if(id == null) do
      dv1: ""
      dv2: ""
    end
    else do
      dv1: "id==@"+id
      dv2: readById(id).finNavMetaWhoAmI
    end

    body: [
      {name: "filt1", editorType: "filter", prompt:toLocale("j2FinToolsExt::moveFromFilter")+":", defVal: dv1},
      {name: "filt2", editorType: "filter", prompt:toLocale("j2FinToolsExt::moveToFilter")+":", defVal: dv2},

      {
        name: "tag1",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::tagToCopy")+":",
        labelField: "val",
        defIndex: 0,
        dataProvider: "try read(parseFilter(\$filt1)).names.sort catch []",
        selectedValueTags: "val"
      },

      {name: "ckbx", editorType: "checkbox", label: toLocale("j2FinToolsExt::deleteTagFromOrig")},

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {
      "dis": toLocale("j2FinToolsExt::copyTags"),
      "name": "finCopyTagForm2",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "jobRun(finMoveTag(\$filt1, \$filt2, \$tag1, \$ckbx))",
      "completeACtion": js.concat("\n").replace("{FUNC_NAME}", "finMoveTag").replace("{ACTION_VERB}", toLocale("j2FinToolsExt::movingTagsMsg")),
      "refreshTrees": marker(),
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finCreateAlarmTopicCommit ​

finCreateAlarmTopicCommit(topicName, priorityData, tagsData, targetTagsData, topicId, folderPath) ​

Used by the "Create Alarm Topic" form to create the alarmTopic record.


meta ​

deffunc:finCreateAlarmTopicCommit
isfunc
liblib:finTools
namefinCreateAlarmTopicCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(topicName, priorityData, tagsData, targetTagsData, topicId, folderPath) => do
  aRec: {dis: topicName, alarmTopic, topic}
  keyword: toLocale("j2FinToolsExt::created")
  topicOns:"("

  /*---Priority Stuff---*/
  if(priorityData->enabled)
    topicOns = topicOns + "priority " + priorityData->appliedTo + " " + priorityData->val + ")"
  else
    topicOns = ""

  /*---Tags Stuff---*/
  if(not tagsData->custom.trim.isEmpty)
    tagsData = tagsData.set("tags", tagsData->tags.addAll(tagsData->custom.split(",").map(r => r.trim).findAll(v => not v.isEmpty)))

  if(tagsData->tags.size == 1) do
    if(topicOns.isEmpty)
      topicOns = topicOns + "metadata->" + tagsData->tags[0]
    else
      topicOns = topicOns + " and metadata->" + tagsData->tags[0]
  end else do
    tagsData->tags.each tag => do
      if(tag == tagsData->tags[0] and topicOns.isEmpty)
        topicOns = topicOns + "(" + "metadata->" + tag + " "
      else if(tag == tagsData->tags[0])
        topicOns = topicOns + " and (" + "metadata->" + tag + " "
      else if(tag == tagsData->tags[-1])
        topicOns = topicOns + tagsData->logic + " " + "metadata->" + tag + ")"
      else
        topicOns = topicOns + tagsData->logic + " " + "metadata->" + tag + " "
    end
  end

  /*---Target Tags Stuff---*/
  if(targetTagsData->tags.size == 1) do
    if(topicOns.isEmpty)
      topicOns = topicOns + "sourceRef->" + targetTagsData->tags[0]
    else
      topicOns = topicOns + " and sourceRef->" + targetTagsData->tags[0]
  end else do
    targetTagsData->tags.each tag => do
      if(tag == targetTagsData->tags[0] and topicOns.isEmpty)
        topicOns = topicOns + "(sourceRef->" + tag + " "
      else if(tag == targetTagsData->tags[0])
        topicOns = topicOns + " and (sourceRef->" + tag + " "
      else if(tag == targetTagsData->tags[-1])
        topicOns = topicOns + targetTagsData->logic + " sourceRef->" + tag + ")"
      else
        topicOns = topicOns + targetTagsData->logic + " sourceRef->" + tag + " "
    end
  end

  if(topicOns.isEmpty)
    aRec = aRec.set("topicOn", "alarm")
  else
    aRec = aRec.set("topicOn", "alarm and " + topicOns)

  if (folderPath != null and folderPath.isStr)
    aRec = aRec.set("folderPath", folderPath)

  if(topicId == null)
    diff(null, aRec, {add}).commit
  else do
    readById(topicId).diff(aRec).commit
    keyword = toLocale("j2FinToolsExt::updated")
  end

  if(read(topic and dis == topicName) != null)
    finFormAlertOk(toLocale("finStackExt::bLineSuccess"), toLocale("j2FinToolsExt::alarmTopicCreated").replace("{name}", topicName).replace("{verb}", keyword))
  else
    finFormAlertOk(toLocale("finStackExt::warning"), toLocale("j2FinToolsExt::alarmTopicCreatedFailed").replace("{name}", topicName))
end


def ​

func:finCreateAlarmTopicForm ​

finCreateAlarmTopicForm(topicId: null, folderPath: null) ​

Create a new alarm topic and chooses which alarm priority, tags, target tags to apply it to.


meta ​

appFormOnfolio
deffunc:finCreateAlarmTopicForm
distoLocale("j2FinToolsExt::createAlarmTopic")
folderPathtoLocale("finStackExt::userMenuSubscriptions")
formOnuser
helpCreate a new alarm topic and choose which alarm prioriti...
isfunc
liblib:finTools
namefinCreateAlarmTopicForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(topicId:null, folderPath: null) => do
  nameTip: toLocale("j2FinToolsExt::subCreateTopicName")
  alarmCheckTip: toLocale("j2FinToolsExt::subCreateCheckBox")
  alarmPriTip: toLocale("j2FinToolsExt::subEnterAlarmPriority")
  alarmLogicTip: toLocale("j2FinToolsExt::subChooseAlarmPriority")
  tagsTip: toLocale("j2FinToolsExt::subCheckAlarmsToInclude")
  customTagsTip: toLocale("j2FinToolsExt::subCommaList")
  targetTip: toLocale("j2FinToolsExt::subCheckTagsTargetRefs")
  logicTip: toLocale("j2FinToolsExt::subChooseSearchMethod")

  howToSearch: [{dis: toLocale("j2FinToolsExt::allTags"), val: "and"},{dis: toLocale("j2FinToolsExt::anyTags"), val: "or"}]
  defVals: {name: "", priority: 0, hasPri: false, priLogic: 2, alarmTagsLogic: 0, alarmTags: [], targetsLogic: 0, targets: []}
  endOfOwners: 0
  tempStr: null
  topicObj: null
  formTitle: toLocale("j2FinToolsExt::createAlarmTopic")
  okButton: toLocale("finStackExt::coreCreate")

  if(topicId != null) do
    defVals = defVals.set("name", readById(topicId).dis)
    topicObj = readById(topicId)->topicOn
    formTitle = toLocale("j2FinToolsExt::editAlarmTopic")
    okButton = toLocale("finStackExt::coreApply")

    if(topicObj.size > 5 and topicObj[0..8] == "alarm and")
      topicObj = topicObj[10..-1].replace(" and ", " & ").replace(" or ", " | ")
    else
      topicObj = topicObj.replace(" and ", " & ").replace(" or ", " | ")

    if(topicObj.contains("priority")) do
      defVals = defVals.set("hasPri", true)

      tempStr = topicObj.split(")")[0][1..-1].replace("priority ", "")
      if(tempStr[0..1] == "<=")
        defVals = defVals.set("priLogic", 1)
      else if(tempStr[0..1] == ">=")
        defVals = defVals.set("priLogic", 0)

      defVals = defVals.set("priority", parseNumber(tempStr[3..-1]))

      endOfOwners = topicObj.index(")") + 4

      if(topicObj.size > endOfOwners)
        topicObj = topicObj[endOfOwners..-1]
    end

    if(topicObj.contains("targetRef")) do
      endOfOwners = topicObj.index("targetRef")

      if(topicObj[endOfOwners - 1] == 40) do
        tempStr = topicObj[endOfOwners..-2]
        if(tempStr.split(" ")[1] == "|")
          defVals = defVals.set("targetsLogic", 1)
        topicObj = topicObj[0..(endOfOwners - 5)]
      end else do
        tempStr = topicObj[endOfOwners..-1]
        topicObj = topicObj[0..(endOfOwners - 4)]
      end

      tempStr.replace("targetRef->", "#").replace("|", "").replace("&", "").split("#")[1..-1].each target => defVals = defVals.set("targets", defVals->targets.add(target))
    end

    if(not topicObj.isEmpty()) do
      if(topicObj[0] == 40) do
        topicObj = topicObj[1..-2]
        if(topicObj.split(" ")[1] == "|")
          defVals = defVals.set("alarmTagsLogic", 1)
      end

      topicObj.split(" ").each tag => if(tag != "&" and tag != "|") defVals = defVals.set("alarmTags", defVals->alarmTags.add(tag))
    end
  end

  body: [{ name: "topicName",
           editorType: "textinput",
           prompt: toLocale("j2FinToolsExt::subAlarmTopicName"),
           defVal: defVals->name,
           toolTip: nameTip
         },

         { name: "priSep",
           editorType: "separator",
           text: toLocale("j2FinToolsExt::subAlarmPriority")
         },

         { name: "priorityCheck",
           editorType: "checkbox",
           label: toLocale("finStackExt::weatherMenuAdd") + " " + toLocale("j2FinToolsExt::subAlarmPriority"),
           defVal: defVals->hasPri,
           toolTip: alarmCheckTip
         },

         { name: "priorityVal",
           editorType: "numericstepper",
           toolTip: alarmPriTip,
           defVal: defVals->priority,
           maxVal: 255,
           minVal: 0
         },

         { name: "priorityRange",
           editorType: "combobox",
           dataProvider: "[{dis: "+toLocale("j2FinToolsExt::greaterThanOrEqual").toAxonCode+", val: \">=\"}, {dis: "+toLocale("j2FinToolsExt::lesserThanOrEqual").toAxonCode+",val:\"<=\"},{dis:"+toLocale("j2FinToolsExt::exact").toAxonCode+",val:\"==\"}]",
           labelField: "dis",
           selectedValueTags: "val",
           defIndex: defVals->priLogic,
           toolTip: alarmLogicTip
         },

         { name: "tagSep",
           editorType: "separator",
           text: toLocale("j2FinToolsExt::alarmTags")
         },

         { name: "tagCombo",
           editorType: "combobox",
           dataProvider: howToSearch.toAxonCode,
           labelField: "dis",
           selectedValueTags: "val",
           defIndex: defVals->alarmTagsLogic,
           toolTip: logicTip
         },

         { name: "tagList",
           editorType: "list",
           listType: "checkbox",
           prompt: toLocale("j2FinToolsExt::alarmTags"),
           dataProvider: finReadAlarmTags(defVals->alarmTags).map(row => if(defVals->alarmTags.find(v => v == row->dis) != null) row.set("selected", marker()) else row).toRecList.toAxonCode, // defVals->alarmTags
           labelField: "dis",
           selectedValueTags: "dis",
           defValTagName: "selected",
           toolTip: tagsTip
         },

         {
           name: "customTags",
           editorType: "textinput",
           prompt: toLocale("j2FinToolsExt::customAlarmTags"),
           defVal: "",
           toolTip: customTagsTip
         },

         { name: "targetSep",
           editorType: "separator",
           text: toLocale("finStackExt::targetTags")
         },

         { name: "targetCombo",
           editorType: "combobox",
           dataProvider: howToSearch.toAxonCode,
           labelField: "dis",
           selectedValueTags: "val",
           defIndex: defVals->targetsLogic,
           toolTip: logicTip
         },

         { name: "targetTags",
           editorType: "list",
           prompt: toLocale("finStackExt::targetTags"),
           listType: "checkbox",
           dataProvider: readAllTagNames(site or floor or equip).findAll(v => v->kind=="Marker").map(row => if(defVals->targets.find(v => v == row->name) != null) row.set("selected", marker()) else row).toRecList.toAxonCode,
           labelField: "name",
           selectedValueTags: "name",
           defValTagName: "selected",
           toolTip: targetTip
         },

         { name: "cancelButton",
           editorType: "button",
           label: toLocale("finStackExt::cancel"),
           controlBar: true},

         { name: "applyButton",
           editorType: "button",
           label: okButton,
           controlBar: true}]

  { "dis": formTitle,
    "name": "createAlarmTopic",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finCreateAlarmTopicCommit(\$topicName, {enabled:\$priorityCheck, val: \$priorityVal, appliedTo: \$priorityRange}, {tags: \$tagList, logic: \$tagCombo, custom: \$customTags}, {tags: \$targetTags, logic: \$targetCombo}, " + topicId.toAxonCode + ", "+folderPath.toAxonCode+")",
    "helpDoc":"/wiki/display/FINStack/Create+Alarm+Topic",
    "completeAction": "try { " + generateFormRefreshCalls("topic", folderPath, true, true)["jsAction"] + " window.app.RefreshBuilderGridAt(0, 'panel'); } catch (err) {}",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finCreateEditTuningPolicyCommit ​

finCreateEditTuningPolicyCommit(changesDict, id, folderPath: null) ​

Axon function


meta ​

deffunc:finCreateEditTuningPolicyCommit
isfunc
liblib:finTools
namefinCreateEditTuningPolicyCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(changesDict, id, folderPath:null) => do
  nam: changesDict["name"]
  folderRec: null
  existingRec: null

  if (id != null and id.isRef)
    existingRec = readById(id, false)

  // new record or edited record's name has been changed
  if (not changesDict["edit"] or (existingRec != null and existingRec.dis != nam))
  do
    if(nam == "") nam = random(1..10000).toStr

    n: readAll(connTuning and dis).findAll(x=> x->dis.startsWith(nam)).toRecList.map(x=> x->dis)
    duplicateName : n

    if(n.size > 0) do
      n = n.map(x=> do
        l: x.size - 1
        if(parseNumber(x[l..l],false) == null) 0
        else do //find number on end
          m: 0
          (l..0).eachWhile y=> do
            m = y
            if(parseNumber(x[y..y],false) != null) return null
            else true
          end
          parseNumber(x[m + 1..l],false)
        end
      end).sortr[0]
      if(duplicateName.contains(nam)) nam = nam + toStr(n + 1)
    end
  end

  newDict:{connTuning, dis: nam}

  if(changesDict->schedule) newDict = newDict.set("writeSchedule", marker())
  else  newDict = newDict.set("writeSchedule", removeMarker())

  if(changesDict->minEnab) newDict = newDict.set("writeMinTime", parseNumber(changesDict->minWrite + "sec"))
  else  newDict = newDict.set("writeMinTime", removeMarker())

  if(changesDict->maxEnab) newDict = newDict.set("writeMaxTime", parseNumber(changesDict->maxWrite + "min"))
  else  newDict = newDict.set("writeMaxTime", removeMarker())

  if(changesDict->pollEnab) newDict = newDict.set("pollTime", parseNumber(changesDict->poll))
  else  newDict = newDict.set("pollTime", removeMarker())

  if(folderPath != null and folderPath != "")
  do
    if(folderPath.startsWith("@")) do
      folderRec = readById(folderPath[1..-1].parseRef, null)
      folderPath = (if(folderRec["folderPath"] != null) folderRec->folderPath + "/" else "") + folderRec->dis
    end

    newDict = newDict.merge({folderPath: reFind(r"[^/].*[^/]", folderPath)})
  end

  if(changesDict->edit) readById(id).diff(newDict).commit
  else newDict.toRecList.finCommit()

  if (folderRec != null) try folderPathDelete(folderPath->id) catch return 0
end


def ​

func:finCreateEmbeddedLink ​

Axon function


meta ​

deffunc:finCreateEmbeddedLink
isfunc
liblib:finTools
namefinCreateEmbeddedLink
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

 // Create an embedded link to a Skyspark 3.0 app page
 // @author Radu Racariu <radur@j2inn.com>
(viewName, noChrome: true) => do
  chrome: "nochrome"
  if (noChrome == false) do chrome = "" end
  spec:  "{meta : {" + chrome + "} left:{view:\"" + viewName + "\"}}"
  data: spec.finBase64Encode().replace("=", "").parseUri().uriEncode()
  projName: context()->projName
  return "/ui/" + projName + "?ws=" + data
end


def ​

func:finCreateFormTemplate ​

finCreateFormTemplate(funcName) ​

Function to make a beginning form function instantly


meta ​

deffunc:finCreateFormTemplate
isfunc
liblib:finTools
namefinCreateFormTemplate

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(funcName) => do
  funcName = funcName.toTagName
  words: []
  tmp: ""
  char: ""

  if (funcs(name == funcName).size > 0)
    throw toLocale("j2FinToolsExt::duplicateFuncName")

  (0..funcName.size-1).each x=> do
    char = funcName[x..x]
    if(char == char.lower) tmp = tmp + char
    else do
      words = words.add(tmp)
      tmp = char
    end
  end
  words = words.add(tmp)
  dis: words.concat(" ").trim.capitalize

  cont:
    "() => do\n"
  + "  body: [\n"
  + "  {name: \"cancelButton\", editorType: \"button\", label: \"Cancel\", controlBar: true},\n"
  + "  {name: \"commitButton\", editorType: \"button\", label: \"Apply\", controlBar: true}\n"
  + "  ]\n"
  + "  \n"
  + "  {\n"
  + "  \"dis\": \""+dis+"\",\n"
  + "  \"name\": \""+funcName+"\",\n"
  + "  \"body\": body.toJSON,\n"
  + "  \"cancelButton\": \"\\\$cancelButton\",\n"
  + "  \"commitButton\": \"\\\$commitButton\",\n"
  + "  \"commitAction\": \"null\",\n"
  + "  \"completeAction\": \"null\",\n"
  + "  \"finForm\": marker()\n"
  + "  }.toGrid.addMeta({formExecute: marker()})\n"
  + "end"
  diff(null,{func: marker(), name: funcName, src: cont},{add}).commit
end


def ​

func:finCreateFromTemplate ​

finCreateFromTemplate(tempList, isJob: null) ​

Axon function


meta ​

deffunc:finCreateFromTemplate
isfunc
liblib:finTools
namefinCreateFromTemplate

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(tempList, isJob: null) => do
  if(isJob != null)
  do
    sze: tempList.size + 1
    cou: 0
    msg: ""

    tempList.each x =>
    do
      try
      do
        func: finTemplateGenerateFunc(x->id, x->templatePath)

        if(func != null)
        do
          func = func.replace("\"<data>\"", {ts: isJob, pcntMin: cou / sze, pcntMax: (cou + 100) / sze}.toAxonCode)

          try eval(func)
          catch(e)
          do
            logErr("finCreateFromTemplate", toLocale("j2FinToolsExt::funcError")+": " + func, e)
          end
        end
      end
      catch (e) logErr("finCreateFromTemplate",toLocale("j2FinToolsExt::unknownError"), e)

      cou = cou + 100
      jobProgress(cou / sze, msg)
    end
  end
  else
  do
    ts: now().toTimeZone("UTC").toStr.replace(" UTC","")
    {templateTs: ts, jobHandle: eval("jobRun(finCreateFromTemplate("+ tempList.toAxonCode +", "+ ts.toAxonCode +"))")}
  end
end

/*
finCreateFromTemplate([{id: @234234, templatePath: @siemens::foo or @345345}, ...])
actually imports the template and uses the specified connector

  returns job stuff and templateTs that is being used

  also adds templateTs to everything that is imported

add cloneRef marker to equips created and conns that it was applied on

on import, make clone record
\tclone marker tag
\tdis: "siemens::foo"
if using db import, add clone tag to template file

  set wizardConnector tag of conn to true
*/


def ​

func:finCreateNoteTopicCommit ​

finCreateNoteTopicCommit(topicName, userList, tagsData, targetTagsData, topicId, folderPath) ​

Used by the "Create Note Topic" form to create the noteTopic record.


meta ​

deffunc:finCreateNoteTopicCommit
isfunc
liblib:finTools
namefinCreateNoteTopicCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(topicName, userList, tagsData, targetTagsData, topicId, folderPath) => do
  aRec: {dis: topicName, noteTopic, topic}
  keyword: toLocale("j2FinToolsExt::created")
  topicOns:"("

  /*---User Stuff---*/
  if(userList.isEmpty)
    topicOns = ""
  else do
    userList.each user => do
      if(userList[-1] == user or userList.size == 1)
        topicOns = topicOns + "owner==" + user.toAxonCode + ")"
      else
        topicOns = topicOns + "owner==" + user.toAxonCode + " or "
    end
  end

  /*---Tags Stuff---*/
  if(not tagsData->custom.trim.isEmpty) do
    tagsData = tagsData.set("tags", tagsData->tags.addAll(tagsData->custom.split(",").map(r => r.trim).findAll(v => not v.isEmpty)))
    finEditNoteTagsCommit([], tagsData->custom)
  end

  if(tagsData->tags.size == 1) do
    if(topicOns.isEmpty)
      topicOns = topicOns + tagsData->tags[0]
    else
      topicOns = topicOns + " and " + tagsData->tags[0]
  end else do
    tagsData->tags.each tag => do
      if(tag == tagsData->tags[0] and topicOns.isEmpty)
        topicOns = topicOns + "(" + tag + " "
      else if(tag == tagsData->tags[0])
        topicOns = topicOns + " and (" + tag + " "
      else if(tag == tagsData->tags[-1])
        topicOns = topicOns + tagsData->logic + " " + tag + ")"
      else
        topicOns = topicOns + tagsData->logic + " " + tag + " "
    end
  end

  /*---Target Tags Stuff---*/
  if(targetTagsData->tags.size == 1) do
    if(topicOns.isEmpty)
      topicOns = topicOns + "targetRef->" + targetTagsData->tags[0]
    else
      topicOns = topicOns + " and targetRef->" + targetTagsData->tags[0]
  end else do
    targetTagsData->tags.each tag => do
      if(tag == targetTagsData->tags[0] and topicOns.isEmpty)
        topicOns = topicOns + "(targetRef->" + tag + " "
      else if(tag == targetTagsData->tags[0])
        topicOns = topicOns + " and (targetRef->" + tag + " "
      else if(tag == targetTagsData->tags[-1])
        topicOns = topicOns + targetTagsData->logic + " targetRef->" + tag + ")"
      else
        topicOns = topicOns + targetTagsData->logic + " targetRef->" + tag + " "
    end
  end

  if (folderPath != null and folderPath.isStr)
    aRec = aRec.set("folderPath", folderPath)

  if(topicOns.isEmpty)
    aRec = aRec.set("topicOn", "note")
  else
    aRec = aRec.set("topicOn", "note and " + topicOns)

  if(topicId == null)
    diff(null, aRec, {add}).commit
  else do
    readById(topicId).diff(aRec).commit
    keyword = toLocale("j2FinToolsExt::updated")
  end

  if(read(topic and dis == topicName) != null)
    finFormAlertOk(toLocale("finStackExt::bLineSuccess"), toLocale("j2FinToolsExt::noteTopicCreated").replace("{name}", topicName).replace("{verb}", keyword))
  else
    finFormAlertOk(toLocale("finStackExt::warning"), toLocale("j2FinToolsExt::noteTopicCreatedFailed").replace("{name}", topicName))
end


def ​

func:finCreateNoteTopicForm ​

finCreateNoteTopicForm(topicId: null, folderPath: null) ​

Allows the user to create a new note topic and choose which users, tags, and target tags to apply it to by assigning it to topicOn property.


meta ​

appFormOnfolio
deffunc:finCreateNoteTopicForm
distoLocale("j2FinToolsExt::createNoteTopic")
folderPathtoLocale("finStackExt::userMenuSubscriptions")
formOnuser
helpCreate a new note topic and choose which users, tags, ta...
isfunc
liblib:finTools
namefinCreateNoteTopicForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(topicId:null, folderPath: null) => do
  nameTip: toLocale("j2FinToolsExt::finCreateTopicName")
  assignTip: toLocale("j2FinToolsExt::finCreateTopicCheckUsers")
  tagsTip: toLocale("j2FinToolsExt:finCheckTopicTags")
  customTagsTip: toLocale("j2FinToolsExt::finCommaList")
  targetTip: toLocale("j2FinToolsExt::finCheckTargetRefTags")
  logicTip: toLocale("j2FinToolsExt::finCreateTopicChooseSearchMethod")

  howToSearch: [
    {dis: toLocale("j2FinToolsExt::allTags"), val: "and"},
    {dis: toLocale("j2FinToolsExt::anyTags"), val: "or"}
  ]
  defVals: {name: "", assignees: [], noteTagsLogic: 0, noteTags: [], targetsLogic: 0, targets: []}
  endOfOwners: 0
  tempStr: null
  topicObj: null
  formTitle: toLocale("j2FinToolsExt::createNoteTopic")
  okButton: toLocale("finStackExt::coreCreate")

  if(topicId != null) do
    defVals = defVals.set("name", readById(topicId).dis)
    topicObj = readById(topicId)->topicOn
    formTitle = toLocale("j2FinToolsExt::editNoteTopic")
    okButton = toLocale("finStackExt::coreApply")

    if(topicObj.size > 4 and topicObj[0..7] == "note and")
      topicObj = topicObj[9..-1].replace(" and ", " & ").replace(" or ", " | ").replace("==", "=")
    else
      topicObj = topicObj.replace(" and ", " & ").replace(" or ", " | ").replace("==", "=")

    if(topicObj.contains("owner")) do
      topicObj.split(")")[0][1..-1].replace("owner=", "").split("|").each id => defVals = defVals.set("assignees", defVals->assignees.add(id))
      endOfOwners = topicObj.index(")") + 4
      topicObj = if (endOfOwners >= topicObj.size) "" else topicObj[endOfOwners..-1]
    end

    if(topicObj.contains("targetRef")) do
      endOfOwners = topicObj.index("targetRef")

      if(topicObj[endOfOwners - 1] == 40) do
        tempStr = topicObj[endOfOwners..-2]
        if(tempStr.split(" ")[1] == "|")
          defVals = defVals.set("targetsLogic", 1)
        topicObj = topicObj[0..(endOfOwners - 5)]//topicObj.replace(topicObj[(endOfOwners - 1)..-1], "")
      end else do
        tempStr = topicObj[endOfOwners..-1]
        topicObj = topicObj[0..(endOfOwners - 4)] //topicObj.replace(topicObj[endOfOwners..-1], "")
      end

      //topicObj = topicObj.replace(topicObj[endOfOwners..-1], "")
      tempStr.replace("targetRef->", "#").replace("|", "").replace("&", "").split("#")[1..-1].each target => defVals = defVals.set("targets", defVals->targets.add(target))
    end

    if(not topicObj.isEmpty()) do
      if(topicObj[0] == 40) do
        topicObj = topicObj[1..-2]
        if(topicObj.split(" ")[1] == "|")
          defVals = defVals.set("noteTagsLogic", 1)
      end

      topicObj.split(" ").each tag => if(tag != "&" and tag != "|") defVals = defVals.set("noteTags", defVals->noteTags.add(tag))
    end
  end

  body: [{ name: "topicName",
           editorType: "textinput",
           prompt: toLocale("j2FinToolsExt::topicName"),
           toolTip: nameTip,
           defVal: defVals->name
         },

         { name: "userList",
           editorType: "list",
           prompt: toLocale("j2FinToolsExt::assignTo"),
           listType: "checkbox",
           dataProvider: userReadAll().map(row => if(defVals->assignees.find(v => v == row->id) != null) row.set("selected", marker()) else row).keepCols(["id","dis","selected"]).toRecList.toAxonCode,
           labelField: "dis",
           selectedValueTags: "id",
           defValTagName: "selected",
           toolTip: assignTip
         },

         { name: "tagSep",
           editorType: "separator",
           text: toLocale("j2FinToolsExt::noteTags")
         },

         { name: "tagCombo",
           editorType: "combobox",
           dataProvider: howToSearch.toAxonCode,
           labelField: "dis",
           selectedValueTags: "val",
           defIndex: defVals->noteTagsLogic,
           toolTip: logicTip
         },

         { name: "tagList",
           editorType: "list",
           listType: "checkbox",
           prompt: toLocale("j2FinToolsExt::noteTags"),
           dataProvider: read(noteTags)->noteTags.split(",").map(row => if(defVals->noteTags.find(v => v == row) != null) {dis: row, selected} else {dis: row}).toRecList.toAxonCode,
           labelField: "dis",
           selectedValueTags: "dis",
           defValTagName: "selected",
           toolTip: tagsTip
         },

         {
           name: "customTags",
           editorType: "textinput",
           prompt: toLocale("j2FinToolsExt::customNoteTags"),
           defVal: "",
           toolTip: customTagsTip
         },

         { name: "targetSep",
           editorType: "separator",
           text: toLocale("finStackExt::targetTags")
         },

         { name: "targetCombo",
           editorType: "combobox",
           dataProvider: howToSearch.toAxonCode,
           labelField: "dis",
           selectedValueTags: "val",
           defIndex: defVals->targetsLogic,
           toolTip: logicTip
         },

         { name: "targetTags",
           editorType: "list",
           listType: "checkbox",
           prompt: toLocale("finStackExt::targetTags"),
           dataProvider: readAllTagNames(site or floor or equip).findAll(v => v->kind=="Marker").map(row => if(defVals->targets.find(v => v == row->name) != null) row.set("selected", marker()) else row).toRecList.toAxonCode,
           labelField: "name",
           selectedValueTags: "name",
           defValTagName: "selected",
           toolTip: targetTip
         },

         { name: "cancelButton",
           editorType: "button",
           label: toLocale("finStackExt::cancel"),
           controlBar: true},

         { name: "applyButton",
           editorType: "button",
           label: okButton,
           controlBar: true}]

  { "dis": formTitle,
    "name": "createNoteTopic",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finCreateNoteTopicCommit(\$topicName, \$userList, {tags: \$tagList, logic: \$tagCombo, custom: \$customTags}, {tags: \$targetTags, logic: \$targetCombo}, " + topicId.toAxonCode + ", "+folderPath.toAxonCode+")",
    //"gotoAction": "finstack:folio:axonQuery=read(topic and dis == \"\$topicName\")",
    "completeAction": "try { " + generateFormRefreshCalls("topic", folderPath, true, true)["jsAction"] + " window.app.RefreshBuilderGridAt(0, 'panel'); } catch (err) {}",
    "helpDoc":"/wiki/display/FINStack/Create+Note+Topic",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finCreatePod ​

finCreatePod(step: -2, name: "", copyDefault: false, publish: false, ver: "", filter: "", func: "", addRes: null, createKind: "", mergeFn: true) ​

Axon function


meta ​

deffunc:finCreatePod
isfunc
liblib:finTools
namefinCreatePod

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(step:-2, name:"",copyDefault:false, publish: false, ver:"",filter:"", func:"", addRes:null, createKind:"",mergeFn:true)=> do
  if(step == -2) do
    body:[
      {name:"name", editorType: "textinput", prompt:toLocale("j2FinToolsExt::podName")},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    return {
        "dis": toLocale("j2FinToolsExt::createPod"),
        "name": "createPodForm0",
        "body": body.toJSON,
        "cancelButton": "\$cancelButton",
        "commitButton": "\$applyButton",
        "commitAction": "finCreatePod(-1,\$name)",
        "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(step == -1) do
    name = name.split(" ").map((w,idx) => if(idx > 0) w.lower.capitalize else w.lower).concat("")
    foundPod : findPod(name + "Ext")

    folderExist: ioExists(parseUri("io/" + name + "Template/"))
    opts :[{dis:toLocale("finStackExt::coreCreateNew"), val:"new"}]
    if(folderExist)
      opts = opts.add({dis:toLocale("j2FinToolsExt::useExistingFolder").replace("{name}", name + "Template/"),val:"overwrite"})
    if(foundPod)
      opts = opts.add({dis:toLocale("j2FinToolsExt::editFromExisting").replace("{name}", name + "Ext.pod"), val:"pod"})
    body:[
      {name:"option", editorType: "combobox", prompt:toLocale("finStackExt::coreCreate"), dataProvider:toJSON(opts), labelField:"dis", selectedValueTags:"val",defIndex:0},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    return {
        "dis": toLocale("j2FinToolsExt::createPod"),
        "name": "createPodForm0",
        "body": body.toJSON,
        "cancelButton": "\$cancelButton",
        "commitButton": "\$applyButton",
        "commitAction": "finCreatePod(0,\"" + name + "\",false,false, \"\", \"\", \"\",null, \$option)",
        "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(step == 0) do
    version : getPodVersion(name + "Ext.pod")
    if(createKind == "new") do
      if(ioExists("io/" + name + "Template/"))
        ioDelete(parseUri("io/" + name + "Template/"))

      ioCreateDir(parseUri("io/" + name + "Template/"))
    end
    else if(createKind == "pod") do
      ioUnzipPod(name + "Ext.pod", parseUri("io/" + name + "Template/"))
    end

    body: [
                {name: "bkFilter", editorType:"filter", prompt:toLocale("j2FinToolsExt::templateFilter"),defVal:" "},
                {name: "fnFilter", editorType:"textinput", prompt:toLocale("j2FinToolsExt::funcFilter"),defVal:" "},
                {name: "mergeFuncs", editorType: "checkbox", label:toLocale("j2FinToolsExt::mergeFuncs")+ "("+toLocale("j2FinToolsExt::uncheckToOverwrite")+")",defVal:true},
                {name: "podVer", editorType:"textinput", prompt:toLocale("j2FinToolsExt::podVersion"),defVal: version},

                {name: "publish", editorType: "checkbox", label:toLocale("j2FinToolsExt::publishToStackhub")},
                {name:"group", editorType:"group",horizontal:true, prompt:toLocale("j2FinToolsExt::addResources"), children:[
                  {name:"resModel",editorType:"checkbox", label:toLocale("j2FinToolsExt::modelFiles"),defVal: ioExists(parseUri("io/" + name + "Template/res/models/"))},
                  {name:"resJson",editorType:"checkbox", label:toLocale("j2FinToolsExt::graphicRecs"),defVal: ioExists(parseUri("io/" + name + "Template/res/elements/"))},
                  {name:"resTemplate",editorType:"checkbox", label:toLocale("j2FinToolsExt::graphicTemps"),defVal: ioExists(parseUri("io/" + name + "Template/res/templates/"))},
                  {name:"resJslib",editorType:"checkbox", label:"JS/CSS",defVal: ioExists(parseUri("io/" + name + "Template/res/jslibs/"))},
                  {name:"resFin5",editorType:"checkbox", label:toLocale("finStackExt::rightMenuGraphicsTitle"),defVal: ioExists(parseUri("io/" + name + "Template/res/graphics/"))},
                  {name:"resImg",editorType:"checkbox", label:toLocale("finStackExt::folioFilesImages"),defVal: ioExists(parseUri("io/" + name + "Template/res/images/"))},
                ]},
                {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
                {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
           ]

    return  {
        "dis": toLocale("j2FinToolsExt::createPod"),
        "name": "createPodForm",
        "body": body.toJSON,
        "cancelButton": "\$cancelButton",
        "commitButton": "\$applyButton",
        "commitAction": "finCreatePod(1,\"" + name +"\",true,\$publish, \$podVer, \$bkFilter, \$fnFilter,{finModel:\$resModel, json:\$resJson, tmpl:\$resTemplate, jslib:\$resJslib, fin5:\$resFin5, img:\$resImg},\$mergeFn)",
        "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(step == 1) do

    folder:"io/" + name +"Template/"

    ioCreateDir(parseUri(folder +"lib/"))
    //if(copyDefault) do
    //  if(ioExists( parseUri(folder + "bacnetProperties.trio")) == false)
    //    ioWriteStr(ioReadFileStr(`fan://j2FinToolsExt/res/podTemplate/bacnetProperties.trio`), parseUri(folder + "bacnetProperties.trio"))
    //  if(ioExists( parseUri(folder + "lib/"+ name +"ExtFuncs.trio")) == false)
    //    ioWriteStr(ioReadFileStr(`fan://j2FinToolsExt/res/podTemplate/podFuncs.trio`), parseUri(folder + "lib/"+ name +"ExtFuncs.trio"))
    //  if(ioExists( parseUri(folder +  name +"ExtTags.trio")) == false)
    //    ioWriteStr(ioReadFileStr(`fan://j2FinToolsExt/res/podTemplate/podTags.trio`), parseUri(folder + name +"ExtTags.trio"))
    //end

    if(filter.trim != "") do
      try do
        recs: readAll(parseFilter(filter))
        bkFileRec: recs.finBackupRecord({everything:true})[0]
        handle:ioBin(bkFileRec, "file")

        ioWriteFile(handle, parseUri(folder + name+"Ext.fst"))
      end
      catch(err) logErr("j2FinToolsExt","finCreatePod",err)
    end
    if(func.trim != "") do
      fnRecs: readAll(parseFilter("func and (" + func + ")"))
      if(fnRecs.size > 0) do
        exRecs:[]
        if(ioExists(parseUri("io/" + name + "Template/" + name + "ExtFunc.trio"))) do
          exRecs = readFileTrio(parseUri("io/" + name + "Template/lib/" + name + "ExtFunc.trio"))
        end
        mergedRecs:exRecs
        fnRecs.each( fnRec => do
          if(mergedRecs.any(mRec=> mRec->name == fnRec->name) == false) mergedRecs = mergedRecs.add(fnRec)
        end)
        if(mergeFn)
          ioWriteTrio(mergedRecs, parseUri(folder + "lib/" + name + "ExtFunc.trio"))
        else
          ioWriteTrio(fnRecs, parseUri(folder + "lib/" + name + "ExtFunc.trio"))

      end
    end

    if(addRes != null) do
      if(addRes->finModel) ioCreateDir(parseUri(folder + "res/models/"))
      if(addRes->json)     ioCreateDir(parseUri(folder + "res/elements/"))
      if(addRes->tmpl) ioCreateDir(parseUri(folder + "res/templates/"))
      if(addRes->jslib) ioCreateDir(parseUri(folder + "res/jslibs/"))
      if(addRes->fin5) ioCreateDir(parseUri(folder + "res/graphics/"))
      if(addRes->img) ioCreateDir(parseUri(folder + "res/images/"))
    end

    body:[
      {name:"lbl",editorType:"label",text:toLocale("j2FinToolsExt::tempFolderAdded").replace("{folderName}", folder)},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::continue"), controlBar: true}
    ]

    return  {
        "dis": toLocale("j2FinToolsExt::createPod"),
        "name": "createPodForm2",
        "body": body.toJSON,
        "cancelButton": "\$cancelButton",
        "commitButton": "\$applyButton",
        "commitAction": "finCreatePod(2, \"" + name +"\",false," + publish +",\"" + ver +"\",\"\",\"\",{finModel:"+addRes->finModel+", json:"+addRes->json+", tmpl:"+addRes->tmpl+", jslib:"+addRes->jslib+", fin5:"+addRes->fin5+", img:"+addRes->img+"})",
        "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(step == 2) do
    folder: "io/"+name +"Template/"
    str:ioReadFileStr(`fan://j2FinToolsExt/res/podTemplate/extraFuncs.trio`).replace("{{podName}}", name + "Ext")
    recs:readFileTrio(str)
    writeRecs:[]

    if(ioExists(parseUri(folder + "lib/generatedFuncs.trio"))) do
      writeRecs = ioReadTrio(parseUri(folder + "lib/generatedFuncs.trio"))
    end

    r:null
    if(addRes->finModel) do
      models: ioDir(parseUri(folder + "res/models/")).findAll(f=> finFileType(f->uri) == "f5m")
      if(models.size > 0) do
        r= recs.find(rec=> rec->name==(name + "ExtModels"))
        if(r != null and (writeRecs.any(mRec=> mRec->name == r->name) == false))
          writeRecs = writeRecs.add(r.set("src", r->src.replace("{{finModels}}", models.toRecList.map(f=> "{name:\"" + f->name +"\",file:`/finPod/"+ name + "Ext/res/models/" +f->uri.uriName + "`, finModel}").concat(",\n") )))
      end
    end

    if(addRes->tmpl) do
      tmpls: ioDir(parseUri(folder + "res/templates/")).findAll(f=> f->name.endsWith(".f5t"))
      if(tmpls.size > 0) do
        r= recs.find(rec=> rec->name==(name + "ExtTemplates"))
        if(r != null and (writeRecs.any(mRec=> mRec->name == r->name) == false))
          writeRecs = writeRecs.add(r.set("src", r->src.replace("{{finTemplates}}", tmpls.toRecList.map(f=> "{name:\"" + f->name +"\",file:`/finPod/"+ name + "Ext/res/templates/" + f->uri.uriName + "`,finTemplate}").concat(",\n") )))
      end
    end
    if(addRes->json) do
      r= recs.find(rec=> rec->name==(name + "ExtRemoteAssets"))
      if(r != null and (writeRecs.any(mRec=> mRec->name == r->name) == false))
        writeRecs = writeRecs.add(r)
    end
    if(addRes->jslib) do
      r= recs.find(rec=> rec->name==(name + "ExtJSLibs"))
      if(r != null and (writeRecs.any(mRec=> mRec->name == r->name) == false))
        writeRecs = writeRecs.add(r)
    end

    ioWriteTrio(writeRecs, parseUri(folder + "lib/generatedFuncs.trio"))

    body:[
      {name:"lbl",editorType:"label",text:toLocale("j2FinToolsExt::canEditGeneratedFile").replace("{folderPath}",folder + "lib/")},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreCreate"), controlBar: true}
    ]

    return  {
        "dis": toLocale("j2FinToolsExt::createPod"),
        "name": "createPodForm2",
        "body": body.toJSON,
        "cancelButton": "\$cancelButton",
        "commitButton": "\$applyButton",
        "commitAction": "finCreatePod(3, \"" + name +"\",false," + publish +",\"" + ver +"\")",
        "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(step == 3) do

    finCreateTemplatePackage2(parseUri("io/"+name+"Template/"), {name:name+"Ext", version:ver})
    if(publish) do
      body:[
        {name: "username", editorType: "textinput", prompt: toLocale("finStackExt::settingsMenuUsername"),defVal:"acme@acme.com"},
        {name: "password", editorType: "textinput", prompt: toLocale("finStackExt::settingsMenuPassword")},
        {name: "live", editorType: "checkbox", prompt: toLocale("finStackExt::sGridLive"),defVal:false},
        {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
        {name: "applyButton", editorType: "button", label: toLocale("j2FinToolsExt::publish"), controlBar: true}
      ]

      return  {
        "dis": "Publish Pod",
        "name": "createPodForm3",
        "body": body.toJSON,
        "cancelButton": "\$cancelButton",
        "commitButton": "\$applyButton",
        "commitAction": "publishPod(\"" + name + "Ext.pod\",\$username,\$password,\$live)",
        "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
    end
    else finFormAlertOk(toLocale("finStackExt::bLineSuccess"), toLocale("j2FinToolsExt::podCreatedMsg"))
  end
end


def ​

func:finCurWriteHisEditor ​

finCurWriteHisEditor(recs, writemode, conntype) ​

Axon function


meta ​

deffunc:finCurWriteHisEditor
isfunc
liblib:finTools
namefinCurWriteHisEditor

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(recs, writemode, conntype) => do
  recs = readAll(parseFilter(recs)).toRecList()
  from: ""
  to: ""
  if(writemode == "c2w") do
    from = conntype+"Cur"
    to = conntype+toLocale("j2FinToolsExt::write")
    end
  else if(writemode == "w2c") do
    from = conntype+toLocale("j2FinToolsExt::write")
    to = conntype+"Cur"
    end
  else if(writemode == "c2h") do
    from = conntype+"Cur"
    to = conntype+"His"
    end

  out : []
  tmp : null
  obj : {}

  recs.each r => do
    tmp = {id: r->id}
    if(r[from] == null or r[to] == null) do
      if(r[from] == null) tmp = tmp.set(from, from + " isn't set")
      if(r[to] == null) tmp = tmp.set(to, to + " isn't set")
      end
    else do
      tmp = tmp.set(to, r[to])
      tmp = tmp.set(from, r[from])
      tmp = tmp.set(to + "BeforeSet", r[to])
      obj = obj.set(to, r[from])
      r.diff(obj).commit
      tmp = tmp.set(to, r[from])
      end
    out = out.add(tmp)
  end
  out
end


def ​

func:finCustomAhuCreate ​

finCustomAhuCreate(equipRef, equipInfo) ​

Axon function


meta ​

deffunc:finCustomAhuCreate
isfunc
liblib:finTools
namefinCustomAhuCreate

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(equipRef, equipInfo) => do

  csv: readFinToolsCsv(`/lib/equipAhu.csv`)

  tags: {}
  equipInfo.each e => do
      row: csv.find(r => r->description == e->description)
      if (row.has("haystackTags")) split(row->haystackTags, ",") .each(t => tags = tags.set(t, marker()))
      if (row.has("j2Tags"))       split(row->j2Tags, ",")       .each(t => tags = tags.set(t, marker()))
      if (row.has("tagRef"))       split(row->tagRef, ",")       .each(t => tags = tags.set(t + "Ref", @bogusRef))
  end

  commit(diff(readById(equipRef), tags))

  finCustomAhuSelectPoints(equipRef)

end


def ​

func:finCustomAhuCreatePoints ​

finCustomAhuCreatePoints(equipRef, sensorList, cmdList, spList) ​

Axon function


meta ​

deffunc:finCustomAhuCreatePoints
isfunc
liblib:finTools
namefinCustomAhuCreatePoints

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(equipRef, sensorList, cmdList, spList) => do

  ////////////////////////////////////////////////
  // addPoint

  addPoint: (equip, pointName, row) => do

      pointRec: {
        point: marker(),
        cur: marker(),
        disMacro: "\$siteRef \$navName",
        siteRef: equip->siteRef,
        floorRef: equip->floorRef,
        equipRef: equip->id,
        navName: pointName,
        kind: capitalize(row->kind),
        tz: equip->siteRef->tz
      }

      if (row.has("hisCollect")) do
          pointRec = pointRec.set("his", marker())
          if (row->hisCollect == "cov")
              pointRec = pointRec.set("hisCollectCov", marker())
          else do
              pointRec = pointRec.set("hisCollectInterval", parseNumber(row->hisCollect))
          end
      end

      if (row.has("unit"))
          pointRec = pointRec.set("unit", row->unit)
          // TODO set precision based on unit  F.1,kw0,%0, else .1

      if (row.has("enum"))
          pointRec = pointRec.set("enum", row->enum)

      if (row.has("schedulable"))
          pointRec = pointRec.set("schedulable", parseNumber(row->schedulable))

      if (row.has("writable")) do
          pointRec = pointRec.set("writable", marker())
          pointRec = pointRec.set(
              "actions",
              ioWriteZinc(finPointActions(capitalize(row->kind)), ""))
      end

      if (row.has("haystackTags"))
          split(lower(row->haystackTags), " ").each(
              t => pointRec = pointRec.set(t, marker()))

      if (row.has("j2Tags"))
          split(lower(row->j2Tags), " ").each(
              t => pointRec = pointRec.set(t, marker()))

      res: commit(diff(null, pointRec, {add}))

  end

  ////////////////////////////////////////////////
  // addPoints

  addPoints: (csv, equip, pointList) => do

    pointList.each pointDict => do

      pointName: pointDict->j2EquipPointName
      row: csv.find(r => r.has("j2EquipPointName") and r->j2EquipPointName.contains(pointName))

      if (pointDict.has("numVal")) do
         numVal: pointDict->numVal
         numVal.times(n => addPoint(equip, replace(pointName, "##", (n+1).toStr), row))
      else do
        addPoint(equip, pointName, row)
      end

    end
  end

  ////////////////////////////////////////////////
  // main

  csv: readFinToolsCsv(`/lib/equipAhuPoints.csv`)
  equip: readById(equipRef)

  addPoints(csv, equip, sensorList)
  addPoints(csv, equip, cmdList)
  addPoints(csv, equip, spList)

end


def ​

func:finCustomAhuPointProvider ​

finCustomAhuPointProvider(equipRef, pointType, filterPoints) ​

Axon function


meta ​

deffunc:finCustomAhuPointProvider
isfunc
liblib:finTools
namefinCustomAhuPointProvider

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(equipRef, pointType, filterPoints) => do

  //------------------------------------------------
  // check whether a rec matches the given filter
  // TODO: put this in the pod trio file, give docs

  finRecMatchesFilter: (rec, filterStr) => do
    sanitized: replace(filterStr, "return", "\"return\"")
    if(filterStr != "sensor" or filterStr != "cmd" or filterStr != "sp") do
      try
        return ([rec].find(filterToFunc(parseFilter(sanitized)))) != null
      catch(er)
        false
    end
    else
      return rec.has(filterStr)

  end

  //------------------------------------------------
  // turn space-delimited tags into a rec
  // TODO: put this in the pod trio file, give docs

  finTagsToRec: (tagStr) => do
    eval("{" + replace(tagStr, " ", ",") + "}")
  end

  //------------------------------------------------
  // main

  equip: readById(equipRef)

  fromCsv: null

  // filter based on 'equipOn'
  if (filterPoints) do

    fromCsv = readFinToolsCsv(`/lib/equipAhuPoints.csv`).findAll(r =>
        r.has("haystackTags") and
        finRecMatchesFilter(finTagsToRec(r->haystackTags), pointType) and
        r.has("equipOn") and finRecMatchesFilter(equip, r->equipOn))

  // else just send back everything
  end else do

    fromCsv = readFinToolsCsv(`/lib/equipAhuPoints.csv`).findAll(r =>
        r.has("haystackTags") and
        finRecMatchesFilter(finTagsToRec(r->haystackTags), pointType))
  end

  // now create an 'isChecked' column so the list will know whether
  // to check the item or not
  result: []
  fromCsv.each r => do

      if (r.has("typeEquip")) do
          r = r.set("isChecked", finRecMatchesFilter(equip, r->typeEquip))
      end else do
          r = r.set("isChecked", false)
      end

      result = result.add(r)
  end

  return result

end


def ​

func:finCustomAhuSelect ​

finCustomAhuSelect(id, selectedDicts) ​

Axon function


meta ​

deffunc:finCustomAhuSelect
distoLocale("j2FinToolsExt::addCustomAhu")
formOnequip and advanced
isfunc
liblib:finTools
namefinCustomAhuSelect

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id,selectedDicts) => do

  body: [
    {
      name: "equipInfo",
      editorType: "list",
      prompt: toLocale("j2FinToolsExt::selectAhuProps"),
      defValTagName: "selected",
      dataProvider: "readFinToolsCsv(`/lib/equipAhu.csv`)",
      height: 175,
      itemRenderer: [
        {name: "selected", editorType: "checkbox"},
        {name: "description", editorType: "label", text: "\$description"},
      ]
    },
    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    { name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
  ]

  {
     "dis": toLocale("j2FinToolsExt::addCustomAhu"),
     "name": "foo",
     "body": body.toJSON,
     "cancelButton": "\$cancelButton",
     "commitButton": "\$applyButton",
     "commitAction": "finCustomAhuCreate(@" + id + ",\$equipInfo)",
     "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finCustomAhuSelectPoints ​

finCustomAhuSelectPoints(equipRef) ​

Axon function


meta ​

deffunc:finCustomAhuSelectPoints
isfunc
liblib:finTools
namefinCustomAhuSelectPoints

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(equipRef) => do

  body: [
    {
      name: "filterPoints",
      editorType: "checkbox",
      label: toLocale("j2FinToolsExt::filterPtsByEquipType"),
      defVal: true,
      //selectedValue: true
    },
    {
      name: "sensorList",
      editorType: "list",
      prompt: toLocale("j2FinToolsExt::listOfSensorPts"),
      defValTagName: "isChecked",
      dataProvider: "finCustomAhuPointProvider(@" + equipRef + ",\"sensor\",\$filterPoints)",

      height: 175,
      itemRenderer: [
        {name: "selected", editorType: "checkbox"},
        {name: "j2EquipPointName", editorType: "label", text: "\$j2EquipPointName"},
        {name: "numVal", editorType: "numericstepper", minVal: 1, maxVal: 10, enableOn: "numericComponent", width: 75}
      ]
    },
    {
      name: "cmdList",
      editorType: "list",
      prompt: toLocale("j2FinToolsExt::listOfCmdPts"),
      defValTagName: "isChecked",
      dataProvider: "finCustomAhuPointProvider(@" + equipRef + ",\"cmd\",\$filterPoints)",

      height: 175,
      itemRenderer: [
        {name: "selected", editorType: "checkbox"},
        {name: "j2EquipPointName", editorType: "label", text: "\$j2EquipPointName"},
        {name: "numVal", editorType: "numericstepper", minVal: 1, maxVal: 10, enableOn: "numericComponent", width: 75}
      ]
    },
    {
      name: "spList",
      editorType: "list",
      prompt: toLocale("j2FinToolsExt::listOfSpPts"),
      defValTagName: "isChecked",
      dataProvider: "finCustomAhuPointProvider(@" + equipRef + ",\"sp\",\$filterPoints)",

      height: 175,
      itemRenderer: [
        {name: "selected", editorType: "checkbox"},
        {name: "j2EquipPointName", editorType: "label", text: "\$j2EquipPointName"},
        {name: "numVal", editorType: "numericstepper", minVal: 1, maxVal: 10, enableOn: "numericComponent", width: 75}
      ]
    },
    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    { name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
  ]

  {
     "dis": toLocale("j2FinToolsExt::selectCustomAhu"),
     "name": "foo",
     "body": body.toJSON,
     "cancelButton": "\$cancelButton",
     "commitButton": "\$applyButton",
     "commitAction": "finCustomAhuCreatePoints(@" + equipRef + ",\$sensorList,\$cmdList,\$spList)",
     "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})

end


def ​

func:finDelEnumOptForm ​

finDelEnumOptForm(name: null) ​

Axon function


meta ​

appFormOnfolio
deffunc:finDelEnumOptForm
distoLocale("j2FinToolsExt::deleteEnumOpts")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
isfunc
liblib:finTools
namefinDelEnumOptForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(name:null) => do
  body:[]
  enumRec: read(enumMeta,false)
  if(enumRec == null) do
    return {"dis": toLocale("j2FinToolsExt::deleteEnumOpts"),
      "name": "finApplyEnumOptForm0",
      "body": [
        {name:"lbl",editorType:"label", text: toLocale("j2FinToolsExt::configEnumOptsFirst")},
        {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
      ].toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end

  if(name == null) do
    sets : []
    enumRec.each((v,k) => if(k != "id" and k != "dis" and k != "enumMeta" and k != "mod") sets = sets.add({val:k}) )

    body = [
      {name: "name", editorType:"combobox", prompt: toLocale("j2FinToolsExt::optsSetName")+":",
        dataProvider: sets.toJSON, labelField:"val", selectedValueTags:"val", defIndex:0},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]
    {"dis": toLocale("j2FinToolsExt::deleteEnumOpts"),
    "name": "finEditEnumOptForm",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "finDelEnumOptForm(\$name)",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else do
    diff(enumRec,{}.set(name,removeMarker())).commit
    finFormAlertOk(toLocale("j2FinToolsExt::deleteEnumOpts"),toLocale("j2FinToolsExt::enumOptsDeleted"))
  end

end


def ​

func:finDeleteAlarms ​

finDeleteAlarms(dates) ​

Ack/Delete Alarms within the datespan


meta ​

deffunc:finDeleteAlarms
isfunc
liblib:finTools
namefinDeleteAlarms

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finDeleteTopicsCommit ​

finDeleteTopicsCommit(topicList) ​

Axon function


meta ​

deffunc:finDeleteTopicsCommit
deleteTop✓
isfunc
liblib:finTools
namefinDeleteTopicsCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(topicList) => do
  topicNames: ""

  topicList.each topic => do
    topicNames = topicNames + "\n" + topic->dis
    readById(topic).diff({trash}).commit
  end

  finFormAlertOk(toLocale("j2FinToolsExt::deleteTopics"), toLocale("j2FinToolsExt::followingTopicsDeleted") + " " + topicNames)
end


def ​

func:finDeleteTopicsForm ​

finDeleteTopicsForm(fromDbBuilder: false) ​

Axon function


meta ​

appFormOnfolio
deffunc:finDeleteTopicsForm
distoLocale("j2FinToolsExt::deleteTopics")
folderPathtoLocale("finStackExt::userMenuSubscriptions")
isfunc
liblib:finTools
namefinDeleteTopicsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(fromDbBuilder: false) => do
  body:[

    { name: "topicList",
      editorType: "list",
      listType: "checkbox",
      prompt:toLocale("j2FinToolsExt::topics"),
      dataProvider: "readAll(alarmTopic or noteTopic).unique(\"dis\")", //checkthis!!
      labelField: "dis",
      selectedValueTags: "id",
    },

    { name: "cancelButton",
      editorType: "button",
      label: toLocale("finStackExt::cancel"),
      controlBar: true
    },

    { name: "applyButton",
      editorType: "button",
      label: toLocale("finStackExt::delete"),
      controlBar: true
    }
  ]

  { "dis": toLocale("j2FinToolsExt::deleteTopics"),
    "name": "deleteTopics",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finDeleteTopicsCommit(\$topicList)",
    "helpDoc": "/wiki/display/FINStack/Delete+Topics",
  "confirm": toLocale("j2FinToolsExt::deleteTopicConfirmation"),
    "completeAction": if (fromDbBuilder) "try { " + generateFormRefreshCalls("topic", null, true, true)["jsAction"] + " window.app.RefreshBuilderGridAt(0, 'panel'); } catch (err) {}" else removeMarker(),
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finDigestTimeCommit ​

finDigestTimeCommit(alarmTime, noteTime) ​

Axon function


meta ​

deffunc:finDigestTimeCommit
digTime✓
isfunc
liblib:finTools
namefinDigestTimeCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(alarmTime, noteTime) => do
  alarmThing: null
  noteThing: null

  if(alarmTime->on) do
    alarmThing = readAll(ext == "alarm")
    alarmThing.each obj =>
      obj.diff({digestTime: alarmTime->time}).commit
  end
  else do
    alarmThing = readAll(ext == "alarm")
    alarmThing.each obj =>
      obj.diff({-digestTime}).commit
  end

  if(noteTime->on) do
    noteThing = readAll(ext == "note")
    noteThing.each obj =>
      obj.diff({digestTime: noteTime->time}).commit
  end
  else do
    noteThing = readAll(ext == "note")
    noteThing.each obj =>
      obj.diff({-digestTime}).commit
  end
end


def ​

func:finDigestTimeSettingsForm ​

finDigestTimeSettingsForm() ​

Axon function


meta ​

appFormOnfolio
deffunc:finDigestTimeSettingsForm
digTime✓
distoLocale("j2FinToolsExt::digestTimeSetting")
formOnuser
isfunc
liblib:finTools
namefinDigestTimeSettingsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  hours: [{val: 0, dis:"12 AM", str:"0hr"},{val: 1, dis:"1 AM", str:"1hr"},{val: 2, dis:"2 AM", str:"2hr"},{val: 3, dis:"3 AM", str:"3hr"},{val: 4, dis:"4 AM", str:"4hr"},{val: 5, dis:"5 AM", str:"5hr"},
          {val: 6, dis:"6 AM", str:"6hr"},{val: 7, dis:"7 AM", str:"7hr"},{val: 8, dis:"8 AM", str:"8hr"},{val: 9, dis:"9 AM", str:"9hr"},{val: 10, dis:"10 AM", str:"10hr"},{val: 11, dis:"11 AM", str:"11hr"},
          {val: 12, dis:"12 PM", str:"12hr"},{val: 13, dis:"1 PM", str:"13hr"},{val: 14, dis:"2 PM", str:"14hr"},{val: 15, dis:"3 PM", str:"15hr"},{val: 16, dis:"4 PM", str:"16hr"},{val: 17, dis:"5 PM", str:"17hr"},
          {val: 18, dis:"6 PM", str:"18hr"},{val: 19, dis:"7 PM", str:"19hr"},{val: 20, dis:"8 PM", str:"20hr"},{val: 21, dis:"9 PM", str:"21hr"},{val: 22, dis:"10 PM", str:"22hr"},{val: 23, dis:"11 PM", str:"23hr"}]
  minutes:[{val: 0, dis:"00", str: "0min"},{val: 5, dis:"05", str: "5min"},{val: 10, dis:"10", str: "10min"},{val: 15, dis:"15", str: "15min"},
           {val: 20, dis:"20", str: "20min"},{val: 25, dis:"25", str: "25min"},{val: 30, dis:"30", str: "30min"},{val: 35, dis:"35", str: "35min"},
           {val: 40, dis:"40", str: "40min"},{val: 45, dis:"45", str: "45min"},{val: 50, dis:"50", str: "50min"},{val: 55, dis:"55", str: "55min"}]

  alarms: readAll(ext=="alarm")
  notes: readAll(ext=="note")
  alarmOn: false
  alarmMinIndex: 0
  alarmHrIndex: 0
  noteOn: false
  noteMinIndex: 0
  noteHrIndex: 0

  if(alarms.size > 0 and alarms[0].has("digestTime")) do
    alarmOn = true
    alarmMinIndex =  minutes.index(minutes.find(v => v->str == readAll(ext =="alarm")[0]->digestTime.minute.toStr))
    alarmHrIndex = hours.index(hours.find(v => v->str == readAll(ext =="alarm")[0]->digestTime.hour.toStr))
  end

  if(notes.size > 0 and notes[0].has("digestTime")) do
    noteOn = true
    noteMinIndex =  minutes.index(minutes.find(v => v->str == readAll(ext =="note")[0]->digestTime.minute.toStr))
    noteHrIndex = hours.index(hours.find(v => v->str == readAll(ext =="note")[0]->digestTime.hour.toStr))
  end

  body:[
    { name: "alarmSep",
      editorType: "separator",
      text: toLocale("j2FinToolsExt::alarmDigestTime"),
    },

    { name: "alarmCheck",
      editorType: "checkbox",
      label: toLocale("j2FinToolsExt::setAlarmDigestTime"),
      defVal: alarmOn
    },

    { name: "alarmHour",
      editorType: "combobox",
      prompt:toLocale("finStackExt::hour"),
      dataProvider: hours.toAxonCode,
      labelField: "dis",
      selectedValueTags: "val",
      defIndex: alarmHrIndex
    },

    { name: "alarmMin",
      editorType: "combobox",
      prompt:toLocale("j2FinToolsExt::minutesCapital"),
      dataProvider:minutes.toAxonCode,
      labelField: "dis",
      selectedValueTags: "val",
      defIndex: alarmMinIndex
    },

    { name: "noteSep",
      editorType: "separator",
      text: toLocale("j2FinToolsExt::noteDigestTime"),
    },

    { name: "noteCheck",
      editorType: "checkbox",
      label: toLocale("j2FinToolsExt::setNoteDigestTime"),
      defVal: noteOn
    },

    { name: "noteHour",
      editorType: "combobox",
      prompt:toLocale("j2FinToolsExt::hoursCapital"),
      dataProvider:hours.toAxonCode,
      labelField: "dis",
      selectedValueTags: "val",
      defIndex:noteHrIndex
    },

    { name: "noteMin",
      editorType: "combobox",
      prompt:toLocale("j2FinToolsExt::minutesCapital"),
      dataProvider:minutes.toAxonCode,
      labelField: "dis",
      selectedValueTags: "val",
      defIndex: noteMinIndex
    },

    { name: "cancelButton",
      editorType: "button",
      label: toLocale("finStackExt::cancel"),
      controlBar: true
    },

    { name: "applyButton",
      editorType: "button",
      label: toLocale("finStackExt::coreApply"),
      controlBar: true
    }
  ]

  { "dis": toLocale("j2FinToolsExt::digestTimeSetting"),
    "name": "tuningPolicy",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finDigestTimeCommit({on: \$alarmCheck, time: time(\$alarmHour, \$alarmMin)}, {on: \$noteCheck, time: time(\$noteHour, \$noteMin)})",
    "helpDoc": "/wiki/display/FINStack/Daily+Digest+Time",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finDistinctConnRefs ​

finDistinctConnRefs(filter) ​

Read all the distinct conn ref connectors


meta ​

deffunc:finDistinctConnRefs
isfunc
liblib:finTools
namefinDistinctConnRefs

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finDownloadSavedRecordsForm ​

finDownloadSavedRecordsForm(stage: null, data: null) ​

Axon function


meta ​

appFormOnfolio
deffunc:finDownloadSavedRecordsForm
distoLocale("j2FinToolsExt::downloadSavedRecs")
folderPathtoLocale("j2FinToolsExt::createBatchRecords")
formOnsite or floor or equip or (point and not schedule)
isfunc
liblib:finTools
namefinDownloadSavedRecordsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, data: null) => do
  if(stage == null) do
    body: [
      {name: "file", editorType: "combobox", prompt: toLocale("j2FinToolsExt::recToDownload")+":", labelField: "val", selectedValueTags: "val", defIndex: 0,
        dataProvider: "ioDir(`io/`).findAll(x=> x->name.contains(\"Libraries\")).colToList(\"uri\").map(x=> ioDir(x).colToList(\"uri\").concat(\"\\n\")).concat(\"\\n\").split(\"\\n\")"},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]

    {"dis": toLocale("j2FinToolsExt::downloadSavedRecs"),
    "name": "finDownloadSavedRecords",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "finDownloadSavedRecordsForm(1,\$file)",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end else if(stage == 1) do
    fname: data.split("/")[-1]
    data = data.parseUri

    fil: diff(null, {dis:fname}, {add}).commit
    fil = finWriteBinTag(fil, "file", data, "application/octet-stream")

    body: [
      {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::fileReadyToDownload").replace("{name}", fname)},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::reportsDownload"), controlBar: true}
    ]

    {"dis": toLocale("j2FinToolsExt::downloadSavedRecs"),
    "name": "finDownloadSavedRecords1",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "null",
    "completeAction": "window.open((finstack.pathPrefix || '')+'/finGetFile/"+context()->projName+"?fileRef=@"+fil->id+"','_blank')",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finDuplicateRec ​

finDuplicateRec(id, countTimes: 1, excludeChildren: false) ​

Duplicates a record and it's children countTimes. If excludeChildren is true, it will only duplicate the record and not it's children.


meta ​

constructfinDuplicateRec(idRec)
deffunc:finDuplicateRec
helpUse this function to duplicate equips and cover mixed HI...
isfunc
liblib:finTools
namefinDuplicateRec

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, countTimes: 1, excludeChildren: false) => do
  metaDict: {dupCount: countTimes}
  if (excludeChildren)
    metaDict = metaDict.merge({shallow})

  return toRec(id).toGrid.setMeta(metaDict).recDup
end


def ​

func:finEditDescriptionForm ​

finEditDescriptionForm(id) ​

Form to edit description, takes id


meta ​

deffunc:finEditDescriptionForm
distoLocale("j2FinToolsExt::editDescription")
formOndescription
isfunc
liblib:finTools
namefinEditDescriptionForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  id = id.toRec
  if(id.has("description")) dval: id->description
  else dval: ""

  body: [
    {name: "desc", editorType: "textinput", prompt: toLocale("finStackExt::hostDescription"), defVal: dval},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {
    "dis":toLocale("j2FinToolsExt::editDescription"),
    "name":"finEditDescriptionForm",
    "body":body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "readById(@"+id->id+").diff({description: \$desc}).commit",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finEditEnumOptForm ​

finEditEnumOptForm() ​

Axon function


meta ​

appFormOnfolio
deffunc:finEditEnumOptForm
distoLocale("j2FinToolsExt::editEnumOpts")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
isfunc
liblib:finTools
namefinEditEnumOptForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body:[]
  enumRec: read(enumMeta,false)
  if(enumRec == null) do
    return {"dis": toLocale("j2FinToolsExt::editEnumOpts"),
      "name": "finApplyEnumOptForm0",
      "body": [
        {name:"lbl",editorType:"label", text: toLocale("j2FinToolsExt::configEnumOptsFirst")},
        {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
      ].toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$commitButton",
      "commitAction": "",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end

  sets : []
  enumRec.each((v,k) => if(k != "id" and k != "dis" and k != "enumMeta" and k != "mod") sets = sets.add({val:k}) )

  body = [
    {name: "name", editorType:"combobox", prompt: toLocale("j2FinToolsExt::optsSetName")+":",
      dataProvider: sets.toJSON, labelField:"val", selectedValueTags:"val", defIndex:0},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
  ]
  {"dis": toLocale("j2FinToolsExt::editEnumOpts"),
  "name": "finEditEnumOptForm",
  "body": body.toJSON,
  "cancelButton": "\$cancelButton",
  "commitButton": "\$commitButton",
  "commitAction": "finEnumOptForm(1,{name:\$name, edit:true})",
  "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})

end


def ​

func:finEditNoteTagsCommit ​

finEditNoteTagsCommit(tagsToRemove, tagsToAdd) ​

This function is used by the "Edit Note Tags" form. It applies user defined changes to the noteTags obj/string.


meta ​

deffunc:finEditNoteTagsCommit
isfunc
liblib:finTools
namefinEditNoteTagsCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(tagsToRemove, tagsToAdd) => do
  noteTagsObj: read(noteTags)
  currentStr: noteTagsObj->noteTags
  newStr: ""

  tagsToRemove.sortr((x,y)=> if(x.size > y.size) 1 else -1).each x => currentStr = currentStr.replace(x, "")
  currentStr.split(",").each x => if(not x.isEmpty) newStr = newStr + x + ","
  try newStr = newStr[0..-2]
  catch ""

  tagsToAdd.split(",").each x => if(not x.isEmpty) newStr = newStr + "," + x

  noteTagsObj.diff({noteTags: newStr}).commit
end


def ​

func:finEditNoteTagsForm ​

finEditNoteTagsForm() ​

This form allows the user to add or remove existing tags from the noteTags list.


meta ​

appFormOnnotes
deffunc:finEditNoteTagsForm
distoLocale("j2FinToolsExt::editNoteTags")
helpAdd or remove existing tags from the noteTags list.
isfunc
liblib:finTools
namefinEditNoteTagsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  currentTip: "Remove a tag by checking the box next it."
  newTip: "Enter in a comma separated list of new tags to add. Ex: hvac, lighting, emergency"

  body:[
    { name: "currentTags",
      editorType: "list",
      prompt: toLocale("j2FinToolsExt::currentNoteTags") + ":",
      listType: "checkbox",
      dataProvider: "read(noteTags)->noteTags.split(\",\").map(row => {dis: row})",
      labelField: "dis",
      selectedValueTags: "dis",
      toolTip: currentTip
    },

    { name: "newTags",
      editorType: "textinput",
      prompt: toLocale("j2FinToolsExt::enterNewTags") + ":",
      toolTip: newTip
    },

    { name: "cancelButton",
      editorType: "button",
      label: toLocale("finStackExt::cancel"),
      controlBar: true
    },

    { name: "applyButton",
      editorType: "button",
      label: toLocale("finStackExt::coreApply"),
      controlBar: true
    }
  ]

  { "dis": toLocale("j2FinToolsExt::editNoteTags"),
  "name": "editNoteTags",
  "body": body.toJSON,
  "cancelButton": "\$cancelButton",
  "commitButton": "\$applyButton",
  "commitAction": "finEditNoteTagsCommit(\$currentTags, \$newTags)",
  "helpDoc": "/wiki/display/FINStack/Edit+Note+Tags",
  "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finEditSummaryCommit ​

finEditSummaryCommit(summaryId, newName, newSumOn, newEquipFilter, newPointFilter) ​

Axon function


meta ​

deffunc:finEditSummaryCommit
editSum✓
isfunc
liblib:finTools
namefinEditSummaryCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(summaryId, newName, newSumOn, newEquipFilter, newPointFilter) => do
  fixedPoints: ""

  each(newPointFilter) (point, i) => do
    if(i != (newPointFilter.size - 1))
      fixedPoints = fixedPoints + "(navName == \"" + point + "\") or "
    else
      fixedPoints = fixedPoints + "(navName == \"" + point + "\")"
  end

  readById(summaryId).diff({dis: newName, summaryOn: newSumOn, equipFilter: newEquipFilter, pointFilter: fixedPoints}).commit
end


def ​

func:finEditSummaryForm ​

finEditSummaryForm(summaryInfo, selected: null) ​

Axon function


meta ​

deffunc:finEditSummaryForm
editSum✓
isfunc
liblib:finTools
namefinEditSummaryForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(summaryInfo, selected: null) => do
  brokenFilter: summaryInfo->equipFilter.replace(" and ", " & ").split("&")
  newFilter:""
  endOfFilter: ""

  brokenFilter.each x => if(not x.contains("Ref")) newFilter = newFilter + x + " and " else endOfFilter = x
  //echo(endOfFilter)

  body:[
    { name:"editName",
      editorType:"textinput",
      prompt:toLocale("j2FinToolsExt::editSumName"),
      defVal: summaryInfo.dis
    },

    { listType:"checkbox",
      labelField:"val",
      name:"pointFilter",
      dataProvider:summaryInfo->pointFilter.replace(" or ", " | ").replace("(navName ==", "").replace(")", "").replace("\"", "").split("|").toAxonCode,
      defValTagName: "val",
      editorType:"list",
      prompt:toLocale("finStackExt::pointFilter"),
      selectedValueTags:"val"
    },

    { name:"equipFilterPicker",
      editorType:"filter",
      prompt:toLocale("j2FinToolsExt::equipFilter"),
      defVal: summaryInfo->equipFilter //newFilter[0..-6]
    },

    { name:"cancelButton", editorType:"button", label:toLocale("finStackExt::cancel"), controlBar:true},
    { name:"commitButton", editorType:"button", label:toLocale("finStackExt::coreApply"), controlBar:true}]

  if(selected == null) body = body.insert(1,{ name:"editSumOn",
      editorType:"filter",
      prompt:toLocale("j2FinToolsExt::editSumOn"),
      defVal: summaryInfo->summaryOn
    })
  else body = body.insert(1,{ name:"editSumOn",
      editorType:"filter",
      prompt:toLocale("j2FinToolsExt::editSumOn"),
      defVal: summaryInfo->summaryOn,
      config: {recordFilter:"id=="+selected.toAxonCode}
    })

  { "dis":toLocale("j2FinToolsExt::editSummaryFormTitle"),
    "name":"finEditSummaryForm",
    "body":body.toJSON,
    "width": 450,
    "cancelButton": "\$cancelButton",
    "commitButton":"\$commitButton",
    "commitAction":  "finEditSummaryCommit(" + summaryInfo->id.toAxonCode + ",\$editName, \$editSumOn, \$equipFilterPicker, \$pointFilter)",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finEditSummaryPickForm ​

finEditSummaryPickForm() ​

Axon function


meta ​

deffunc:finEditSummaryPickForm
distoLocale("j2FinToolsExt::editSummaryFormTitle")
editSum✓
folderPathtoLocale("finStackExt::rightMenuSummaryTitle")
formOnequip
hideFromMobileDB✓
isfunc
liblib:finTools
namefinEditSummaryPickForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  summaryName: "readById(\$summaryList).dis"
  body:[
    {
      name:"summaryList",
      dataProvider:"readAll(summaryOn)",
      editorType:"list",
      prompt:toLocale("j2FinToolsExt::summaryToEdit")+":",
      labelField:"dis",
      //selectedValueTags:"id",
      defIndex: 0
    },

    { name:"cancelButton", editorType:"button", label:toLocale("finStackExt::cancel"), controlBar:true},
    { name:"commitButton", editorType:"button", label:toLocale("finStackExt::next"), controlBar:true}
  ]

  { "dis":toLocale("j2FinToolsExt::editSummaryFormTitle"),
    "name":"finEditSummaryPickForm",
    "body":body.toJSON,
    "width": 450,
    "cancelButton": "\$cancelButton",
    "commitButton":"\$commitButton",
    "commitAction": "finEditSummaryForm(\$summaryList)",
    "helpDoc": "/wiki/display/FINStack/Edit+Summary",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finEditTags ​

finEditTags(id: null, tags: null, stage: null) ​

finEditTags(id, tags)

Form to edit the tags of a record.

Usage:

finEditTags(@12341234-12341234, ["dis","name"])

meta ​

deffunc:finEditTags
distoLocale("finStackExt::folioMenuEditTags")
isfunc
liblib:finTools
namefinEditTags
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id:null, tags:null, stage:null) => do
  id = id.toRecList[0]

  if(stage == null) do
    tags = tags.map(x=> x.toTagName)

    body: [
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    comAct: "finEditTags(@"+id->id+",{"

    y: ""
    cou: 0
    id.names.sort.unique.findAll(x=> index(["id","mod"],x) == null).findAll(x=> tags.index(x) != null or tags.index("all") != null).each x=> do
      y = id.trap(x)
      if(y.isDateTime) do
        body = body.add({name: cou+x, editorType: "textinput", prompt: toLocale("finStackExt::folioQueryDateTime")+": "+x, defVal: y.format("MMM D, YYYY @ k:mm:ss AA zzz")})
        comAct = comAct + x + "_datetime: \$" + cou+x + ", "
      end
      else if(y.isNumber) do
        body = body.add({name: cou+x, editorType: "numericstepper", prompt: toLocale("finStackExt::number")+": "+x, defVal: y})
        comAct = comAct + x + "_number: \$" + cou+x + ", "
      end
      else if(y.isBool) do
        body = body.add({name: cou+x, editorType: "combobox", prompt: toLocale("finStackExt::boolean")+": "+x, labelField: "a", selectedValueTags: "b",
          dataProvider: "[{a:\"True\",b:true},{a:\"False\",b:false}]", defIndex: index([true,false], y)})
        comAct = comAct + x + "_bool: \$" + cou+x + ", "
      end
      else if(y.isRef) do
        tmp: readAll(parseFilter(x.replace("Ref",""))).toRecList.map(a=> {id:a->id, dis:a.dis})
          .sort((a,b)=> a->dis <=> b->dis).sort((a,b)=> if(a->id==y) -1 else 0)
        if(y.readById.has("schedule") and y.readById.has("kind"))
          tmp = tmp.findAll(a=> a->id.readById.has("kind") and a->id.readById->kind==y.readById->kind)
        if(tmp.size == 0) body = body.add({name: cou+x, editorType: "filter", prompt: toLocale("finStackExt::folioQueryRef")+": "+x, defVal: "id==@"+y})
        else body = body.add({name: cou+x, editorType: "combobox", prompt: toLocale("finStackExt::folioQueryRef")+": "+x,
          dataProvider: tmp.toAxonCode, labelField: "dis", selectedValueTags: "id", defIndex: 0})
        comAct = comAct + x + "_ref: \$" + cou+x + ", "
      end
      else if(y.isStr) do
        if(y.size > 40) body = body.add({name: cou+x, editorType: "textarea", prompt: toLocale("finStackExt::string")+": "+x, defVal: y})
        else body = body.add({name: cou+x, editorType: "textinput", prompt: toLocale("finStackExt::string")+": "+x, defVal: y})
        comAct = comAct + x + "_str: \$" + cou+x + ", "
      end
      else if(y.isUri) do
        body = body.add({name: cou+x, editorType: "textinput", prompt: toLocale("finStackExt::folioFilesURI")+": "+x, defVal: y.toStr})
        comAct = comAct + x + "_uri: \$" + cou+x + ", "
      end
      else if(y == marker()) do
        body = body.add({name: cou+x, editorType: "textinput", prompt:  toLocale("finStackExt::marker")+": "+x, defVal: x})
        comAct = comAct + x + "_marker: \$" + cou+x + ", "
      end
      cou = cou + 1
    end

    if(cou == 0) body = body.add({name: "label", editorType: "separator", label:toLocale("j2FinToolsExt::noMatchingTagsFound")})

    if(tags.index("applyBatchTags") != null or cou == 0) do
      body = body.add({name: cou+"applyBatchTags", editorType: "textinput", prompt: toLocale("finStackExt::gbApplyBatchTags")+":", defVal: ""})
      comAct = comAct + "applyBatchTags: \$"+cou+"applyBatchTags, "
    end

    comAct = comAct[0..-3] + "},2)"

    {"dis": toLocale("finStackExt::folioMenuEditTags"),
    "name": "finEditTags",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": comAct,
    "helpDoc": "/wiki/display/FINStack/Edit+Tags+Form",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(stage == 2) do
    type: ""
    newdict: {}
    tags.each()(y,x)=> do
      x = x.split("_")
      type = x[-1]
      x = x[0..-2].concat("_")
      if(type == "applyBatchTags") try newdict = eval("{"+y+"}").merge(newdict) catch 0
      else if(type == "datetime") try newdict = newdict.set(x, parseDateTime(y,"MMM D, YYYY @ k:mm:ss AA zzz")) catch 0
      else if(type == "number") do
        if(id.trap(x).unit != null) y = parseNumber(y+id.trap(x).unit)
        newdict = newdict.set(x, y)
      end
      else if(type == "marker") do
        if(y[0..0] == "-") do
          newdict = newdict.set(x, removeMarker())
        end
        else do
          y = y.toTagName
          if(x != y) newdict = newdict.set(x,removeMarker()).set(y,marker())
        end
      end
      else if(type == "bool") newdict = newdict.set(x, y)
      else if(type == "ref") try newdict = newdict.set(x, read(parseFilter(y))->id) catch  newdict = newdict.set(x, y)
      else if(type == "str") newdict = newdict.set(x, y)
      else if(type == "uri") newdict = newdict.set(x, parseUri(y))
    end
    readById(id->id).diff(newdict).commit
  end
end


def ​

func:finEditTopicsForm ​

finEditTopicsForm() ​

A form that allows the user to select an alarm or note topic to edit. The form calls the create form and passes the selected topic to that form.


meta ​

appFormOnfolio
deffunc:finEditTopicsForm
distoLocale("j2FinToolsExt::editTopics")
folderPathtoLocale("finStackExt::userMenuSubscriptions")
helpEdit existing alarm and note topics.
isfunc
liblib:finTools
namefinEditTopicsForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body:[{ name: "topicCombo",
          editorType: "combobox",
          prompt: toLocale("j2FinToolsExt::chooseTopic"),
          dataProvider: "readAll(noteTopic or alarmTopic)",
          labelField: "dis",
          selectedValueTags: "id",
          toolTip: toLocale("j2FinToolsExt::selectTopic")
          },

        { name: "cancelButton",
          editorType: "button",
          label: toLocale("finStackExt::cancel"),
          controlBar: true},

        { name: "applyButton",
          editorType: "button",
          label: toLocale("finStackExt::next"),
          controlBar: true}]

  { "dis": toLocale("j2FinToolsExt::editNoteAlarmTopic"),
    "name": "editTopics",
    "body": body.toJSON,
    "width": 400,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finEditTopicsFormCommit(\$topicCombo)",
    "helpDoc": "/wiki/display/FINStack/Edit+Topics",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finEditTopicsFormCommit ​

finEditTopicsFormCommit(topicId) ​

Axon function


meta ​

deffunc:finEditTopicsFormCommit
isfunc
liblib:finTools
namefinEditTopicsFormCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(topicId) => do
  if(readById(topicId).has("alarmTopic"))
    finCreateAlarmTopicForm(topicId)
  else if(readById(topicId).has("noteTopic"))
    finCreateNoteTopicForm(topicId)
end


def ​

func:finEnumOptForm ​

finEnumOptForm(stage: null, data: null) ​

Axon function


meta ​

appFormOnfolio
deffunc:finEnumOptForm
distoLocale("j2FinToolsExt::createEnumOpts")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
isfunc
liblib:finTools
namefinEnumOptForm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null,data:null) => do

  body:[]

  if(stage == null) do
    body = [
      {name: "name", editorType:"textinput", prompt: toLocale("finStackExt::gbName")+":"},
      {name: "numberOpts", editorType:"numericstepper",minVal:1,prompt:toLocale("j2FinToolsExt::numOptions")+":"},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]
    {"dis": toLocale("j2FinToolsExt::numberToEnum"),
    "name": "finEnumOptForm",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "finEnumOptForm(1,{name:\$name, number:\$numberOpts, edit:false})",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(stage == 1) do
    nameVal: data->name.toTagName
    enumRec: read(enumMeta,false)
    number: try data->number catch 0

    if(enumRec == null) do
      diff(null,{enumMeta},{add}).commit
      enumRec = read(enumMeta)
    end

    existing:[]
    if(data->edit) do
      existing = enumRec.trap(nameVal).ioReadZinc.toRecList.map(r => {name:r->name,code:r->code})
      number = existing.size
    end

    body = [
      {name: "lbl", editorType:"label", text: toLocale("finStackExt::folioMenuOptions")}
    ]
    obj : []

    number.times (idx => do
      body= body.add(
        {name:"group"+ idx.toStr.padl(3,"0"), editorType:"group",horizontal:true, groupName:toLocale("finStackExt::enum")+ idx.toStr.padl(3,"0"),children:[
          {name: "order"+ idx.toStr.padl(3,"0"), editorType:"numericstepper",defVal: if(idx < existing.size) existing[idx]->code else idx, minVal:-10,prompt:toLocale("j2FinToolsExt::code")},
          {name:"opt"+ idx.toStr.padl(3,"0"), editorType:"textinput", defVal: if(idx < existing.size) existing[idx]->name else "e"+ idx.toStr.padl(3,"0"),prompt:toLocale("finStackExt::gbName")}
        ]}
      )
      obj = obj.add("{code:\$order" + idx.toStr.padl(3,"0") + ",name:\$opt" + idx.toStr.padl(3,"0") + "}")
    end)

    body = body.addAll([
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "commitButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ])

    {"dis": toLocale("j2FinToolsExt::numberToEnum"),
    "name": "finEnumOptForm1",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "read(enumMeta).diff({\""+ nameVal +"\": [" + obj.concat(",") + "].ioWriteZinc(\"\")}).commit",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end

end


def ​

func:finExcelRowPaster ​

finExcelRowPaster() ​

Axon function


meta ​

deffunc:finExcelRowPaster
distoLocale("j2FinToolsExt::excelRowPaster")
formOnid
hideMobile✓
isfunc
liblib:finTools
namefinExcelRowPaster
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do

  //// The goal of this function is to be able to show a table at the top, that the user can right click and hit copy
  //// Then the user can paste it into Excel and they would see what Columns they need to edit. Then the user will copy it back from Excel
  //// The bottom Data grid will then let the user paste it into it. When you hit copy it will then go create all the sites.
  //// If the user includes more tags on the sites then include those too. IE... IF they have address, etc... Then add those
  //// Need a funciton that will take this data and create all tags. IE>.. For Area need to a the SqFt unit tag on the number.

  copyTableData: [{dis:"Fav Site",geoAddr:"14422 My Site Add",area:2800}]

  body: [
    {
      name: "table",
      editorType: "table",
      copyFrom: marker(),
      prompt: toLocale("j2FinToolsExt::ctrlCToCopy"),
      height:50,
      dataProvider:copyTableData.toAxonCode,
      //toolTip:"Right click on this grid and click copy. Then paste this into Excel and edit it. After that copy it from excel and paste below."},
    },
    {
      name: "pastedData",
      editorType: "table",
      pasteTo: marker(),
      prompt: toLocale("j2FinToolsExt::pasteExcelTagger"),
      height: 150
    },

    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true },
    { name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true }
  ]

  {
     "dis": toLocale("j2FinToolsExt::createMultiRows"),
     "name": "manualAhu",
     "body": body.toJSON,
     "cancelButton": "\$cancelButton",
     "commitButton": "\$applyButton",
     "commitAction": "finCopyTableData(\$pastedData)",
    // "confirm": "This will change things, are you sure?",
     "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finExcelSite ​

finExcelSite() ​

Axon function


meta ​

appFormOnbuilder
deffunc:finExcelSite
distoLocale("j2FinToolsExt::createSiteFromExcel")
folderPathtoLocale("finStackExt::advanced")
formOnregion
helpUses Excel to edit or create sites. You can copy the dat...
hideMobile✓
isfunc
liblib:finTools
namefinExcelSite

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do

  copyTableData: [{
    dis:"Favorite Site",
    area:10000,
    geoCountry: "United States",
    geoAddr:"123 Main St",
    geoCity:"Springfield",
    geoState:"CA",
    geoPostalCode:"12345",
    tz:"Los_Angeles",
  }]

  body: [
    {
      name: "table",
      editorType: "table",
      copyFrom: marker(),
      prompt: toLocale("j2FinToolsExt::ctrlCToCopy"),
      height:100,
      dataProvider:copyTableData.toAxonCode,
      //toolTip:"Right click on this grid and click copy. Then paste this into Excel and edit it. After that copy it from excel and paste below."
    },
    {
      name: "pastedData",
      editorType: "table",
      pasteTo: marker(),
      prompt: toLocale("j2FinToolsExt::pasteExcelTagger"),
      height:150},
    {
      name: "cancelButton",
      editorType: "button",
      label: toLocale("finStackExt::cancel"),
      controlBar: true},
    {
      name: "applyButton",
      editorType: "button",
      label: toLocale("finStackExt::coreApply"),
      controlBar: true}
  ]

  {
     "dis": toLocale("j2FinToolsExt::createSiteFromExcel"),
     "name": "manualAhu",
     "body": body.toJSON,
     "cancelButton": "\$cancelButton",
     "commitButton": "\$applyButton",
     "commitAction": "finCommitSites(\$pastedData)",
     "gotoAction": "finstack:folio:axonQuery=readAll(site)",
     "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finExec ​

finExec(src: null, globals: null, returnUpdated: false) ​

This will parse trio file into records then look for "function" tag in each record, then it will execute the function tag expression on the corresponding record. It is sinmilar to funcTemplate

Example function tag:

function: sampleFunc($this, $vendorName)
function: bacnetWriteProperty($connector,$object,$value)

Notice, the $ notation, those are auto-bind vars, $this is a special var that points to the current trio record, $vendorName binds to the current trio record's vendorName tag.

1st parameter is a Uri or a Dict[]. it can be null to use default value 2nd parameter is a Dict for vars' values look-up 3rd parameter updateFile set to true to write all updated records back to original trio file

Example:

finExec(<io/propertiesExec.trio>,{connector:@connectorId},false) finExec(<io/propertiesExec.trio>,null,true)


meta ​

constructfinExec(io/propertiesExec.trio,null,true)
deffunc:finExec
isfunc
liblib:finTools
namefinExec

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finExistingConnectors ​

finExistingConnectors(selectedIds, connType: null) ​

Axon function


meta ​

deffunc:finExistingConnectors
isfunc
liblib:finTools
namefinExistingConnectors

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(selectedIds, connType: null) => do

  recList : finSelectedPoints(selectedIds)

  connMap: {}
  recList.each rec => do
    rec.each((v,k) => do
      if (endsWith(k, "ConnRef")) do // and (connType == null or k.contains(connType))
        connMap = connMap.set(v.toAxonCode, finRefDis(v))
      end
    end)
  end

  connList: []
  connMap.each((v,k) => connList = connList.add({"id":k,"dis":v}))

  if(connList.isEmpty)
    connList = connList.add({id:@null, dis: toLocale("j2FinToolsExt::noConnectorsFound")})

  return connList.toGrid()
end


def ​

func:finExtraCountSystems ​

finExtraCountSystems(rec) ​

Axon function


meta ​

constructreadById(@1a17d84c-5853a4d5).finExtraCountSystems()
deffunc:finExtraCountSystems
helpThis function is mainly used for mobile. It will take an...
isfunc
liblib:finTools
namefinExtraCountSystems

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(rec) => do
    recId: rec->id
  alarms:rec.alarms(today).size()
  notes:navFilter("noteTarget", recId, null).notes({  }).noteSummary.size()
  relatedRefs:readById(recId).finElementOn("graphic").size()
  summary:rec.finElementOn("summary").size()

  [
        {count:alarms,
         text:"alarms"
                      },
        {count:notes,
         text:"notes"
                      },
        {count:relatedRefs,
         text:"relatedRefs"
                      },
        {count:summary,
         text:"summary"
                      }
        ]

end


def ​

func:finFileType ​

finFileType(ioFile) ​

Axon function


meta ​

deffunc:finFileType
isfunc
liblib:finTools
namefinFileType
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ioFile) => do
  val:null
  try do
    list: ioZipDir(ioFile)
    if(list.find(f=> f->path.uriName == "view.html") != null and ioFile.uriExt == "f5m")
      val= "f5m"
    if(list.find(f=> f->path.uriName == "records.zinc") != null)
      val= "fst"
  end
  catch(err) echo(err.toStr)

  return val
end


def ​

func:finFindAnyText ​

finFindAnyText(grid, searchString) ​

Axon function


meta ​

constructfinFindAnyText("ahu city 1")
deffunc:finFindAnyText
helpTakes a grid, IE... readAll(site or equip).finFIndAnyTex...
isfunc
liblib:finTools
namefinFindAnyText

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(grid, searchString) =>
do
   searchList: searchString.lower.split(" ")

    return grid.findAll(row =>
                        do
                          return row.any((value, tagName) =>
                                    do
                                        if (value.isRef)
                                           searchList.all(test => row.dis(tagName).lower.contains(test))
                                        else
                                          return searchList.all(test => value.toStr.lower.contains(test))
                                    end)
                        end)
end


def ​

func:finFindBadChartPts ​

finFindBadChartPts(points) ​

Axon function


meta ​

deffunc:finFindBadChartPts
isfunc
liblib:finTools
namefinFindBadChartPts
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(points) => do
  hasBadId: if(points.find(v => not v.has("id")) != null) true else false
  allBad: if(hasBadId and points.findAll(v => v.has("id")).size == 0) true else false

  if(allBad) return null
  else if(hasBadId) do
    charts: readAll(chartOn).findAll(v => v->savedChart.startsWith("readByIds")).toRecList.map(r => reFind(r"\[[^{}]*\]", r->savedChart)[1..-2])
    ids: points.findAll(v => v.has("id")).toRecList.map(r => r->id)

    charts = charts.findAll(v => do
      v.split(",").size == points.size and ids.map(r => if(v.contains(r.toStr)) "true" else "false").concat(" and ").eval
    end)

    charts = charts.map(r => do
      r = r.split(",")
      r = r.findAll(z => not ids.contains(z[1..-1].parseRef))

      //r
    end).findAll(v => v.size == (points.size - ids.size))

    if(charts.size == 1) charts = charts[0].map(r => r.toAxonCode).concat(",")
    else if(charts.size > 0)
      charts.find(v => do
        reading: try readByIds(v) catch null

        reading == null
      end)[0]
    else charts
  end else ""
end


def ​

func:finFindMarkers ​

finFindMarkers(record) ​

Given a dictionary, finFindMarkers will return a list of all marker tags found. If none are found an empty list is returned.


meta ​

constructfinFindMarkers({marker1, marker2, number1:1, number2: 3}...
deffunc:finFindMarkers
isfunc
liblib:finTools
namefinFindMarkers

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(record) => do
  tagNames: [record].toGrid.colNames
  markerList: []

  tagNames.each tag => do
    if(record[tag].debugType.lower.contains("marker"))
      markerList = markerList.add(tag)
  end

  return markerList
end


def ​

func:finFindRefs ​

finFindRefs(object, depth: 1) ​

Return a grid with a new column called "val" that contains a JSON object with all the Refs found within that record.

object can be a single record, list of records, or a grid of records. depth is a number that determines how many levels of "val" to return. Default is 1. If 1 is passed, only the Refs for that record will be found. If 2 is passed, this function will be run on each Ref found in the original record and so on for larger depths.


meta ​

constructfinFindRefs(read(equip))
deffunc:finFindRefs
isfunc
liblib:finTools
namefinFindRefs

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(object, depth: 1) => do
  foundRefs: {}
  resultObj:[]

  if(not object.isGrid and not object.isList)
    object = [object].toGrid
  else if(not object.isGrid)
    object = object.toGrid

  if(depth < 1) //minimum depth is always 1
    depth = 1
  //else if(depth > 2) //sets maximum depth to 2. Change this number to change max depth or comment out remove maximum
    //depth = 2

  object.each item => do
    item.names.each property => do
      if(item[property].isRef and property != "id") do
        if(depth == 1)
          foundRefs = foundRefs.set(property + "Obj", readById(item[property]))
        else if(depth > 1)
          foundRefs = foundRefs.set(property + "Obj", readById(item[property]).finFindRefs(depth - 1))
        end
    end

    foundRefs = foundRefs.map (refCol => do

      refCol = refCol.map (obj => do
        if(obj.debugType == "haystack::Bin")
          obj.toStr
        else
          obj
      end)
    end)

    temp: item
    foundRefs.names.each ref => do
      temp = temp.set(ref, foundRefs[ref].toRec)
    end

    resultObj = resultObj.add(temp)
    foundRefs = {}
  end

  if(resultObj.size == 1)
    resultObj[0]
  else
    resultObj
end


def ​

func:finFindTargetsForStrTagRename ​

finFindTargetsForStrTagRename(targetTag, pointFilter, splitInput) ​

Axon function


meta ​

deffunc:finFindTargetsForStrTagRename
isfunc
liblib:finTools
namefinFindTargetsForStrTagRename
overridable✓
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(targetTag, pointFilter, splitInput) => do
  pts: []

  try do
    if(targetTag.isEmpty)
      pts = readAll(parseFilter(pointFilter + " and navName")).map(r => r.set("dis", r.dis)).sort("dis")
    else do
      if(splitInput.contains("?")) do
        pts = readAll(parseFilter(pointFilter +" and "+ targetTag)).map(r => r.set("dis", r.dis)).sort("dis")
        pts = eval(pts.toRecList.toAxonCode+".findAll(v => v->"+targetTag+".split("+splitInput.split("?")[0].replace("\"", "").toAxonCode+").size "+splitInput.split("?")[1]+")")
      end else
       pts = readAll(parseFilter(pointFilter +" and "+ targetTag)).map(r => r.set("dis", r.dis)).sort("dis")
    end
  end catch ""

  return pts
end


def ​

func:finFormAdvancedEditor ​

finFormAdvancedEditor(stage: null) ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormAdvancedEditor
distoLocale("j2FinToolsExt::advancedTagEditor")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
helphelp:This is an advanded form, be careful. It will allow...
isfunc
liblib:finTools
namefinFormAdvancedEditor

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null) =>
do
  t: (g)=> g.toAxonCode
  body: []
  query:{ "dis": toLocale("j2FinToolsExt::advancedTagEditor"),
          "name": "finFormAdvancedEditor"+random(0..10000),
          "cancelButton": "\$cancelButton",
          "commitButton": "\$applyButton",
          "commitAction": "",
          "helpDoc": "/wiki/display/FINStack/Advanced+Tag+Editor",
          "finForm": marker() }

  if(not isList(stage) and not isDict(stage))
  do
    body = [
    {name: "filter", editorType: "filter", prompt:toLocale("finStackExt::targetFilter"), defVal:"point"},
    {name: "searchTag", editorType:"textinput", prompt: toLocale("j2FinToolsExt::searchTag"), defVal:"navName"},
    {
      name: "function",
      editorType: "combobox",
      prompt: toLocale("j2FinToolsExt::searchFunction"),
      dataProvider: [
          {dis:toLocale("j2FinToolsExt::contains"),val:"contains",selected:true},
          {dis:toLocale("j2FinToolsExt::startsWith"),val:"startsWith"},
          {dis:toLocale("j2FinToolsExt::endsWith"),val:"endsWith"}
        ].toAxonCode,
      labelField: "dis",
      selectedValueTags: "val",
      defIndex: 0
    },
    {name: "searchValue", editorType:"textinput", prompt:toLocale("j2FinToolsExt::searchValue"), defVal:"SupplyAirTemp"},
    {name: "tags", editorType: "textinput",prompt:toLocale("j2FinToolsExt::tagsToApplyOrRemove"), defVal:"navNameFormat:\"SAT\""},

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
    ]

    query = query.set("commitAction", "finFormAdvancedEditor({a:\$filter, b:\$searchTag, c:\$function, d:\$searchValue, e:\$tags})")
  end
  //-----------------------------------------------------------//
  else if(isDict(stage))
  do
    stuffs: readAll(parseFilter(stage->a +" and "+ stage->b))
    search: stage->d.replace(" or ", toChar(8)).split(toChar(8)).map(x=> x.trim)
    stuffs = stuffs.findAll(x=> search.findAll(y=> eval(stage->c +"("+ x.trap(stage->b).trim.t +","+ y.t +")") ).size > 0)
    body = [
      {name: "label", editorType: "label", prompt: toLocale("finStackExt::warning").upper, text: toLocale("j2FinToolsExt::aboutToModWarning").replace("{num}", stuffs.size.toStr)},
      {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::continuePrompt")},
      {name: "chkbx", editorType: "checkbox", label: toLocale("j2FinToolsExt::continueTagPrompt")},

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]

    stuff: [stage->a, stage->b, stage->c, search, stage->e]

    js: [
      "function checkJobStatus(jobHandle) {",
        "var promise;",
        "if (jobHandle === undefined) {",
          "promise = finstack.evalAll(['jobStatusAll().find(v => v->dis.startsWith(\"finFormAdvancedEditor\") and v->started > "+now().toAxonCode+")']);",
        "} else {",
          "promise = finstack.evalAll(['jobStatusAll(\"'+jobHandle+'\")[0]']);",
        "}",
        "promise.then(function(event) {",
          "var jobStat = event.result[0].toObj(false, false, true);",
          "var isDone = jobStat['jobStatus'].startsWith('done');",
          "if (isDone) {",
            "window.top.app.HideLoader();",
          "} else {",
            //"var msg;",
            //"if (jobStat != null && jobStat != undefined) { msg = window.languageManager['loaderLoading'] + jobStat['progress'] + '%'; }",
            //"else { msg = window.languageManager['loaderLoading'] + '0%'; }",
            "window.top.app.HideLoader();",
            "window.top.app.ShowLoader(languageManager['applyingChanges']);",
            "setTimeout(function(){ checkJobStatus(jobStat['handle']); }, 2000);",
          "}",
        "});",
      "}",
      "window.top.app.ShowLoader(languageManager['applyingChanges']);",
      "checkJobStatus();"
    ]

    query = query.merge({
      commitAction: "[jobRun(finFormAdvancedEditor("+ stuff.t +")), finFormAdvancedEditor()][if(\$chkbx) 1 else 0]",
      completeAction: js.concat("\n")
    })
  end
  //-----------------------------------------------------------//
  else if(isList(stage))
  do
    recs: readAll(parseFilter(stage[0] +" and "+ stage[1]))
    recs.each x=> do
      if(stage[3].findAll(y=> eval(stage[2]+"("+ x.trap(stage[1]).trim.t +","+ y.t +")")).size > 0) do
        x.diff(eval("{"+ stage[4] +"}")).commit
      end
    end
  end

  if(not isList(stage)) query = query.set("body", body.toJSON).toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormAhuAirBalance ​

finFormAhuAirBalance(id) ​

This form Runs on AHUs that serve VAV zones. The tags it runs on are (ahu and vavZone). This form requires that you run it from a AHU record. It will allow you to Globally Open, Close VAV zones that are connected to this AHU.

This is very risky, because you could close all VAV boxes that are attached to this AHU, which could cause too much pressure in the Duct.


meta ​

constructfinFormAhuAirBalance(read(ahu and vavZone)->id)
deffunc:finFormAhuAirBalance
distoLocale("j2FinToolsExt::ahuAirBalance")
formOnahu and vavZone
helpThis form Runs on AHUs that serve VAV zones. The tags it...
isfunc
liblib:finTools
namefinFormAhuAirBalance

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  rec: toRec(id)
  vavCount:readCount(vav and ahuRef->id==rec->id)
  ahuDisplayName: rec.dis

  body: [
    {name: "input7", editorType: "separator", label: toLocale("j2FinToolsExt::ahuAirBalNote").replace("{num}", vavCount.toStr).replace("{ahuDis}", ahuDisplayName) },
    {name: "closeInput", editorType: "radio", label: toLocale("j2FinToolsExt::openVavDampers"), selectedValue: "pointOverride(100%)", encapsulate: false},
    {name: "closeInput", editorType: "radio", label: toLocale("j2FinToolsExt::closeVavDampers"), selectedValue: "pointOverride(0%)", encapsulate: false},
    {name: "closeInput", editorType: "radio", label: toLocale("j2FinToolsExt::releaseVavDampers"), selectedValue: "pointAuto()", encapsulate: false},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {
    "dis": toLocale("j2FinToolsExt::setVavBoxes"),
    "name": "vavAhuModes",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "readAll(point and discharge and air and damper and equipRef->ahuRef->id==@" + rec->id +").each rec => rec. \$closeInput",
    //"confirm": "This will effect the Pressure in the AHU Duct. Make sure if you Close the VAVs that the AHU is off. Last chance to double check if it's off. Are you sure you want to continue",
    //"gotoAction": "finstack:folio:axonQuery=readAll(damper and equipRef->vav and equipRef->ahuRef->id==@" + rec->id +").keepCols([\"id\",\"curVal\",\"curStatus\",\"point\", \"his\",\"cmd\",\"kind\"])",
    "helpDoc":"/wiki/display/FINStack/AHU+Air+Balance",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormAlertOk ​

finFormAlertOk(title, msg) ​

Bring up an alert dialog that displays a text message.


meta ​

deffunc:finFormAlertOk
isfunc
liblib:finTools
namefinFormAlertOk

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(title, msg) => do

  body: [
    {
      name: "label",
      editorType: "label",
      text: msg
    },
    {name: "okButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true},
  ]

  { "dis": title,
    "name": "foo",
    "body": body.toJSON,
    "cancelButton": "\$okButton",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})

end


def ​

func:finFormApplyBatchTags ​

finFormApplyBatchTags(stage: null, data: null) ​

This function takes no parameters, as the parameters get loaded from the form. Let's you batch edit tags, from a filter


meta ​

appFormOnfolio
constructfinFormApplyBatchTags()
deffunc:finFormApplyBatchTags
distoLocale("finStackExt::gbApplyBatchTags")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
helpTake a filter to find a number of records and add/remove...
isfunc
liblib:finTools
namefinFormApplyBatchTags

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, data: null) => do
  if(stage == null)
  do
    //instructions:" This form will use the filter below to find a list of records, and then allow you to enter in a list of tags to add/edit/remove"
    //tagInstruction:"The tags should be comma seperated, and should look like this.    numTag:67%, markerTag , boolTag:true , strTag:\"Foo\" Hint: you can use the - minus character to delete a tag. -tagName"
    filterDef: ""
    tagsDef: ""
    body: []
    formName: "finFormApplyBatchTags"

    if (data != null)
    do
      body = [{name:"errMsg", editorType: "label", text: toLocale("j2FinToolsExt::enterValidFilter")}]
      filterDef = data->filter
      tagsDef = data->tags
      formName = formName + random(0..10000)
    end

    body = body.addAll([
      {
        name: "filterPicker",
        editorType: "filter",
        //toolTip:instructions,
        prompt:toLocale("j2FinToolsExt::filterRecordsBatchEdit"),
        encapsulate: true,
        defVal: filterDef
      },

      {
        name: "tags",
        editorType: "textinput",
        prompt: toLocale("j2FinToolsExt::recordsEnterTags"),
        //toolTip:tagInstruction,
        encapsulate: true,
        defVal: tagsDef
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ])

    {
      "dis": toLocale("j2FinToolsExt::batchEditTagsByFilter"),
      "name": formName,
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      //"commitAction": "finCommitApplyBatchTags(\$filterPicker,\$tags)",
      "commitAction": "if (isEmpty(\$filterPicker) or parseFilter(\$filterPicker, false) == null) finFormApplyBatchTags(null, {filter: \$filterPicker, tags: \$tags}) else finFormApplyBatchTags(2, {filter: \$filterPicker, tags: \$tags})",
      //"gotoAction": "finstack:folio:axonQuery=readCount(\$filterPicker)",
      "helpDoc":"/wiki/display/FINStack/Apply+Batch+Tags",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  else if(stage == 2)
  do
    numChanges: readCount(parseFilter(data->filter))

    body: [
      {name: "label", editorType: "label", prompt: toLocale("finStackExt::pointsStateWarning").upper, text: toLocale("j2FinToolsExt::aboutToModWarning").replace("{num}", numChanges.toStr)},
      {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::continuePrompt")},
      {name: "chkbx", editorType: "checkbox", label: toLocale("j2FinToolsExt::continueTagPrompt")},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::no"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::yes"), controlBar: true}
    ]

    js: [
      "function checkJobStatus(jobHandle) {",
        "var promise;",
        "if (jobHandle === undefined) {",
          "promise = finstack.evalAll(['jobStatusAll().find(v => v->dis.startsWith(\"finCommitApplyBatchTags\") and v->started > "+now().toAxonCode+")']);",
        "} else {",
          "promise = finstack.evalAll(['jobStatusAll(\"'+jobHandle+'\")[0]']);",
        "}",
        "promise.then(function(event) {",
          "var jobStat = event.result[0].toObj(false, false, true);",
          "var isDone = jobStat['jobStatus'].startsWith('done');",
          "if (isDone) {",
            "window.top.app.HideLoader();",
          "} else {",
            //"var msg;",
            //"if (jobStat != null && jobStat != undefined) { msg = window.languageManager['loaderLoading'] + jobStat['progress'] + '%'; }",
            //"else { msg = window.languageManager['loaderLoading'] + '0%'; }",
            "window.top.app.HideLoader();",
            "window.top.app.ShowLoader(languageManager['applyingTags']);",
            "setTimeout(function(){ checkJobStatus(jobStat['handle']); }, 1000);",
          "}",
        "});",
      "}",
      "window.top.app.ShowLoader(languageManager['applyingTags']);",
      "checkJobStatus();"
    ]

    { "dis": toLocale("j2FinToolsExt::confirmation"),
      "name": "finFormApplyBatchTags2",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "[if("+numChanges+" > 0) jobRun(finCommitApplyBatchTags("+data->filter.toAxonCode+","+data->tags.toAxonCode+")) else null, finFormApplyBatchTags()][if(\$chkbx) 1 else 0]",
      "completeAction": js.concat("\n"),
      "helpDoc":"/wiki/display/FINStack/Apply+Batch+Tags",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finFormBatchAdvancedTagEditor ​

finFormBatchAdvancedTagEditor(stage: null, one: null, two: null, three: null) ​

Searches database for points with navNames that start with, end with, or contain the specified keywords and adds specified tags to those.


meta ​

appFormOnfolio
deffunc:finFormBatchAdvancedTagEditor
distoLocale("j2FinToolsExt::batchAdvancedTagEditor")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
isfunc
liblib:finTools
namefinFormBatchAdvancedTagEditor

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, one: null, two: null, three: null) => do
  doutput:{ "dis": toLocale("j2FinToolsExt::batchAdvancedTagEditor"),
            "name": "finFormBatchAdvancedTagEditor",
            "cancelButton": "\$cancelButton",
            "commitButton": "\$applyButton",
            "finForm": marker()}
  mkquery: (inp, type, lend: false) => do //function to turn string into query
    efilt: ""
    if(inp.has("efilter")) efilt = inp->efilter
    filt: inp->search4
    quer: "readAll(point "+ efilt +").findAll(r=> r->navName."+ type +"(\""+ filt.split(",").map(q=> trim(q)).concat("\") or r->navName."+type+"(\"") +"\"))"
    if(lend) quer = quer + ".each x=> x.diff({" + inp->tags2add + "}).commit"
    quer
  end
  ////////////////////////////////
  if(stage != 1 and stage != 2) do //read from file, format data, let users see and edit data
    body: [
      {name: "sep", editorType: "separator", label: toLocale("j2FinToolsExt::contains")},
      {name: "1chk", editorType: "combobox", dataProvider: "[{type: "+toLocale("finStackExt::selectAll").toAxonCode +", boole: true},{type: "+toLocale("finStackExt::unselectAll").toAxonCode +", boole: false}]", labelField: "type", selectedValueTags: "boole", defIndex: 0},
      {name: "1xtraRow", editorType: "numericstepper", prompt: toLocale("j2FinToolsExt::extraRows"), minVal: 0},
      {name: "contains", editorType: "list", prompt: "\t\t "+toLocale("j2FinToolsExt::tagsToAdd")+" \t\t\t\t "+toLocale("j2FinToolsExt::contains")+" \t\t\t\t "+toLocale("finStackExt::finFilter"), defValTagName: "selected",
      dataProvider: "if(size([\$1chk]) > 0) finBatchAdvancedTagDP([\$1chk][0], \"contains\", \$1xtraRow) else []",
      itemRenderer: [
        {name: "selected", editorType: "checkbox", enableOn: "selected"},
        {name: "tags2add", editorType: "textinput", text: "\$tagsToAdd"},
        {name: "search4", editorType: "textinput", text: "\$contains"},
        {name: "efilter", editorType: "textinput", text: "\$filter", enableOn: "filter"},
      ]},

    {name: "sep", editorType: "separator", label: toLocale("j2FinToolsExt::startsWith")},
    {name: "2chk", editorType: "combobox", prompt: toLocale("j2FinToolsExt::startsWith"), dataProvider: "[{type: "+toLocale("finStackExt::selectAll").toAxonCode +", boole: true},{type:  "+toLocale("finStackExt::unselectAll").toAxonCode +", boole: false}]", labelField: "type", selectedValueTags: "boole", defIndex: 0},
    {name: "2xtraRow", editorType: "numericstepper", prompt: toLocale("j2FinToolsExt::extraRows"), minVal: 0},
    {name: "startsWith", editorType: "list", prompt: "\t\t "+toLocale("j2FinToolsExt::tagsToAdd")+" \t\t\t\t "+toLocale("j2FinToolsExt::startsWith")+" \t\t\t\t "+toLocale("finStackExt::finFilter"), defValTagName: "selected",
     dataProvider: "if(size([\$2chk]) > 0) finBatchAdvancedTagDP([\$2chk][0], \"startsWith\", \$2xtraRow) else []",
     itemRenderer: [
      {name: "selected", editorType: "checkbox", enableOn: "selected"},
      {name: "tags2add", editorType: "textinput", text: "\$tagsToAdd"},
      {name: "search4", editorType: "textinput", text: "\$startsWith"},
      {name: "efilter", editorType: "textinput", text: "\$filter", enableOn: "filter"},
    ]},

    {name: "sep", editorType: "separator", label: toLocale("j2FinToolsExt::endsWith")},
    {name: "3chk", editorType: "combobox", prompt: toLocale("j2FinToolsExt::endsWith"), dataProvider: "[{type: "+toLocale("finStackExt::selectAll").toAxonCode +", boole: true},{type:  "+toLocale("finStackExt::unselectAll").toAxonCode +", boole: false}]", labelField: "type", selectedValueTags: "boole", defIndex: 0},
    {name: "3xtraRow", editorType: "numericstepper", prompt: toLocale("j2FinToolsExt::extraRows"), minVal: 0},
    {name: "endsWith", editorType: "list", prompt: "\t\t "+toLocale("j2FinToolsExt::tagsToAdd")+" \t\t\t\t "+toLocale("j2FinToolsExt::endsWith")+" \t\t\t\t "+toLocale("finStackExt::finFilter"), defValTagName: "selected",
     dataProvider: "if(size([\$3chk]) > 0) finBatchAdvancedTagDP([\$3chk][0], \"endsWith\", \$3xtraRow) else []",
     itemRenderer: [
      {name: "selected", editorType: "checkbox", enableOn: "selected"},
      {name: "tags2add", editorType: "textinput", text: "\$tagsToAdd"},
      {name: "search4", editorType: "textinput", text: "\$endsWith"},
      {name: "efilter", editorType: "textinput", text: "\$filter", enableOn: "filter"},
    ]},

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
    ]

    doutput = doutput.set("body", body.toJSON).set("height", 600).set("width", 800)
    doutput.set("commitAction", "finFormBatchAdvancedTagEditor(1, \$contains, \$startsWith, \$endsWith)").toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 1) do //do a dry run to show how many points affected
    cdstuff: (asdf,sfunc)=> do //function to make list for labels
      asdf = asdf.findAll(g=> g->tags2add != "" and g->search4 != "" and (not g.has("selected") or g->selected))
      tmp: 0
      ctmp: ""
      asdf.each g=> do
        tmp = eval(mkquery(g, sfunc)+".size")
        if(tmp > 0) ctmp = ctmp + toStr(tmp) + " :\t " + g->search4.split(",").concat(" or ") + "\n"
      end
      if(ctmp == "") ctmp = toLocale("finStackExt::noPtsFound")
      if(asdf.size == 0) ctmp = toLocale("j2FinToolsExt::noSearchParamsForCategory")
      ctmp
    end

    body: [
    {name: "label", editorType: "label", prompt: "contains", text: one.cdstuff("contains")},
    {name: "label", editorType: "label", prompt: "startsWith", text: two.cdstuff("startsWith")},
    {name: "label", editorType: "label", prompt: "endsWith", text: three.cdstuff("endsWith")},
    {name: "label", editorType: "label", prompt: toLocale("j2FinToolsExt::clickApplyToAddTagsToPoints")},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    doutput = doutput.set("body", body.toJSON).set("width", 850)
    doutput.set("commitAction", "finFormBatchAdvancedTagEditor(2, "+one.toAxonCode+", "+two.toAxonCode+", "+three.toAxonCode+")").toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 2) do //apply the changes and stuff
    gridstuff: []
    functhing: (a,b)=> do
      filt: ""
      tags: ""
      a.each y=> do
        if(y->tags2add != "" and y->search4 != "" and (not y.has("selected") or y->selected)) do
          eval(mkquery(y, b, true))
          tags = y->tags2add
          filt = y->search4.split(",").map(w=> w.trim)
          if(b == "contains") filt.each c=> gridstuff = gridstuff.add({navName: ".*("+c+")+.*", addTags: tags})
          else if(b == "startsWith") filt.each c=> gridstuff = gridstuff.add({navName: "("+c+").*", addTags: tags})
          else if(b == "endsWith") filt.each c=> gridstuff = gridstuff.add({navName: ".*("+c+")", addTags: tags})
        end
      end
    end

    if(one.findAll(r=> not r.has("selected") or r->selected).size != 0) functhing(one, "contains")
    if(two.findAll(r=> not r.has("selected") or r->selected).size != 0) functhing(two, "startsWith")
    if(three.findAll(r=> not r.has("selected") or r->selected).size != 0) functhing(three, "endsWith")

    gridstuff.toGrid.ioWriteCsv(`io/output.csv`)
  end
end


def ​

func:finFormBatchDuplicate ​

finFormBatchDuplicate(id) ​

This function takes a record ID, and it will copy and paste it X amount of times. Based on what you enter in the form. finFormBatchDuplicate(@1234) Only works with an ID, not a record, use toRecId() if you want to pass in something like read(point).toRecId.finFormBatchDuplicate()


meta ​

constructfinFormBatchDuplicate(read(point))
deffunc:finFormBatchDuplicate
distoLocale("j2FinToolsExt::duplicateXTimes")
formOnregion or site or floor or equip or (point and not sched...
helpDuplicate the selected items X amount of times. The incl...
isfunc
liblib:finTools
namefinFormBatchDuplicate

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  rec: id.toRec()
  whoAmI:read(id==id).finNavMetaWhoAmI()
  dbBuilderRefreshAction: ""

  if (whoAmI != null)
  do
    navMetaList: reFind("[^/].+", read(navMeta)->equipPath).split("/")
    curNavIndex: navMetaList.index(whoAmI)

    if (curNavIndex != 0)
    do
      parentNodeRef: rec[navMetaList[curNavIndex - 1]+"Ref"]
      dbBuilderRefreshAction = "window.app.RefreshBuilderTreeNodeForId('"+parentNodeRef.toAxonCode+"')"
    end
    else
      dbBuilderRefreshAction = "window.app.RefreshBuilderTreeNodeForId('@folderPath:equip:')"
  end
  else if (rec.has("programOn"))
    dbBuilderRefreshAction = "window.app.RefreshBuilderTreeNodeForId('@folderPath:programs:')"

  body: [
    {
      name: "xTimes",
      editorType: "numericstepper",
      prompt: toLocale("j2FinToolsExt::duplicateFormPrompt"),
      minVal: 1,
      maxVal: 100,
      defVal: 1
    },

    {
      name: "includeChildren",
      editorType: "checkbox",
      defVal: false,
      label: toLocale("j2FinToolsExt::removeChildren")
      //toolTip:"If checked this will only copy the selected item, it will not copy it's children, IE.. points, equips, floors, etc.."
    },

    //{name: "includeChildren", editorType: "radio", label: toLocale("j2FinToolsExt::includeChildren"), selectedValue: " "},
    //{name: "input2", editorType: "radio", label: toLocale("j2FinToolsExt::dontIncludeChildren"), selectedValue: ", noChildren"},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {
    "dis":toLocale("j2FinToolsExt::copyThis") + " " + whoAmI + " -- " + rec.dis() + " -- " + toLocale("j2FinToolsExt::numOfDuplicates"),
    "name": "Copy and Paste",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finDuplicateRec(" + id.toAxonCode + ", \$xTimes, \$includeChildren)" ,
    "confirm": toLocale("j2FinToolsExt::duplicateFormConfirmation"),
    //"gotoAction": "finstack:builder:recId=@" + id,
    "completeAction": dbBuilderRefreshAction,
    "finForm": marker(),
    "helpDoc":"/wiki/display/FINStack/Duplicate+X+Times",
    "refreshTrees": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormChangeAddAhuRef ​

finFormChangeAddAhuRef(id, selectedDicts: null) ​

This function will take and ID, and a list of selectedDicts. Typically will be used in the Builder when you select multiple vavs, and then you want to select which ahu is belongs too . This function will only work if the selected item or items are all a vav and an equip


meta ​

constructfinFormChangeAddAhuRef(read(ahuRef and vav)->id, readAll...
deffunc:finFormChangeAddAhuRef
distoLocale("j2FinToolsExt::batchUpdateAhuRefs")
formOnvav and equip
helpChange the ahuRef on all VAVs that were selected. Select...
isfunc
liblib:finTools
namefinFormChangeAddAhuRef
overridable✓
uiFormOnvav and equip

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, selectedDicts: null) => do

  if (selectedDicts == null)
    return {}.toGrid.addMeta({err, errTrace: toLocale("j2FinToolsExt::selectVavEquipErr"), errType: toLocale("j2FinToolsExt::selectVavEquipErr")})

  rec: id.toRec()
  recDisplayName: rec.dis()
  vavCount: selectedDicts.size()
  idsList: selectedDicts.map() (row => row->id.toAxonCode).concat(",")
  sitesId:rec->siteRef->id

    body: [
      {name: "input7", editorType: "separator", label: toLocale("j2FinToolsExt::selectedAhuWillBeAppliedToVavs").replace("{num}", vavCount.toStr) },
      {name: "ahuSelection", editorType: "combobox", prompt: toLocale("j2FinToolsExt::selectAhu"), dataProvider: "ahu and siteRef->id==@" + sitesId , labelField: "dis", selectedValueTags: "id"},
      //This will let you see what is getting passed in {name: "input5", editorType: "textarea", prompt: toLocale("j2FinToolsExt::textArea"), height: 200, editable: false,defVal: idsList  },
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

  {
    "dis": toLocale("j2FinToolsExt::updateAhurefPrompt"),
    "name": "changeAhuRef",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "readByIds([" + idsList +"]).toRecList.map(r => diff(r, {ahuRef:\$ahuSelection})).commit",
    //"gotoAction": "finstack:folio:axonQuery=readByIds([" + idsList +"]).keepCols([\"id\",\"ahuRef\"])",
    //"confirm": toLocale("j2FinToolsExt::blinePromptWarning"),
    "finForm": marker(),
    "helpDoc":"/wiki/display/FINStack/Batch+Update+AHU+Ref",
    "refreshTrees": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormCloneSchedule ​

finFormCloneSchedule(id) ​

Axon function


meta ​

deffunc:finFormCloneSchedule
distoLocale("j2FinToolsExt::batchCloneSchedule")
formOnschedule
isfunc
liblib:finTools
namefinFormCloneSchedule

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id)=> do
  kind: readById(id)->kind
  action: ""

  body: [
    {
      name:"eventCatalog",
      editorType:"combobox",
      prompt:toLocale("j2FinToolsExt::cloneScheduleBy"),
      dataProvider:[{dis:toLocale("j2FinToolsExt::wholeSchedule"),val:"whole"},{dis:toLocale("finStackExt::schWeekly"),val:"weekly"},{dis:toLocale("finStackExt::events"),val:""}].toAxonCode,
      selectedValueTags:"val",
      labelField:"dis"
    },
    {
      name:"selectedEvents",
      editorType:"list",
      listType:"checkbox",
      prompt:toLocale("j2FinToolsExt::selectEvents"),
      selectedValueTags:"dis",
      labelField:"label",
      defValTagName :"selected",
      dataProvider:"getEventsData(@"+id+",\$eventCatalog)",
      height:150
    },

    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    { name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
  ]

  if(readAll(savedQueryFilter and cloneSchedule).size > 0) do
    body = body.addAll([{
      name:"filter",
      editorType:"combobox",
      dataProvider:"readAll(savedQueryFilter and cloneSchedule)",
      labelField:"dis",
      selectedValueTags:"filterString",
      prompt:toLocale("j2FinToolsExt::targetSchedulesByFilter")
    },

    {
      name:"scheduleList",
      editorType:"list",
      prompt:toLocale("j2FinToolsExt::filterResults"),
      labelField:"dis",
      selectedValueTags:"id",
      dataProvider:"eval(\$filter).findAll(r=> r->kind==\""+kind+"\" and r->id != @"+id+")",
      height:150
    }])

    action = "finBatchCloneScheduleApply(@" + id + ",\$selectedEvents,\"readAll(\" + (\$scheduleList).map(t=>\"id==@\"+t).concat(\" or \") + \")\")"
  end else do
    body = body.add({
      name:"scheduleList",
      editorType:"list",
      listType: "checkbox",
      prompt:toLocale("j2FinToolsExt::selectSchedules"),
      labelField:"dis",
      selectedValueTags:"id",
      dataProvider:"readAll(schedule).findAll(r=> r->kind==\""+kind+"\" and r->id != @"+id+").map(r=> r.set(\"dis\", r.dis)).sort(\"dis\")",
      height:150
    })

    action = "finBatchCloneScheduleApply(@" + id + ",\$selectedEvents,\"readAll(\" + (\$scheduleList).map(t=>\"id==@\"+t).concat(\" or \") + \")\")"
  end

  {
     "dis": toLocale("j2FinToolsExt::batchCloneSchedule"),
     "name": "formBatchCloneSchedule",
     "body": body.toJSON,
     "cancelButton": "\$cancelButton",
     "commitButton": "\$applyButton",
     "commitAction": action,
     "confirm": "This will overwrite the existing events in targeted schedules, are you sure?",
     "helpDoc": "/wiki/display/FINStack/Batch+Clone+Schedule",
     "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormCommandAuto ​

finFormCommandAuto() ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormCommandAuto
distoLocale("j2FinToolsExt::autoPointVals")
folderPathtoLocale("j2FinToolsExt::databaseCleanUp")
isfunc
liblib:finTools
namefinFormCommandAuto

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
//sets all levels to null
levels: "[{name: \"1 (emergency)\", level: 1, chk: true},{name: \"2\", level: 2, chk: false},{name: \"3\", level: 3, chk: false},{name: \"4\", level: 4, chk: false},{name: \"5\", level: 5, chk: false},{name: \"6\", level: 6, chk: false},{name: \"7\", level: 7, chk: false},{name: \"8 (manual)\", level: 8, chk: true},{name: \"9\", level: 9, chk: false},{name: \"10\", level: 10, chk: false},{name: \"11\", level: 11, chk: false},{name: \"12\", level: 12, chk: false},{name: \"13\", level: 13, chk: false},{name: \"14\", level: 14, chk: false},{name: \"15\", level: 15, chk: false},{name: \"16\", level: 16, chk: false},{name: \"def\", level: 17, chk: false},]"

  body: [
    {name: "filterPicker", editorType: "filter", prompt: toLocale("j2FinToolsExt::recordFilter")+":", encapsulate: true},
    {name: "levels", editorType: "list", prompt: toLocale("j2FinToolsExt::writeLevelsToAuto")+":", listType: "checkbox", dataProvider: levels, labelField: "name", selectedValueTags: "level", defValTagName: "chk", height: 200},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {
    "dis":toLocale("j2FinToolsExt::autoPointVals"),
    "name": "finFormCommandAuto",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finCommandAuto(\$filterPicker, \$levels)",
    "helpDoc":"/wiki/display/FINStack/Auto+Point+Values",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormConflictingTags ​

finFormConflictingTags() ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormConflictingTags
distoLocale("j2FinToolsExt::fixConflictingTags")
folderPathtoLocale("j2FinToolsExt::databaseCleanUp")
isfunc
liblib:finTools
namefinFormConflictingTags

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  hasin: (nam, lst)=> do
    stat: false
    nam = nam.lower
    lst.each g=> if(nam.contains(g)) stat = true
    stat
  end

  rnames: "finConflictingTags([\"\""
  body: []
  count: 0
  rname: ""
  stuff: readAll(sp and sensor or sp and cmd or cmd and sensor or point and not cmd and not sp and not sensor).sort("navName")

  if(stuff.size > 0)
    stuff = stuff.unique("navName")

  stuff.each x =>
  do
    rname = count+"count"
    body = body.add({name: "label", editorType: "separator", label: x->navName})

    if(x->navName.hasin(["cmd","command"]))
      body = body.add({name: rname, group: rname, editorType: "radio", label: "CMD", selectedValue: "cmd", defVal: true})
    else
      body = body.add({name: rname, group: rname, editorType: "radio", label: "CMD", selectedValue: "cmd"})

    if(x->navName.hasin(["sensor","status","sts"]))
      body = body.add({name: rname, group: rname, editorType: "radio", label: "SENSOR", selectedValue: "sensor", defVal: true})
    else
      body = body.add({name: rname, group: rname, editorType: "radio", label: "SENSOR", selectedValue: "sensor"})

    if(x->navName.lower.hasin(["stpt","spt"]) or x->navName.lower.endsWith("sp"))
      body = body.add({name: rname, group: rname, editorType: "radio", label: "SP", selectedValue: "sp", defVal: true})
    else
      body = body.add({name: rname, group: rname, editorType: "radio", label: "SP", selectedValue: "sp"})

    rnames = rnames + ",[\$" + rname + ", " + x->navName.toAxonCode + "]"
    count = count+1
  end

  rnames = rnames + "]"

  if(count == 0)
    body = body.add({name: "label", editorType: "label", text: toLocale("j2FinToolsExt::noConflictingTags")})
  else if(count > 1)
  do
    body = body.insertAll(0,[
      {name: "label", editorType: "separator", label: toLocale("j2FinToolsExt::applyToAll")},
      {name: "opt", editorType: "radio", group: "settings", label: "CMD", selectedValue: 1},
      {name: "opt", editorType: "radio", group: "settings", label: "SENSOR", selectedValue: 2},
      {name: "opt", editorType: "radio", group: "settings", label: "SP", selectedValue: 3},
      {name: "opt", editorType: "radio", group: "settings", label: toLocale("j2FinToolsExt::fixIndividually"), selectedValue: 0, defVal: true}
    ])

    rnames = rnames + ",\$opt"
  end

  rnames = rnames + ")"

  body = body.addAll([
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
  ])

  {
    "dis": toLocale("j2FinToolsExt::fixConflictingTags"),
    "name": "finFormConflictingTags",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": rnames,
    //"gotoAction": "finstack:folio:axonQuery="+rnames,
    "helpDoc":"/wiki/display/FINStack/Fix+Conflicting+Tags",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormConnTuning ​

finFormConnTuning(stage: null, data: null) ​

Form to add connTuningRef tags to filter results


meta ​

appFormOnfolio,connectors
deffunc:finFormConnTuning
distoLocale("j2FinToolsExt::batchApplyTuningPolicy")
folderPathtoLocale("finStackExt::rightMenuConnectors")+"/"+toLocal...
isfunc
liblib:finTools
namefinFormConnTuning

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, data: null) => do
  query: {
    "dis": toLocale("j2FinToolsExt::batchApplyTuningPolicy"),
    "name": "finFormConnTuning"+stage.toStr,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$commitButton",
    "commitAction": "null",
    "finForm": marker()
  }

  ////////////////////
  if(stage == null)
  do
    body: [
      {
        name: "filt",
        editorType: "filter",
        prompt: toLocale("j2FinToolsExt::recordFilter")+":",
        defVal: if (data == null or data["selected"] == null) "connTuningRef" else data->selected
      },

      {
        name: "combo",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::tuningPolicyToAdd")+":",
        defIndex: 0,
        dataProvider: "readAll(connTuning)",
        labelField: "dis",
        selectedValueTags: "id"
      },

      { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true },
      { name: "commitButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true }
    ]

    query.set("body", body.toJSON).set("commitAction","finFormConnTuning(2, {filt:\$filt, combo:\$combo})").toGrid.addMeta({formExecute: marker()})
  end

  //////////////////////
  else if(stage == 2)
  do
    body: [
      {name: "label", editorType: "label", prompt: toLocale("finStackExt::warning").upper, text: toLocale("j2FinToolsExt::aboutToModWarning").replace("{num}", readCount(parseFilter(data->filt)).toStr)},
      {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::continuePrompt")},
      {name: "chkbx", editorType: "checkbox", label: toLocale("j2FinToolsExt::continueTagPrompt")},

      { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::no"), controlBar: true },
      { name: "commitButton", editorType: "button", label: toLocale("finStackExt::yes"), controlBar: true}
    ]

    query = query.set("commitAction","[finFormConnTuning(3, "+data.toAxonCode+"), finFormConnTuning()][if(\$chkbx) 1 else 0]")
    query.set("body", body.toJSON).toGrid.addMeta({formExecute: marker()})
  end

  //////////////////////
  else if(stage == 3)
  do
    readAll(parseFilter(data->filt)).each x=> x.diff({connTuningRef: data->combo}).commit
  end
end


def ​

func:finFormCopyBoundPoints ​

finFormCopyBoundPoints(id, selectedDicts) ​

Axon function


meta ​

appFormOnbuilder
deffunc:finFormCopyBoundPoints
distoLocale("j2FinToolsExt::copyPoints")
formOnpoint and not schedule
isfunc
liblib:finTools
namefinFormCopyBoundPoints

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, selectedDicts) => do

  selDis: "[" + selectedDicts.map() (row => "\"" + dis(readById(row->id)) + "\"").concat(",") + "]"
  selIds: "[" + selectedDicts.map() (row => row->id.toAxonCode).concat(",") + "]"
  equipRef: selectedDicts[0]->equipRef

  body: [
    {
      name: "points",
      editorType: "list",
      listType: "checkbox",
      prompt: toLocale("finStackExt::points"),
      height: 100,
      dataProvider: selDis,
      labelField: "val",
      selectedValueTags: "val",
    },
    {
      name: "equipFilter",
      editorType: "filter",
      prompt:toLocale("j2FinToolsExt::equipFilter"),
      encapsulate: true
    },
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
  ]

  { "dis": toLocale("j2FinToolsExt::copyPoints"),
    "name": "foo",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finCopyBoundPoints(" + selIds + ", parseFilter(\$equipFilter))",
    "helpDoc":"/wiki/display/FINStack/Copy+Points",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})

end


def ​

func:finFormCreateEditGraphic ​

finFormCreateEditGraphic(stage: null, id: null) ​

Axon function


meta ​

appFormOngraphics
deffunc:finFormCreateEditGraphic
distoLocale("j2FinToolsExt::createEditExternalGraphic")
isfunc
liblib:finTools
namefinFormCreateEditGraphic

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, id: null) => do
  if(stage != 1) do
    opts: [{dis: toLocale("finStackExt::coreCreateNew"), id: "null"}]
    readAll(finExternalProject).keepCols(["dis","id"]).each x=> opts = opts.add(x)

    body: [
      {name: "option", editorType: "combobox", prompt: toLocale("finStackExt::coreEdit"), dataProvider: opts.toAxonCode, labelField: "dis", selectedValueTags: "id", defIndex: 0},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
    ]

    { "dis": toLocale("j2FinToolsExt::createEditExternalGraphic"),
      "name": "finFormCreateEditGraphic",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "finFormCreateEditGraphic(1,\$option)",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 1) do
    if(id != "null") stuff: readById(id)
    else stuff: {dis: toLocale("finStackExt::newGraphic"), graphicOn: "site or floor", finScreenshot: "/api/demo/rec/1e72380c-a994187f/file",
      finThumbnail: "/api/demo/rec/1e72380c-a994187f/file", finIcon: "/api/demo/rec/1e72380c-a994187f/file", uri: "/pub/folder/index.html#\$dis"}

    button: toLocale("finStackExt::builderUpdate")
    if(id == "null") button = toLocale("finStackExt::coreCreate")

    imgs: []
    readAll(file).findAll(x=> x->file.toAxonCode.contains("image")).keepCols(["id","dis"]).each x=> imgs = imgs.add({dis: x->dis, id: "/api/"+ context()->projName +"/rec/"+ x->id +"/file"})
    dind: [0,0,0]
    if(id != "null") imgs.each((x,y)=> do
      if(x->id == stuff->finScreenshot) dind = dind.set(0,y)
      if(x->id == stuff->finThumbnail) dind = dind.set(1,y)
      if(x->id == stuff->finIcon) dind = dind.set(2,y)
    end)

    body: [
      {name: "dis",        editorType: "textinput", prompt: "dis:", defVal: stuff->dis},
      {name: "graphicOn",  editorType: "textinput", prompt: "graphicOn:", defVal: stuff->graphicOn},
      {name: "uri",        editorType: "textinput", prompt: "uri:", defVal: stuff->uri},
      {name: "screenshot", editorType: "combobox", prompt: "screenshot:", dataProvider: imgs.toAxonCode, labelField: "dis", selectedValueTags: "id", defIndex: dind[0], defVal: stuff->finScreenshot},
      {name: "thumbnail",  editorType: "combobox", prompt: "thumbnail:", dataProvider: imgs.toAxonCode, labelField: "dis", selectedValueTags: "id", defIndex: dind[1], defVal: stuff->finThumbnail},
      {name: "icon",       editorType: "combobox", prompt: "icon", dataProvider: imgs.toAxonCode, labelField: "dis", selectedValueTags: "id", defIndex: dind[2], defVal: stuff->finIcon},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: button, controlBar: true}
    ]

    if(id != "null") commact: "diff(readById("+id+"), {finExternalProject: marker(), dis: \$dis, graphicOn: \$graphicOn, finScreenshot: \$screenshot, finThumbnail: \$thumbnail, finIcon: \$icon, uri: \$uri}).commit"
    else commact: "diff(null, {finExternalProject: marker(), dis: \$dis, graphicOn: \$graphicOn, finScreenshot: \$screenshot, finThumbnail: \$thumbnail, finIcon: \$icon, uri: \$uri}, {add}).commit"

    { "dis": toLocale("j2FinToolsExt::createEditExternalGraphic"),
    "name": "finFormCreateEditGraphic",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": commact,
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finFormCreateNote ​

finFormCreateNote(id) ​

This form will create a note on a target. Currently it will only work if this form is loaded from the builder, as it uses the recId that is in the url paramter in the builder


meta ​

constructfinFormCreateNote(read(site or equip or floor or point)-...
deffunc:finFormCreateNote
distoLocale("j2FinToolsExt::createNote")
hideFromMobileDB✓
isfunc
liblib:finTools
namefinFormCreateNote

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  rec: id.toRec()
  u: finGetCurrentUser()->id.toAxonCode
  body: [
    {name: "titleInput", editorType: "textinput",prompt:toLocale("j2FinToolsExt::finFormNoteTitle")},
    {name: "bodyInput", editorType: "textarea", height:150, prompt:toLocale("j2FinToolsExt::finFormEnterDesc")+":"},
    // {name: "userSelect", editorType: "combobox", prompt: toLocale("j2FinToolsExt::selectUser"), dataProvider: "user", labelField: "dis", selectedValueTags: "id"},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {
    "dis": toLocale("j2FinToolsExt::finFormCreateNote").replace("{name}", rec.dis()),
    "name": "create a note",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "noteOpen(noteAdd({ dis:\$titleInput, body:\$bodyInput, targetRef:@"+rec->id+", owner:"+u+" }),"+u+",\"\")",
  //"gotoAction": "finstack:folio:axonQuery=\$input3",
    "helpDoc":"/wiki/display/FINStack/Create+A+Note",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormCreateSummary ​

finFormCreateSummary(id, refill: null) ​

Axon function


meta ​

deffunc:finFormCreateSummary
distoLocale("finStackExt::createSum")
folderPathtoLocale("finStackExt::rightMenuSummaryTitle")
formOnequip
helpCreate a summary
hideFromMobileDB✓
isfunc
liblib:finTools
namefinFormCreateSummary

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, refill: null) => do
  defName: ""
  defFilter: if(id == null) "topLevel" else readById(id).findAll(x=> x==marker()).names.concat(" and ")
  runOnData: "finFormCreateSummaryRefs(" + id.toAxonCode + ").sort(\"dis\")"

  if(refill != null) do
    defName = refill->name
    defFilter = refill->filter
    runOnData = "finFormCreateSummaryRefs(" + id.toAxonCode + ").map(r => if(("+refill->runOn.toAxonCode+").contains(r->dis)) r.merge({selected}) else r).sort(\"dis\")"
  end

  body: [
    {
      name: "summaryName",
      editorType: "textinput",
      prompt:toLocale("j2FinToolsExt::sumName"),
      defVal: defName
    },
    {
      name: "summariesToRunOn",
      editorType: "list",
      prompt: toLocale("j2FinToolsExt::selectSum"),
      dataProvider: runOnData,
      listType: "checkbox",
      labelField: "dis",
      selectedValueTags: "dis",
      defValTagName: "selected",
      /*
      itemRenderer: [
        {name: "selectedb", editorType: "checkbox"},
        {name: "selectedDis", editorType: "label", text: "\$dis", toolTip:toLocale("j2FinToolsExt::toolTipAddFilter")},
        {name: "extraFilter", editorType: "textinput"}
      ]*/
    },
    {
      name: "pointsInEquip",
      editorType: "list",
      listType: "checkbox",
      prompt: toLocale("j2FinToolsExt::selectPointsSum"),
      height: 200,
      dataProvider: if(id != null) "readAll(point and equipRef == " + id.toAxonCode + ").colToList(\"navName\").sort" else "[]",
      labelField: "val",
      selectedValueTags: "val",
    },
    {
      name: "equipFilter",
      editorType: "filter",
      prompt:toLocale("j2FinToolsExt::equipFilterSum"),
      defVal: defFilter,
      config: {recordFilter: if(id != null) "id=="+id.toAxonCode else if(read(topLevel, false) != null) "id=="+read(topLevel)->id.toAxonCode else "topLevel"}
    },
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton",  editorType: "button", label: toLocale("finStackExt::next"),  controlBar: true}
  ]

  if(refill != null)
    body = body.insert(0, {name: "errMsg", editorType: "label", text: toLocale("j2FinToolsExt::summaryBuilderSelectPointErr")})

  { "dis": toLocale("finStackExt::createSum"),
    "name": "finFormCreateSummary" + (if(refill != null) random(1..1000) else ""),
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "if((\$pointsInEquip).isEmpty) finFormCreateSummary("+id.toAxonCode+", {name: \$summaryName, runOn:\$summariesToRunOn, filter: \$equipFilter}) else finFormSetSummaryPointOrder(\$summaryName, \$summariesToRunOn, \$pointsInEquip, \$equipFilter)",
    "helpDoc":"/wiki/display/FINStack/Create+Summary",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormCreateSummaryApply ​

finFormCreateSummaryApply(summaryName, summariesToRunOn, pointsInEquip, equipFilter, pointOrders) ​

Axon function


meta ​

deffunc:finFormCreateSummaryApply
isfunc
liblib:finTools
namefinFormCreateSummaryApply
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(summaryName, summariesToRunOn, pointsInEquip, equipFilter, pointOrders) => do
  if(summaryName.isRef)
      readById(summaryName).diff({pointOrder: pointOrders.toGrid.sort("order").toRecList.map(r => r->name).concat(",")}).commit
  else do
    summariesToRunOn.each s => do
      tag: s
      summaryOn: tag

      rec: {
        dis: capitalize(tag) + " " + summaryName,
        summaryOn: summaryOn,
        equipFilter: if(tag != "topLevel") equipFilter + " and " + tag + "Ref==\$self" else equipFilter,
        pointFilter: pointsInEquip.map(p=> "(navName == \"" + p + "\")").concat(" or "),
        pointOrder: pointOrders.toGrid.sort("order").toRecList.map(r => r->name).concat(",")
      }
      commit(diff(null, rec, {add}))
    end
  end
end


def ​

func:finFormCreateSummaryRefs ​

finFormCreateSummaryRefs(id) ​

Axon function


meta ​

deffunc:finFormCreateSummaryRefs
isfunc
liblib:finTools
namefinFormCreateSummaryRefs
private✓
update✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  rec: toRec(id)

  list: []

  if(id != null) do
    rec.each((v,k) => do
      if (endsWith(k, "Ref") and k != "imageRef")
          list = list.add({"dis": k[0..-4]})
    end)
  end

  if(not readAll(topLevel).isEmpty) list = list.add({dis: "topLevel"})

  return list.toGrid

end


def ​

func:finFormCreateTuningPolicy ​

finFormCreateTuningPolicy(id, folderPath: null, refreshTop: false) ​

Axon function


meta ​

deffunc:finFormCreateTuningPolicy
helpThis form let's you create a new tuning policy. Try to u...
isfunc
liblib:finTools
namefinFormCreateTuningPolicy

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, folderPath:null, refreshTop: false) => do
  policyName: ""
  minWriteVal: 5
  maxWriteVal: 90
  pollTimeIndex: 0
  edit: false
  formTitle: toLocale("finStackExt::coreCreate")
  curPolicy: {}
  pollTimes: [{val:"5s"},{val:"10s"},{val:"15s"},{val:"20s"},{val:"30s"},{val:"1min"},{val:"2min"},{val:"3min"},
              {val:"5min"},{val:"10min"},{val:"15min"},{val:"30min"},{val:"1hr"}]

  if(id != null and id.isRef) do
    formTitle = toLocale("finStackExt::coreEdit")
    curPolicy = readById(id)
    edit = true
    policyName = curPolicy.dis
    minWriteVal = try curPolicy->writeMinTime catch minWriteVal
    maxWriteVal = try curPolicy->writeMaxTime catch maxWriteVal
    pollTimeIndex = try pollTimes.index(pollTimes.find(v => parseNumber(v->val) == curPolicy->pollTime)) catch pollTimeIndex
  end

  body: [
    {
        name: "tuningPolicyName",
        editorType: "textinput",
        prompt:toLocale("j2FinToolsExt::finFormTuningPolicyName"),
        defVal: policyName
    },

    {   name: "minWriteEnable",
        editorType: "checkbox",
        label:toLocale("j2FinToolsExt::finFormMinWriteTime"),
        defVal: curPolicy.has("writeMinTime")
    },

    {
        name: "minWriteTime",
        editorType: "numericstepper",
        prompt: toLocale("j2FinToolsExt::finFormMinWriteTimeSeconds"),
        minVal: 0,
        maxVal: 10000,
        defVal: minWriteVal,
        toolTip:"The min time it will write to a point. 5seconds means that it will never write more than once per 5 seconds",
    },

    {   name: "maxWriteEnable",
        editorType: "checkbox",
        label: toLocale("j2FinToolsExt::finFormEnableMaxWritetime"),
        defVal: curPolicy.has("writeMaxTime")
    },

    {
        name: "maxWriteTime",
        editorType: "numericstepper",
        prompt: toLocale("j2FinToolsExt::finFormMaxWriteTimeMinutes"),
        minVal: 0,
        maxVal: 5000,
        defVal: maxWriteVal,
        toolTip:"The maxWriteTime tag is the maximum amount of time before it's writes the value again. If it is set to 10 minutes this means that the point will be written every 10 minutes even if it never changes. Be very careful with this setting. It should only be used on things like schedule points or things you want written over and over",
    },

    {   name: "scheduleWrite",
        editorType: "checkbox",
        label: toLocale("j2FinToolsExt::finFormScheduleWrite"),
        defVal: curPolicy.has("writeSchedule")
    },

    {   name: "pollEnable",
        editorType: "checkbox",
        label: toLocale("j2FinToolsExt::finFormEnablePoll"),
        defVal: curPolicy.has("pollTime")
    },

    {
        name: "pollTime",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::finFormPoll"),
        defIndex:pollTimeIndex,
        dataProvider:pollTimes.toAxonCode,
        selectedValueTags:"val",
        labelField:"val"
    },

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {
    "dis": formTitle + " " + toLocale("j2FinToolsExt::fillInTuningPolicy"),
    "name": "tuningPolicy2",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finCreateEditTuningPolicyCommit({name:\$tuningPolicyName, pollEnab: \$pollEnable, minEnab:\$minWriteEnable, maxEnab: \$maxWriteEnable, edit: " + edit.toAxonCode + ", minWrite:\$minWriteTime, maxWrite:\$maxWriteTime, poll:\$pollTime, schedule: \$scheduleWrite}, " + id.toAxonCode + ", "+folderPath.toAxonCode+")",
    "helpDoc":"/wiki/pages/viewpage.action?pageId=7045163",
    "completeAction": try generateFormRefreshCalls("connTuning", folderPath, refreshTop) catch "",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormCurWriteHisEditor ​

finFormCurWriteHisEditor() ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormCurWriteHisEditor
distoLocale("j2FinToolsExt::pathEditor")
folderPathtoLocale("j2FinToolsExt::databaseCleanUp")
isfunc
liblib:finTools
namefinFormCurWriteHisEditor

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  //write cur/write/his values to cur/write/his values
  instructions:"Filter stuff"
  promptt:toLocale("j2FinToolsExt::recordFilter")+":"

  body: [
    {name: "radButt1", group: "radButt1", editorType: "radio", label: toLocale("j2FinToolsExt::curToWrite"), selectedValue: "c2w", defVal: true},
    {name: "radButt1", group: "radButt1", editorType: "radio", label: toLocale("j2FinToolsExt::writeToCur"), selectedValue: "w2c"},
    {name: "radButt1", group: "radButt1", editorType: "radio", label: toLocale("j2FinToolsExt::curToHis"), selectedValue: "c2h"},

    {name: "filterPicker", editorType: "filter", toolTip:instructions, prompt:promptt, encapsulate: true},

    {name: "radButt2", group: "radButt2", editorType: "radio", label: toLocale("j2FinToolsExt::haystack"), selectedValue: "haystack", defVal: true},
    {name: "radButt2", group: "radButt2", editorType: "radio", label:toLocale("j2FinToolsExt::bacnet"), selectedValue: "bacnet"},

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {
    "dis": toLocale("j2FinToolsExt::pathEditor"),
    "name": "finFormCurWriteHisEditor",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finCurWriteHisEditor(\$filterPicker,\$radButt1,\$radButt2)",
    "helpDoc":"/wiki/display/FINStack/Path+Editor",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormCustomName ​

finFormCustomName() ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormCustomName
distoLocale("j2FinToolsExt::customToNavName")
finString✓
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
formOnpoint and basName and not schedule
isfunc
liblib:finTools
namefinFormCustomName

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body: [
    {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::updateNavNameCount").replace("{count}", readCount(navNameCustom).toStr)},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::no"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::yes"), controlBar: true}
  ]

  { "dis": toLocale("j2FinToolsExt::customToNavName"),
    "name": "finFormCustomName",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "readAll(navNameCustom).findAll(x=> x->navNameCustom.isStr).each(x=> x.diff({navName:x->navNameCustom}).commit)",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormDisplayTagRenames ​

finFormDisplayTagRenames(pointFilter, targetTag, splitInput, patternInput) ​

Axon function


meta ​

deffunc:finFormDisplayTagRenames
isfunc
liblib:finTools
namefinFormDisplayTagRenames
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(pointFilter, targetTag, splitInput, patternInput) => do
  //finGenerateSampleTagValue([@1a169f42-97348ed4], "navName", " ", "1, \" thingy \", -1")
  body: [
    {
      name: "changeList",
      editorType: "list",
      listType: "checkbox",
      dataProvider: "finGenerateSampleTagValue(readAll("+pointFilter+").colToList(\"id\"), "+targetTag.toAxonCode+", "+splitInput.toAxonCode+", "+patternInput.toAxonCode+").sort((a, b) => a->finFormDisplay <=> b->finFormDisplay)",
      labelField: "finFormDisplay",
      height: 300
    },

    {name:"cancelButton", editorType:"button", label:toLocale("finStackExt::cancel"), controlBar:true},
    {name:"commitButton", editorType:"button", label:toLocale("finStackExt::coreApply"), controlBar:true}
  ]

  { "dis":toLocale("j2FinToolsExt::massRenameStringTags"),
    "name": "finFormDisplayTagRenames", //else "finFormTagSplitAndRename" + random(1..10000),
    "body":body.toJSON,
    "width": 450,
    "cancelButton": "\$cancelButton",
    "commitButton":"\$commitButton",
    "commitAction": "finGenerateSampleTagValue(readAll("+pointFilter+").colToList(\"id\"), "+targetTag.toAxonCode+", "+splitInput.toAxonCode+", "+patternInput.toAxonCode+", true)",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormDuplicateScheduleDay ​

finFormDuplicateScheduleDay(id: null, data: null) ​

This is a form to duplicate one day from a schedule to one or more days on the same schedule. This form does not over-write other days, it just adds the extra schedules onto the other days. Original scheduling won't be removed. You cannot duplicate a day that doesn't have any schedule on it.


meta ​

deffunc:finFormDuplicateScheduleDay
distoLocale("j2FinToolsExt::duplicateScheduleDay")
formOnschedule
isfunc
liblib:finTools
namefinFormDuplicateScheduleDay
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id: null, data: null) => do
  sched: readById(id)
  if(data == null) do
    translate: [
      {a:toLocale("finStackExt::dRuleSun"),b:"sun",o:0},
      {a:toLocale("finStackExt::dRuleMon"),b:"mon",o:1},
      {a:toLocale("finStackExt::dRuleTue"),b:"tue",o:2},
      {a:toLocale("finStackExt::dRuleWed"),b:"wed",o:3},
      {a:toLocale("finStackExt::dRuleThu"),b:"thu",o:4},
      {a:toLocale("finStackExt::dRuleFri"),b:"fri",o:5},
      {a:toLocale("finStackExt::dRuleSat"),b:"sat",o:6}
    ]
    days: []
    sched->scheduleGrid.colToList("weekdays").unique.findAll(x=> x != null and not x.contains(",")).each x=> do
      days = days.add(translate.find(y=> y->b == x))
    end

    days = days.sort((x,y)=> x->o <=> y->o)

    body:[
      {name: "parentDay", editorType: "combobox", prompt: toLocale("j2FinToolsExt::dayToDuplicate")+":", dataProvider: days.toAxonCode, labelField: "a", selectedValueTags: "b", defIndex: 0},
      {
        name: "childDays",
        editorType: "list",
        prompt: toLocale("j2FinToolsExt::duplicateTo")+":",
        dataProvider: translate.toAxonCode+".findAll(x=> x->b != \$parentDay)",
        labelField: "a",
        selectedValueTags: "b",
        listType: "checkbox",
        height: 145
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    {"dis": toLocale("j2FinToolsExt::duplicateScheduleDay") + ": " + sched.dis,
    "name": "finFormDuplicateScheduleDay",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finFormDuplicateScheduleDay(@"+id+",[\$parentDay, \$childDays])",
    "completeAction": "setTimeout(function(){ window.app.OpenScheduleWithIdAndRef('@"+id+"', 'null'); app.set({viewMode: 'mini-app'}); app.HideMainMenu(); }, 100);",
    "finForm": marker(),
    }.toGrid.addMeta({formExecute: marker()})
  end
  else do
    days: sched->scheduleGrid.toRecList
    parentDays: days.toGrid.finGridFilter(weekdays == data[0]).toRecList
    insertAll: (v,i,t)=> do //auxiliary insertAll function that actually works
      a: []
      v.each((x,y)=> do
        if(y==i) t.each z=> a = a.add(z)
        a = a.add(x)
      end)
      a
    end
    fixDis: (g,h)=> do
      if(g.has("dis")) do
        d: g->dis
        l: [ //weekday derivatives
          ["monday","mon"],
          ["tuesday","tues","tue"],
          ["wednesday","wed"],
          ["thursday","thurs","thu"],
          ["friday","fri"],
          ["saturday","sat"],
          ["sunday","sun"]
        ]

        (0..l.size - 1).each x=> do
          (0..l[x].size - 1).each y=> do
            i: d.lower.index(l[x][y])
            if(i != null) do
              u: (i .. l[x][y].size - 1).map z=> d[z].isUpper //generate uppercase map
              h2: (0..h.size - 1).map(z=> if(u[z]) h[z..z].upper else h[z..z]).concat("") //style week name with uppercase
              d = d.replace(d[i..l[x][y].size - 1], h2) //split string and put this in //[0 .. 0 + 2 - 1]
            end
          end
        end
        g = g.set("dis",d)
      end
      g.set("weekdays",h)
    end
    data[1].each x=> do
      ind: days.toGrid.colToList("weekdays").index(x) //find index of first one
      if(ind == null) ind = days.toGrid.colToList("weekly").indexr(marker()) //correct if day doesn't already exist
      days = days.toGrid.finGridFilter(not weekdays or weekdays != x).toRecList //remove them from schedule
      days = days.insertAll(ind, parentDays.map(y=> y.fixDis(x))) //insert into index while changing weekdays to x
    end
    sched.diff({scheduleGrid: days.toGrid}).commit //write back to record
  end
end


def ​

func:finFormEliminateOrphans ​

finFormEliminateOrphans() ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormEliminateOrphans
distoLocale("j2FinToolsExt::removeOrphanRecords")
folderPathtoLocale("j2FinToolsExt::databaseCleanUp")
isfunc
liblib:finTools
namefinFormEliminateOrphans

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  orphNum: 0
  lint(null).each x=> if(contains(x->msg, "Unknown rec for") and not contains(x->msg, "weatherRef")) orphNum = orphNum + 1

  body: [
    {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::orphanPointsAffected").replace("{count}", orphNum.toStr)},
    {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::confirmOrphanRemoval")},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::no"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::yes"), controlBar: true}
  ]

  {
    "dis": toLocale("j2FinToolsExt::removeOrphanRecords"),
    "name": "finFormEliminateOrphans",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "lint(null).each x=> if(contains(x->msg, \"Unknown rec for\") and not contains(x->msg, \"weatherRef\")) builderAppTrash(\"\",x->targetRef,false)",
    "helpDoc":"/wiki/display/FINStack/Remove+Orphan+Records",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormEquipAuditLog ​

finFormEquipAuditLog(id, data: null, date: null) ​

This function takes an ID, and will you the audit log for what has been changed in the time period.


meta ​

constructfinFormEquipAuditLog(read(equip)->id)
deffunc:finFormEquipAuditLog
distoLocale("j2FinToolsExt::auditLog")
hideMobile✓
isfunc
liblib:finTools
namefinFormEquipAuditLog
obsolete✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, data:null,date:null) => do
  //formOn:site or floor or equip
  rec: id.toRec()
  if(data == null)
  do
    rstr:[
      {val:"All",opt:""},
      {val:"Login",opt:"login"},
      {val:"Login by user",opt:"login:"},
      {val:"Commit",opt:"commit"},
      {val:"Commit by user",opt:"commit:"},
      {val:"Action",opt:"action"},
      {val:"Action by user",opt:"action:"},
      {val:"Target",opt:rec.dis()}
    ].toJSON

    body: [
      {name: "opt", editorType: "combobox", prompt:"Options", dataProvider:rstr,
        labelField: "val", selectedValueTags: "opt"},
      {name: "date", editorType: "combobox", prompt: toLocale("j2FinToolsExt::finSelectYourDateRange"), dataProvider: "[{val:\"today\"},{val:\"yesterday\"},{val:\"thisWeek\"},{val:\"lastWeek\"},{val:\"thisMonth\"},{val:\"lastMonth\"}]", labelField: "val", selectedValueTags: "val"},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    return {
      "dis": toLocale("j2FinToolsExt::finShowMeAudit") + " " + rec.dis(),
      "name": "finFormEquipAuditLog",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "if(\$opt.contains(\":\")) finFormEquipAuditLog(@"+ id + ",\$opt,\$date)  else read(site)",
      "gotoAction": "finstack:folio:axonQuery=logRead(\$date).findAll r => r->category.contains(\"audit\") and r->msg.contains(\"\$opt\")",
      "helpDoc":"/wiki/display/FINStack/Equip+Audit+Log",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})

  end
  else do
    users: userReadAll().toRecList.map( u => {dis: u.dis, username: data + " " + u->username}).add({dis:"su", username:data + " su"})
    body: [
      {name: "user", editorType:"combobox", prompt:"User", dataProvider: users.toJSON,
        labelField: "dis", selectedValueTags: "username"},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    return {
      "dis": toLocale("j2FinToolsExt::finShowMeAudit") + " " + rec.dis(),
      "name": "finFormEquipAuditLog1",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "read(site)",
      "gotoAction": "finstack:folio:axonQuery=logRead(" + date + ").findAll r => r->category.contains(\"audit\") and r->msg.contains(\"\$user\")",
      "helpDoc":"/wiki/display/FINStack/Equip+Audit+Log",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finFormEquipPointTagClone ​

finFormEquipPointTagClone(id) ​

Axon function


meta ​

deffunc:finFormEquipPointTagClone
distoLocale("j2FinToolsExt::clonePointsToEquip")
folderPathtoLocale("j2FinToolsExt::batchEditAndClone")
formOnequip
isfunc
liblib:finTools
namefinFormEquipPointTagClone

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  body: [
    {
      name: "selectAllPoint",
      editorType:"combobox",
      prompt: toLocale("j2FinToolsExt::selectPoints") + ":",
      dataProvider:[{dis:"none",val:false},{dis:toLocale("j2FinToolsExt::allPoints"),val:true}].toAxonCode,
      labelField:"dis",
      selectedValueTags:"val",
      defIndex:0
    },
    {
      name: "pointsInEquip",
      editorType: "list",
      listType: "checkbox",
      prompt: toLocale("j2FinToolsExt::selectPointsToClone") + ":",
      toolTip: "click on this to refresh other lists",
      height: 180,
      dataProvider: "readAll(point and equipRef == @" + id + ").sort(\"navName\").map(r=>r.set(\"selected\",false or \$selectAllPoint))",
      labelField: "navName",
      selectedValueTags: "id",
      defValTagName: "selected"
    },
    {
      name: "applyToAll",
      editorType:"checkbox",
      label: toLocale("j2FinToolsExt::applyToAllMarkers"),
      defVal:true
    },
    {
      name: "tagsToClone",
      editorType: "list",
      prompt:toLocale("j2FinToolsExt::selectMarkersToClone") + ":",
      listType:"checkbox",
      height: 180,
      dataProvider: "finFormEquipPointTagsProvider(\$pointsInEquip,markerOnly).map(r=>r.set(\"selected\",true and \$applyToAll))",
      labelField: "name",
      selectedValueTags: "name",
      defValTagName: "selected"
    },
    {
      name: "applyToAllProps",
      editorType:"checkbox",
      label: toLocale("j2FinToolsExt::applyToAllProperties"),
      defVal:true
    },

    {
      name: "propTagsToClone",
      editorType: "list",
      listType: "checkbox",
      prompt: toLocale("j2FinToolsExt::selectPropertiesToClone") + ":",
      height: 180,
      dataProvider: "finFormEquipPointTagsProvider(\$pointsInEquip,hideRef).map(r=>r.set(\"selected\",true and \$applyToAllProps) )",
      labelField: "name",
      selectedValueTags: "name",
      defValTagName: "selected"
    },
    {
      name: "copyPoints",
      editorType:"checkbox",
      label: toLocale("j2FinToolsExt::copyPoints"),
      defVal:false
    },
    {
      name: "equipFilter",
      editorType: "filter",
      prompt:toLocale("j2FinToolsExt::equipFilter"),
    },
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
  ]

  { "dis": toLocale("j2FinToolsExt::clonePointsToEquip"),
    "height":600,
    "name": "cloneEquipPoints",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finEquipPointTagClone(@" + id + ",\$pointsInEquip,addAll(\$tagsToClone,\$propTagsToClone),\$equipFilter,\$copyPoints)",
    "helpDoc": "/wiki/display/FINStack/Clone+Points+To+Equip",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})

end


def ​

func:finFormEquipPointTagsProvider ​

finFormEquipPointTagsProvider(pointsInEquip, hideTagFilter) ​

Axon function


meta ​

deffunc:finFormEquipPointTagsProvider
isfunc
liblib:finTools
namefinFormEquipPointTagsProvider
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(pointsInEquip,hideTagFilter) => do

  if(pointsInEquip != null and pointsInEquip.size > 0) do
    pointsFilter: pointsInEquip.map() (id => "(id == @" + id + ")").concat(" or ")
    return try do readAllTagNames(parseFilter(pointsFilter))
      .findAll(r => do
        show: (hideTagFilter==null or (not hideTagFilter(r)))
        blacklist:finIsTagBlackList(r->name)
        //echo(r->name +" is " + blacklist)
        return ((not blacklist) and show)
      end)
      .sort("name")
    end catch []
  end
  return []
end


def ​

func:finFormFuncs ​

finFormFuncs() ​

Axon function


meta ​

advanced✓
deffunc:finFormFuncs
hideFromMobileDB✓
isfunc
liblib:finTools
namefinFormFuncs

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body: [
    {name: "function", editorType: "combobox", prompt:toLocale("j2FinToolsExt::formToRun") + ":", dataProvider: "ioReadTrio(`io/test.trio`)", labelField: "dis", selectedValueTags: "name"},
    {name: "text", editorType: "textinput", prompt: toLocale("j2FinToolsExt::optionalFormToRun") + ":"},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::folioQueryRun"), controlBar: true}
  ]

  { "dis": toLocale("j2FinToolsExt::functionsForm"),
  "name": "finFormWriteLevels",
  "body": body.toJSON,
  "cancelButton": "\$cancelButton",
  "commitButton": "\$applyButton",
  "commitAction": "if(\$text.size > 0) eval(\$text) else eval(\$function)",
  "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormHaystackSyncToNiagara ​

finFormHaystackSyncToNiagara(stuff: null) ​

Applies tags made in FIN|Framework to the connector in Niagara


meta ​

appFormOnfolio
deffunc:finFormHaystackSyncToNiagara
distoLocale("j2FinToolsExt::haystackSyncToNiag")
folderPathtoLocale("finStackExt::rightMenuConnectors")+"/"+toLocal...
isfunc
liblib:finTools
namefinFormHaystackSyncToNiagara

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stuff: null) => do
  if(not stuff.isGrid) do
    body: [
      {name: "conn", editorType: "combobox", prompt: toLocale("j2FinToolsExt::selectHaystackConn"), dataProvider:"readAll(haystackConn)", labelField: "id", selectedValueTags: "id", defIndex: 0},
      {name: "filter", editorType: "filter", prompt: toLocale("finStackExt::finFilter")},

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    { "dis": toLocale("j2FinToolsExt::haystackSyncToNiag"),
      "name": "finHaystackSuncToNiagaraForm",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "finNHaystackApplyFolioFilter(readById(\$conn), \"haystackConnRef==\" + \$conn + \" and \" + \$filter).finFormHaystackSyncToNiagara",
      "helpDoc": "/wiki/display/FINStack/Sync+tags+to+Niagara",
      "helpDoc":"/wiki/display/FINStack/Haystack+Sync+to+Niagara",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
  ////////////////////
  else if(stuff.isGrid) do
    body: [
    {name: "filter", editorType: "label", text: toLocale("j2FinToolsExt::rowsWereChanged").replace("{count}", stuff[0]->rowsChanged.toStr)},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]

    { "dis": toLocale("j2FinToolsExt::haystackSyncToNiag"),
      "name": "finHaystackSuncToNiagaraForm",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "helpDoc": "/wiki/display/FINStack/Sync+tags+to+Niagara",
      "helpDoc":"/wiki/display/FINStack/Haystack+Sync+to+Niagara",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finFormHisImport ​

finFormHisImport(stage: null, dat: null) ​

Form to import history from a CSV file into a point.

-This form will only work with one point at a time. -The point should have collected history or another writable history (should work with hisWrite or hisRewrite) -CSV file should have at least two columns, one datetime column and one value column -Write mode used if there is no history for the file's time range, rewrite mode used to rewrite time ranges that already exist -Data type must be specified


meta ​

appFormOnfolio
deffunc:finFormHisImport
distoLocale("j2FinToolsExt::importHistory")
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
isfunc
liblib:finTools
namefinFormHisImport
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, dat: null) => do
  query:{ "dis": toLocale("j2FinToolsExt::importHistory"),
          "name": "finFormHisImport"+random(0..10000),
          "cancelButton": "\$cancelButton",
          "commitButton": "\$applyButton",
          "helpDoc": "/wiki/display/FINStack/Import+History",
          "finForm": marker() }
  body: []
  form: true

  if(index([1,2,3],stage)==null) do //upload file and choose point
    body = [
    {name: "file", editorType: "file", prompt: toLocale("j2FinToolsExt::csvHisFile") + ":", fileTypes: ["csv"], toolTip: "CSV file containing times and history values"},
    {name: "filt", editorType: "filter", prompt: toLocale("finStackExt::pointFilter"), toolTip: "Filter must be for points with writable history"},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]
    query = query.set("commitAction", "finFormHisImport(1, [\$filt, \$file])")
  end
  //////////////////////
  else if(stage == 1) do //select column and mode, or error
    try cnt: readCount(parseFilter(dat[0]+" and point")) catch cnt: 0
    if(dat.size == 2 and cnt > 0 and ioBin(dat[1], "file").ioReadCsv.colNames.size >= 2) do
      d: ["Number","Boolean"].map((x,y)=> {a: x, b: y})
      cnames: ioBin(dat[1],"file").ioReadCsv.colNames
      body = [
        {name: "time", editorType: "combobox", prompt: toLocale("j2FinToolsExt::timeCol") + ":", dataProvider: cnames.toAxonCode, labelField: "val", selectedValueTags: "val", defIndex: 0},
        {name: "oper", editorType: "radio", prompt:  toLocale("j2FinToolsExt::operation") + ":", label:  toLocale("j2FinToolsExt::rewrite"), selectedValue: "rewrite", defVal: true},
        {name: "oper", editorType: "radio", label: toLocale("j2FinToolsExt::write"), selectedValue: "write"},
        {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
        {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
      ]

      comact: "[jobRun( finFormHisImport(2, ["+dat[1].toAxonCode+", \$time, \$oper, ["
      cou: 1
      ocou: 0
      readAll(parseFilter("("+dat[0]+") and point")).map(x=> x.set("dis",x.dis)).sort("dis").each x=> do
        body = body.addAll([
          {name: "sepr", editorType: "separator", label: x.dis},
          {name: ocou+"valu", editorType: "combobox", prompt: toLocale("j2FinToolsExt::valCol") + ":", dataProvider: cnames.toAxonCode, labelField: "val", selectedValueTags: "val", defIndex: cou},
          {name: ocou+"type", editorType: "combobox", prompt: toLocale("j2FinToolsExt::valType") + ":", dataProvider: d.toAxonCode, labelField: "a", selectedValueTags: "b", defIndex: 0}
        ])
        comact = comact + "{id: @"+x->id+", type: \$"+ocou+"type, val: \$"+ocou+"valu},"
        if(cou < cnames.size - 1) cou = cou + 1
        ocou = ocou + 1
      end

      query = query.set("commitAction", comact+"]]) ), finFormHisImport(3)][1]")
    end
    else do
      if(dat.size == 1) reason:toLocale("finStackExt::folioRestoreNoFile")
      else if(cnt == 0) reason:toLocale("finStackExt::noPtsFound")
      else reason: toLocale("j2FinToolsExt::csvLessThanTwoCols")
      body = [
      {name: "label", editorType: "label", text: reason},
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
      ]
      query = query.remove("commitButton")
    end
  end
  //////////////////////
  else if(stage == 2) do //run import
    outp: []
    cou: 0%
    sze: 100 / dat[3].size

    dat[3].each x=> do
      jobProgress(cou,toLocale("finStackExt::workingLoader"))

      d: ["number","bool"][x->type]
      try stuff: finHisImport(x->id, ioBin(dat[0],"file"), dat[2], {ts: dat[1], val: x->val}, d) catch(e) do
        outp = outp.add({id: x->id, error: e->dis})
        /*stuff: e->dis.replace("\n"," - ")
        if(stuff.contains("rewrite computed")) stuff = "History cannot be computed"
        else if(stuff.contains("Mismatched tz")) stuff = "Timezone of file doesn't match timezone of point"
        else if(stuff.contains("Missing 'his' tag")) stuff = "Point not configured for history"
        else if(not stuff.isStr) stuff = "Unknown Error"*/
      end

      cou = cou + sze
    end
    if(outp.size > 0) diff(null,{finFormHisImport, result: outp.toJSON},{add}).commit
    form = false
  end
  //////////////////////
  else if(stage == 3) do //report output
    body = [
      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
    ]

    jb: jobStatusAll().findAll(x=> x->dis.contains("finFormHisImport")).sortr("started")[0]
    if(jb->progress < 100%) do
      p: jb->progressMsg.trim
      if(p == "") p = toLocale("j2FinToolsExt::runningMsg")
      body = body.addAll([{name: "label", editorType: "label", text: p},
        {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreRefresh"), controlBar: true}])
    end else do
      body = body.add({name: "label", editorType: "label", text: toLocale("j2FinToolsExt::complete")})
      if(readCount(finFormHisImport) > 0) do
        body = body.addAll([{name: "label", editorType: "label", text: toLocale("j2FinToolsExt::followingErrorsOccured")},
          {name: "table", editorType: "table", dataProvider: "[read(finFormHisImport)->result.fromJSON, readAll(finFormHisImport).finHardDelete][0]"}])
      end else body = body.add({name: "label", editorType: "label", text: toLocale("j2FinToolsExt::importedSuccessfully")})
    end

    query = query.set("commitAction","finFormHisImport(3)")
  end
  ///
  if(form) query.set("body", body.toJSON).toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormManageZincLibrary ​

finFormManageZincLibrary(stage: null, choice: null, ids: null, type: null) ​

Form to manage the records within the io/Records.zinc libraries


meta ​

appFormOnfolio
batchRecords✓
deffunc:finFormManageZincLibrary
distoLocale("j2FinToolsExt::manageSavedRecords")
folderPathtoLocale("j2FinToolsExt::createBatchRecords")
formOnsite or floor or equip or (point and not schedule)
helpQuickly rename or delete records for the zinc template.
isfunc
liblib:finTools
namefinFormManageZincLibrary

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, choice: null, ids: null, type: null) => do
  body: []
  cmdStr: ""
  fname: "finFormManageZincLibrary"
  buttonName: ""

  if(stage != "two" and stage != "three") do //display stage
    body = [
      {
        name: "radbut",
        editorType: "radio",
        prompt: toLocale("finStackExt::action"),
        label: toLocale("finStackExt::rename"),
        selectedValue: "rename",
        defVal: true
      },

      {
        name: "radbut",
        editorType: "radio",
        label: toLocale("finStackExt::delete")+":",
        selectedValue: "delete"
      },

      {
        name: "listt",
        editorType: "list",
        prompt: toLocale("finStackExt::fileName")+":",
        labelField: "val",
        selectedValueTags: "val",
        defIndex: 0,
        height: 50,
        //dataProvider: "[{val: \"Point\", fld: \"io/PointRecords.zinc\"}, {val: \"Equip\", fld: \"io/EquipRecords.zinc\"}].toGrid"},
        dataProvider: "ioDir(`io/`).findAll(x=> x->name.contains(\"Libraries\")).colToList(\"uri\").map(x=> ioDir(x).colToList(\"uri\").concat(\"\\n\")).concat(\"\\n\").split(\"\\n\")"
      },

      {
        name: "levels",
        editorType: "list",
        prompt: toLocale("j2FinToolsExt::pointsToApplyAction")+":",
        listType: "checkbox",
        dataProvider: "try ioReadZinc(parseUri(\$listt)).map(p => if(p.has(\"navName\")) p else p.set(\"navName\", p.dis)).sort(\"navName\") catch {}",
        labelField: "navName",
        selectedValueTags: "id"
      }
    ]

    buttonName = toLocale("finStackExt::ok")
    cmdStr = fname+"(\"two\", \$radbut, \$levels, \$listt)"
  end // end not 1 or 2

  else if(stage == "two") do //action stage
    try zinc: ioReadZinc(parseUri(type)).map(p => if(p.has("navName")) p else p.set("navName", p.dis))
    catch zinc: [].toGrid

    if(choice == "rename") do
      num: 0
      cmdSub: ""

      ids.each x=> do
        body = body.add({
          name: toStr(num)+"txtbox",
          editorType: "textinput",
          prompt: zinc.find(y=> y->id == x)->navName
        })

        cmdSub = cmdSub +"[@"+x+",\$"+toStr(num)+"txtbox],"
        num = num + 1
      end

      try cmdSub = cmdSub[0..-2]
      catch cmdSub = ""

      buttonName = toLocale("finStackExt::coreApply")
      cmdStr = fname+"(\"three\", \"rename\", ["+cmdSub+"], "+type.toAxonCode+")"
    end
    else if (choice == "delete") do
      body = [{name: "label", editorType: "label", text: toLocale("j2FinToolsExt::wantToDeleteFollowingPoints")}]

      ids.each x=> do
        body = body.add({name: "label", editorType: "label", text: zinc.find(y=> y->id == x)->navName})
      end

      buttonName = "Yes"
      cmdStr = fname+"(\"three\", \"delete\", "+ids.toAxonCode+", "+type.toAxonCode+")"
    end
  end // end 2

  else if(stage == "three") do //apply stage
    try zinc: ioReadZinc(parseUri(type))
    catch zinc: [].toGrid

    listt: []
    num: 0

    if(choice == "rename") do
      mker: true

      zinc.each x=> do
        mker = true

        ids.each y=> do
          if(x->id == y[0]) do
            listt = listt.add(x.set("navName", y[1]))
            mker = false
            num = num + 1
          end
        end

        if(mker) listt = listt.add(x)
      end

      body = [{name: "label", editorType: "label", text: toLocale("j2FinToolsExt::numPointsRenamed").replace("{count}", toStr(num))}]
      buttonName = toLocale("finStackExt::ok")
      cmdStr = ""
    end

    if(choice == "delete") do
      zinc.each x=> if(ids.index(x->id) == null) listt = listt.add(x) else num = num + 1
      body = [{name: "label", editorType: "label", text: toLocale("j2FinToolsExt::numPointsDeleted").replace("{count}", toStr(num))}]
      buttonName = toLocale("finStackExt::ok")
      cmdStr = ""
    end

    ioWriteZinc(listt.toGrid, parseUri(type))
  end // end 3

  body = body.addAll([
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: buttonName, controlBar: true}
  ])

  {
    "dis": toLocale("j2FinToolsExt::manageSavedRecords"),
    "name": "finFormManageZincLibrary"+stage,
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": cmdStr,
    "helpDoc": "/wiki/display/FINStack/Manage+Saved+Records",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormModBus ​

finFormModBus(id) ​

Axon function


meta ​

appFormOnoldFolio
deffunc:finFormModBus
distoLocale("j2FinToolsExt::modbusUtility")
folderPathtoLocale("finStackExt::rightMenuConnectors") + "/Modbus"...
formOnfoo
isfunc
liblib:finTools
namefinFormModBus

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id)=> do
  data: {
    dis:"Meter-1",
    uri:"modbus-tcp://host/",
    modbusRegMapUri:"data/modbus/xxx.csv",
    modbusSlave:1,
    site:"City Center",
    floor:"Utility",
    tenant:"J2",
    addTags:"modbus,imported:true",
    folderPath:"/folder"
  }

  if(id != null)
  do
    rec:id.toRec
    if(rec.has("floor"))
    do
      site:rec.get("siteRef").toRec
      data = data.set("floor",if(rec.has("navName")) rec.get("navName") else rec.dis).set("site",if(site.has("navName")) site.get("navName") else site.dis)
    end
    else if(rec.has("site"))
    do
      site:rec
      data = data.set("site",if(site.has("navName")) site.get("navName") else site.dis)
    end
  end

  copyTableData:[].add(data)
  body: [
    {
      name: "table",
      editorType: "table",
      prompt: toLocale("j2FinToolsExt::copyPasteTableToExcel") + ":",
      height:60,
      dataProvider:copyTableData.toAxonCode,
      toolTip:"Right click on this grid and click copy. Then paste this into Excel and edit it. After that copy it from excel and paste below."},
    {
      name: "pastedData",
      editorType: "table",
      prompt: toLocale("j2FinToolsExt::pasteExcelTagger") + ":",
      height:150},
    {
      name: "fileList",
      height:150,
      editorType:"list",
      listType: "checkbox",
      dataProvider:"readAll(parseFilter(\"file\")).findAll()(item=>item.dis.contains(\".csv\"))",
      selectedValueTags:"id",
      labelField:"dis",
      prompt:"Select Modbus CSV Files (only FIN Stack and CControls types are supported)"
    },

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  {
     "dis": toLocale("j2FinToolsExt::modbusUtility"),
     "name": "modbusForm",
     "width":700,
     "body": body.toJSON,
     "cancelButton": "\$cancelButton",
     "commitButton": "\$applyButton",
     "commitAction": "finModBusMap(\$pastedData,\$fileList)",
     "finForm": marker(),
     "helpDoc":"/wiki/display/FINStack/Modbus+Utility+Form",
     "refreshTrees": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormNHaystackBatchAdvancedTagEditor ​

finFormNHaystackBatchAdvancedTagEditor(stage: null, one: null, two: null, three: null, conns: null) ​

Searches haystack points with navNames that start with, end with, or contain the specified keywords and adds specified tags to those.


meta ​

appFormOnfolio
deffunc:finFormNHaystackBatchAdvancedTagEditor
distoLocale("j2FinToolsExt::haystackBatchAdvancedTagEditor"...
folderPathtoLocale("finStackExt::rightMenuConnectors")+"/"+toLocal...
isfunc
liblib:finTools
namefinFormNHaystackBatchAdvancedTagEditor

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, one: null, two: null, three: null, conns: null) => do
  doutput:{ "dis": toLocale("j2FinToolsExt::haystackBatchAdvancedTagEditor"),
            "name": "finFormNHaystackBatchAdvancedTagEditor",
            "cancelButton": "\$cancelButton",
            "commitButton": "\$applyButton",
            "finForm": marker()}
  mkquery: (inp, type, cid, lend: false) => do //function to turn string into query
    efilt: ""
    if(inp.has("efilter")) efilt = inp->efilter
    filt: inp->search4
    quer: "readById("+cid+").haystackReadAll(point "+ efilt +").findAll(r=> r.has(\"axType\") and r->axType.contains(\"control\") and (r->navName."+type+"(\"" + filt.split(",").map(q=> trim(q)).concat("\") or r->navName."+type+"(\"") + "\")))"
    if(lend) do //////////////finish this/////////////////
      ids: []
      eval(quer).each t=> ids = ids.add(t->id)
      //quer = quer + ".each x=> x.diff({" + inp->tags2add + "}).commit"
      quer = ["id==@" + ids.concat(" or id==@") , inp->tags2add]
    end
    quer
  end
  ////////////////////////////////
  if(stage != 1 and stage != 2) do //read from file, format data, let users see and edit data
    body: [
    {name: "connectors", editorType: "list", prompt: toLocale("j2FinToolsExt::haystackConnectors"), listType: "checkbox", dataProvider: "readAll(haystackConn)", labelField: "dis", selectedValueTags: "id"},
    {name: "sep", editorType: "separator", label: toLocale("j2FinToolsExt::contains")},
    {name: "1chk", editorType: "combobox", dataProvider: "[{type: "+toLocale("finStackExt::selectAll").toAxonCode +", boole: true},{type: "+toLocale("finStackExt::unselectAll").toAxonCode +", boole: false}]", labelField: "type", selectedValueTags: "boole", defIndex: 0},
    {name: "1xtraRow", editorType: "numericstepper", prompt: toLocale("j2FinToolsExt::extraRows"), minVal: 0},
    {name: "contains", editorType: "list", prompt: "\t\t "+toLocale("j2FinToolsExt::tagsToAdd")+" \t\t\t\t "+toLocale("j2FinToolsExt::contains")+" \t\t\t\t "+toLocale("finStackExt::finFilter"), defValTagName: "selected",
     dataProvider: "if(size([\$1chk]) > 0) finBatchAdvancedTagDP([\$1chk][0], \"contains\", \$1xtraRow) else []",
     itemRenderer: [
      {name: "selected", editorType: "checkbox", enableOn: "selected"},
      {name: "tags2add", editorType: "textinput", text: "\$tagsToAdd"},
      {name: "search4", editorType: "textinput", text: "\$contains"},
      {name: "efilter", editorType: "textinput", text: "\$filter", enableOn: "filter"},
    ]},
    {name: "sep", editorType: "separator", label: toLocale("j2FinToolsExt::startsWith")},
    {name: "2chk", editorType: "combobox", prompt: toLocale("j2FinToolsExt::startsWith"), dataProvider: "[{type: "+toLocale("finStackExt::selectAll").toAxonCode +", boole: true},{type: "+toLocale("finStackExt::unselectAll").toAxonCode +", boole: false}]", labelField: "type", selectedValueTags: "boole", defIndex: 0},
    {name: "2xtraRow", editorType: "numericstepper", prompt: toLocale("j2FinToolsExt::extraRows"), minVal: 0},
    {name: "startsWith", editorType: "list", prompt: "\t\t "+toLocale("j2FinToolsExt::tagsToAdd")+" \t\t\t\t "+toLocale("j2FinToolsExt::startsWith")+" \t\t\t\t "+toLocale("finStackExt::finFilter"), defValTagName: "selected",
     dataProvider: "if(size([\$2chk]) > 0) finBatchAdvancedTagDP([\$2chk][0], \"startsWith\", \$2xtraRow) else []",
     itemRenderer: [
      {name: "selected", editorType: "checkbox", enableOn: "selected"},
      {name: "tags2add", editorType: "textinput", text: "\$tagsToAdd"},
      {name: "search4", editorType: "textinput", text: "\$startsWith"},
      {name: "efilter", editorType: "textinput", text: "\$filter", enableOn: "filter"},
    ]},
    {name: "sep", editorType: "separator", label: toLocale("j2FinToolsExt::endsWith")},
    {name: "3chk", editorType: "combobox", prompt: toLocale("j2FinToolsExt::endsWith"), dataProvider: "[{type: "+toLocale("finStackExt::selectAll").toAxonCode +", boole: true},{type: "+toLocale("finStackExt::unselectAll").toAxonCode +", boole: false}]", labelField: "type", selectedValueTags: "boole", defIndex: 0},
    {name: "3xtraRow", editorType: "numericstepper", prompt: toLocale("j2FinToolsExt::extraRows"), minVal: 0},
    {name: "endsWith", editorType: "list", prompt: "\t\t "+toLocale("j2FinToolsExt::tagsToAdd")+" \t\t\t\t "+toLocale("j2FinToolsExt::endsWith")+" \t\t\t\t "+toLocale("finStackExt::finFilter"), defValTagName: "selected",
     dataProvider: "if(size([\$3chk]) > 0) finBatchAdvancedTagDP([\$3chk][0], \"endsWith\", \$3xtraRow) else []",
     itemRenderer: [
      {name: "selected", editorType: "checkbox", enableOn: "selected"},
      {name: "tags2add", editorType: "textinput", text: "\$tagsToAdd"},
      {name: "search4", editorType: "textinput", text: "\$endsWith"},
      {name: "efilter", editorType: "textinput", text: "\$filter", enableOn: "filter"},
    ]},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
    ]

    doutput = doutput.set("body", body.toJSON).set("height", 735).set("width", 800)
    doutput.set("commitAction", "finFormNHaystackBatchAdvancedTagEditor(1, \$contains, \$startsWith, \$endsWith, \$connectors)").toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 1) do //do a dry run to show how many points affected
    cdstuff: (inputs,types)=> do //function to make list for labels
      inputs = inputs.findAll(g=> g->tags2add != "" and g->search4 != "" and (not g.has("selected") or g->selected))
      tmp: 0
      ctmp: ""
      inputs.each g=> do
        tmp = 0
        conns.each conn => tmp = tmp + eval(mkquery(g, types, conn)+".size")
        if(tmp > 0) ctmp = ctmp + toStr(tmp) + " :\t " + g->search4.split(",").concat(" or ") + "\n"
      end
      if(ctmp == "") ctmp = toLocale("finStackExt::noPtsFound")
      if(conns.size == 0) ctmp = toLocale("j2FinToolsExt::noHaystackConnsSelected")
      if(inputs.size == 0) ctmp = toLocale("j2FinToolsExt::noSearchParamsForCategory")
      ctmp
    end

    body: [
    {name: "label", editorType: "label", prompt: "contains", text: one.cdstuff("contains")},
    {name: "label", editorType: "label", prompt: "startsWith", text: two.cdstuff("startsWith")},
    {name: "label", editorType: "label", prompt: "endsWith", text: three.cdstuff("endsWith")},
    {name: "label", editorType: "label", prompt: toLocale("j2FinToolsExt::clickApplyToAddTagsToPoints")},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ]

    doutput = doutput.set("body", body.toJSON).set("width", 850)
    doutput.set("commitAction", "finFormNHaystackBatchAdvancedTagEditor(2, "+one.toAxonCode+", "+two.toAxonCode+", "+three.toAxonCode+", "+conns.toAxonCode+")").toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(stage == 2) do //apply the changes and stuff
    gridstuff: []
    filts: ""
    tags: ""
    temps: []
    functhing: (a,b)=> do
      a = a.findAll(g=> g->tags2add != "" and g->search4 != "" and (not g.has("selected") or g->selected))
      a.each y=> do
        conns.each conn=> do //apply the tags
          temps = mkquery(y, b, conn, true)
          //echo(temps[0].toAxonCode)
          readById(conn).finNHaystackApplyBatchTags(temps[0], temps[1])
        end
        tags = y->tags2add
        filts = y->search4.split(",").map(w=> w.trim)
        if(b == "contains") filts.each c=> gridstuff = gridstuff.add({navName: ".*("+c+")+.*", addTags: tags})
        else if(b == "startsWith") filts.each c=> gridstuff = gridstuff.add({navName: "("+c+").*", addTags: tags})
        else if(b == "endsWith") filts.each c=> gridstuff = gridstuff.add({navName: ".*("+c+")", addTags: tags})
      end
    end

    if(one.findAll(r=> not r.has("selected") or r->selected).size != 0) functhing(one, "contains")
    if(two.findAll(r=> not r.has("selected") or r->selected).size != 0) functhing(two, "startsWith")
    if(three.findAll(r=> not r.has("selected") or r->selected).size != 0) functhing(three, "endsWith")

    gridstuff.toGrid.ioWriteCsv(`io/output.csv`)
  end
end


def ​

func:finFormNavMeta ​

finFormNavMeta(refill: null) ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormNavMeta
distoLocale("j2FinToolsExt::changeNavMeta")
folderPathtoLocale("j2FinToolsExt::databaseCleanUp")
isfunc
liblib:finTools
namefinFormNavMeta

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(refill: null) => do
  formName: "finFormNavMeta"
  newLevelDef: ""
  parentDef: 0
  optionalDef: false

  if (refill != null)
  do
    newLevelDef = refill->level
    parentDef = read(navMeta)->equipPath.split("/").index(refill->parent)
    optionalDef = refill->optional
    formName =  formName + random(1..10000)
  end

  body: [
    {
      name: "levelToAdd",
      editorType: "textinput",
      prompt: toLocale("j2FinToolsExt::enterNavLevelName")+":",
      defVal: newLevelDef
    },

    {
      name: "navMetaList",
      editorType: "combobox",
      prompt: toLocale("j2FinToolsExt::selectParentLevel") + ":",
      dataProvider:"finNavMetaGetLevels(true)",
      labelField: "name",
      selectedValueTags: "name",
      defIndex: parentDef
    },

    {
      name: "group",
      editorType: "group",
      horizontal,
      children: [
        {
          name: "removeLevel",
          editorType: "checkbox",
          label: toLocale("j2FinToolsExt::removeLevel"),
          defVal: false
        },

        {
          name: "isOptional",
          editorType: "checkbox",
          label: toLocale("j2FinToolsExt::makeOptional"),
          defVal: optionalDef
        }
      ]
    },

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  if (refill != null)
    body = body.insert(0, {
      name: "errMsg",
      editorType: "label",
      text: if (refill->parent.startsWith("[")) toLocale("j2FinToolsExt::optionalLevelsMustHaveParent") else toLocale("j2FinToolExt::optionalLevelsCannotStartOrEnd")
    })

  {
    "dis": toLocale("j2FinToolsExt::changeNavMeta"),
    "name":  formName,
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finNavMetaCommit(\$levelToAdd, \$removeLevel, \$navMetaList, \$isOptional)",
    "helpDoc":"/wiki/display/FINStack/Change+Nav+Meta",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormNewOrEditTuningPolicy ​

finFormNewOrEditTuningPolicy() ​

Axon function


meta ​

appFormOnfolio, builder
deffunc:finFormNewOrEditTuningPolicy
distoLocale("j2FinToolsExt::createEditTunigPolicy")
folderPathtoLocale("finStackExt::rightMenuConnectors")+"/"+toLocal...
helpThis form let's you create a new tuning policy. Try to u...
isfunc
liblib:finTools
namefinFormNewOrEditTuningPolicy

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body:[
    { name: "policiesCombo",
      editorType: "combobox",
      prompt: toLocale("j2FinToolsExt::selectTuningPolicy") + ":",
      dataProvider: "[{dis: toLocale(\"j2FinToolsExt::createNewTuningPolicy\"), id: 0}].addAll(readAll(connTuning).toRecList)",
      defIndex: 0,
      lableField: "dis",
      selectedValueTags: "id"
    },

    { name:"cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true, },
    { name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true, }
  ]

  { "dis": toLocale("j2FinToolsExt::createEditTunigPolicy"),
    "name": "tuningPolicy",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finFormCreateTuningPolicy(\$policiesCombo)",
    "helpDoc":"/wiki/pages/viewpage.action?pageId=7045163",
    "finForm": marker(),
    "helpDoc":"/wiki/display/FINStack/Create-Edit+Tuning+Policy"
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormNoteTags ​

finFormNoteTags(id, selectedDicts) ​

Axon function


meta ​

deffunc:finFormNoteTags
distoLocale("j2FinToolsExt::applyNoteTags")
formOnnote
isfunc
liblib:finTools
namefinFormNoteTags

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, selectedDicts) => do
  selectedIds : ["@"+id.toStr]
  if(selectedDicts != null)
    selectedIds= selectedDicts.map(r => "@" + r->id)
  rec:read(parseFilter("noteTags"),false)
  if(rec == null) do
    commit(diff(null,{"noteTags":"hvac,lighting,emergency"},{add}))
  end

  body:[
    {
      name: "tagsList",
      editorType: "list",
      listType:"checkbox",
      height: 150,
      labelField:"val",
      selectedValueTags:"val",
      dataProvider: "read(noteTags)->noteTags.split(\",\")"
    },
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"),  controlBar: true}
  ]

  { "dis":toLocale("j2FinToolsExt::applyNoteTags"),
    "name":"NoteTagsForm",
    "body":body.toJSON,
    "cancelButton":"\$cancelButton",
    "commitButton":"\$applyButton",
    "commitAction":"finApplyNoteTags("+ selectedIds.toAxonCode + ",\$tagsList)",
    "helpDoc": "/wiki/display/FINStack/Tags+for+Note",
    "finForm":marker()
  }.toGrid.addMeta({formExecute:marker()})
end


def ​

func:finFormPointNotTz ​

finFormPointNotTz() ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormPointNotTz
distoLocale("j2FinToolsExt::fixTimezoneTags")
folderPathtoLocale("j2FinToolsExt::databaseCleanUp")
isfunc
liblib:finTools
namefinFormPointNotTz

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
//fixes all points that do not have a time zone

  body: [
    {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::fixMissingTzTags")},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::no"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::yes"), controlBar: true}
  ]

  { "dis":toLocale("j2FinToolsExt::fixTimezoneTags"),
    "name": "finFormPointNotTz",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finPointNotTz()",
    "helpDoc":"/wiki/display/FINStack/Fix+Timezone+Tags",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})

end


def ​

func:finFormPointNotUnit ​

finFormPointNotUnit(stage: null) ​

Axon function


meta ​

appFormOnfolio
deffunc:finFormPointNotUnit
distoLocale("j2FinToolsExt::addPointUnits")
folderPathtoLocale("j2FinToolsExt::databaseCleanUp")
isfunc
liblib:finTools
namefinFormPointNotUnit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null) => do
  body: []
  query:{ "dis": toLocale("j2FinToolsExt::addPointUnits"),
          "name": "finFormPointNotUnit",
          "cancelButton": "\$cancelButton",
          "commitButton": "\$applyButton",
          "commitAction": "",
          "helpDoc":"/wiki/display/FINStack/Fix+Unit+Tags",
          "finForm": marker() }

  if(stage != 1) do
    body = [ {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::clickOkToFixNumericPoints")} ]

    query = query.set("commitAction", "finFormPointNotUnit(1)")
  end
  //-----------------------------------------------------------//
  else if(stage == 1) do
    uunit: ""
    readAll(point and not unit and kind=="Number").each x=> do
      uunit = ""
      if(x.has("chilled") and x.has("water") and not x.has("temp")) uunit = "%" //CHWV
      else if(x.has("filter")) uunit = "%" //Filter
      else if(x.has("air") and x.has("damper") and x.has("mixed")) uunit = "%" //MAD
      else if(x.has("air") and x.has("mixed") and x.has("temp")) uunit = "°F" //MAT
      else if(x.has("air") and x.has("outside") and x.has("damper")) uunit = "%" //OAD
      else if(x.has("air") and x.has("return") and x.has("damper")) uunit = "%" //RAD
      else if(x.has("air") and x.has("return") and x.has("temp")) uunit = "°F" //RAT
      else if(x.has("air") and x.has("flow") and x.has("sensor")) uunit = "cfm" //SAF and AirFlow
      else if(x.has("air") and x.has("sensor") and x.has("pressure")) uunit = "inHg" //SAP
      else if(x.has("sensor") and x.has("air") and x.has("temp") and not x.has("discharge")) uunit = "°F" //SAT
      else if(x.has("zone") and x.has("air") and x.has("temp") and x.has("sensor")) uunit = "°F" //ZoneTemp and Room Temp
      else if(x.has("zone") and x.has("air") and x.has("temp") and x.has("sp")) uunit = "°F" //Room Setpoint and ZoneTempSp and EffectiveSp
      else if(x.has("air") and x.has("flow") and x.has("sp")) uunit = "cfm" //AirFlow Setpoint
      else if(x.has("air") and x.has("damper") and x.has("discharge")) uunit = "%" //Damper
      else if(x.has("occ") and x.has("cooling")) uunit = "°F" //OccCool
      else if(x.has("occ") and x.has("heating")) uunit = "°F" //OccHeat
      else if(x.has("reHeat")) uunit = "%" //ReHeat Valve
      else if(x.has("air") and x.has("zone") and x.has("humidity")) uunit = "%" //Rm Humidity
      else if(x.has("delta") and x.has("temp") and x.has("zone")) uunit = "°F" //Room Delta Temp
      else if(x.has("unocc") and x.has("cooling")) uunit = "°F" //UnOccCool
      else if(x.has("unocc") and x.has("heating")) uunit = "°F" //UnOccHeat
      if(uunit != "") x.diff({}.set("unit", uunit)).commit
    end

    body = [ {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::clickOkToSeeUnassignedPoints")} ]

    query = query.set("gotoAction", "finstack:folio:axonQuery=readAll(point and not unit and kind==\"Number\")").set("dis", query->dis+" Results")
  end

  body = body.addAll([
  {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
  {name: "applyButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true} ])
  query.set("body", body.toJSON).toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormPointPriorityViewer ​

finFormPointPriorityViewer(inp: null, sec: null) ​

Form to view and auto points with priorities


meta ​

appFormOnfolio
deffunc:finFormPointPriorityViewer
distoLocale("j2FinToolsExt::pointPriorityViewer")
isfunc
liblib:finTools
namefinFormPointPriorityViewer

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(inp: null, sec: null) => do
  query:{ "dis": toLocale("j2FinToolsExt::pointPriorityViewer"),
          "name": "finFormPointPriorityViewer",
          "cancelButton": "\$cancelButton",
          "commitButton": "\$applyButton",
          "commitAction": "",
          "helpDoc":"/wiki/display/FINStack/Point+Priority+Viewer",
          "finForm": marker() }

  if(not inp.isList and not inp.isBool) do
    str: "["
    (1..16).each x=> do
      str = str + "{val: "+x+", nums: try readCount(\$filter.parseFilter and point and writeLevel=="+x+") catch 0},"
    end
    str = str + "{val: 17, nums: try readAll(\$filter.parseFilter and point and writeLevel==17).findAll(h=> (h.pointWriteArray.find(j=> j.has(\"val\") and j->val != null) != null)).size catch 0}"
    str = str + "].findAll(x=> (x->nums != 0))"

    body:[
    {name: "filter", editorType: "filter", prompt:toLocale("j2FinToolsExt::searchPointPriorities")+":", defVal: "point"},
    {name: "list", editorType: "list", dataProvider: str,
      itemRenderer: [
      {name: "cbox", editorType: "checkbox"},
      {name: "priority", editorType: "label", text: toLocale("j2FinToolsExt::priorityVals").replace("{val}","\$val")},
      {name: "nums", editorType: "label", text: "\$nums"}
      ]},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::view"), controlBar: true}
    ]

    query.set("body", body.toJSON).set("commitAction", "finFormPointPriorityViewer(\$list, \$filter)").toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(inp.isList) do
    body: []
    aall: false
    inp = inp.findAll(x=> x->cbox)
    if(inp.size > 1) do
      body = [{name: "aall", editorType: "checkbox", label: toLocale("j2FinToolsExt::autoAllDisplayedPoints")}]
      aall = true
    end
    cstr: "["
    num: 0
    dp: []
    tmp: ""
    tmp2: ""
    inp.each x=> do
      dp = []
      tmp = readAll(parseFilter(sec) and point and writeLevel==parseNumber(x->priority[9..-1]))
      tmp.each y=> do
        tmp2 = y.pointWriteArray.renameCol("val", "writeVal").find(g=> (g.has("writeVal") and g->writeVal != null))
        if(tmp2 != null) do
          tmp2 = try tmp2.set("name", y.dis) catch tmp2.set("name", "null") //name the row
          tmp2 = try tmp2.set("curVal", y->curVal) catch tmp2.set("curVal", 0) //give row curval
          if(tmp2.has("expires")) dp = dp.add({name: tmp2->name, curVal: tmp2->curVal, writeVal: tmp2->writeVal, user: tmp2->who, expires: tmp2->expires})
          else dp = dp.add({name: tmp2->name, curVal: tmp2->curVal, writeVal: tmp2->writeVal, user: tmp2->who})
        end
      end
      dp = dp.sort((x,y)=> x->name <=> y->name)

      num = num + 1
      cstr = cstr + "[\$"+num+"cbox, "+sec.toAxonCode+"+\" and point and writeLevel=="+x->priority[9..-1]+"\", "+x->priority[9..-1]+"],"
      body = body.addAll([
      {name: num+"cbox", editorType: "checkbox", label: toLocale("j2FinToolsExt::autoPointsAtLevel").replace("{level}",x->priority)},
      {name: "table", editorType: "table", prompt: x->priority, dataProvider: dp.toAxonCode+".toGrid.reorderCols("+dp.toAxonCode+".toGrid.colNames.moveTo(\"name\", 0).moveTo(\"expires\", -1))"}
      ])
    end
    cstr = cstr + "]"
    if(aall) cstr = "finFormPointPriorityViewer(\$aall,"+cstr+")"
    else cstr = "finFormPointPriorityViewer(false,"+cstr+")"
    if(body.size == 0) do
      body = [{name: "label", editorType: "label", text: toLocale("j2FinToolsExt::noPrioritiesSelected")}]
      cstr = ""
    end else query = query.set("width", 900)

    body = body.addAll([
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
    ])

    query.set("body", body.toJSON).set("commitAction", cstr).toGrid.addMeta({formExecute: marker()})
  end
  //////////////////////
  else if(inp.isBool) do
    tmp: ""
    tmp2: ""
    changed: 0
    sec.each x=> do
      if(x[0] or inp) do
        tmp = readAll(parseFilter(x[1])).each y=> do
          tmp2 = y.pointWriteArray.find(g=> (g.has("val") and g->val != null))
          if(tmp2 != null) do
            y.pointWrite(null, x[2], "manualPoints")
            changed = changed + 1
          end
        end
      end
    end

    body: []
    if(inp) body = [{name: "label", editorType: "label", text: toLocale("j2FinToolsExt::allPrioPointsAutoed").replace("{number}", changed.toStr)}]
    else if(changed > 0) body = [{name: "label", editorType: "label", text: toLocale("j2FinToolsExt::countPrioPointsAutoed").replace("{number}", changed.toStr)}]
    else body = [{name: "label", editorType: "label", text: toLocale("j2FinToolsExt::noChangesMade")}]
    body = body.add({name: "cancelButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true})

    query.set("body", body.toJSON).remove("commitButton").remove("commitAction").toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finFormRecordTagClone ​

finFormRecordTagClone(id) ​

This function takes an id, then it will pop up a form that let's you select the tags you want to clone.


meta ​

constructfinFormRecordTagClone(read(equip or site or point or flo...
deffunc:finFormRecordTagClone
distoLocale("j2FinToolsExt::cloneTags")
folderPathtoLocale("j2FinToolsExt::batchEditAndClone")
formOnsite or floor or equip or schedule or point or program o...
helpThis form will run on a record, and it will allow you to...
isfunc
liblib:finTools
namefinFormRecordTagClone

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  rec: id.toRec()
  recDisplayName: rec.dis()

  tagsToHide: read(navMeta)->equipPath.split("/")[1..-1].map(r => r + "Ref").addAll(["navName", "tz", "mod", "id"])
  tagListAsCode: rec.stripUncommittable.names.findAll(v => not tagsToHide.contains(v)).map(r => {name: r}).toAxonCode

  if(rec.has("navName")) idnt: "navName"
  else if(rec.has("dis")) idnt: "dis"
  else if(rec.has("name")) idnt: "name"
  else idnt: "id"

  type: rec.finNavMetaWhoAmI

  body: [
    {
      name: "tags",
      editorType: "list",
      prompt: toLocale("j2FinToolsExt::selectTagsToClone"),
      dataProvider: tagListAsCode,
      listType: "checkbox",
      labelField: "name",
      height: 200,
      selectedValueTags: "name",
      toolTip: toLocale("j2FinToolsExt::toolTipSelectTagsClone")
    },

    {
      name: "tagFilter",
      prompt:toLocale("j2FinToolsExt::selectTagsClonePrompt"),
      editorType: "filter",
      defVal: "",
      toolTip:toLocale("j2FinToolsExt::toolTipSelectTagsCloneTwo")
    },

    {name: "tonavs", editorType: "checkbox", label: toLocale("j2FinToolsExt::cloneToOtherPhrase").replace("{0}",type).replace("{1}",idnt).replace("{2}",rec.trap(idnt))},

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  js: [
    "function checkJobStatus(jobHandle) {",
      "var promise;",
      "if (jobHandle === undefined) {",
        "promise = finstack.evalAll(['jobStatusAll().find(v => v->dis.startsWith(\"finRecordTagClone\") and v->started > "+now().toAxonCode+")']);",
      "} else {",
        "promise = finstack.evalAll(['jobStatusAll(\"'+jobHandle+'\")[0]']);",
      "}",
      "promise.then(function(event) {",
        "var jobStat = event.result[0].toObj(false, false, true);",
        "var isDone = jobStat['jobStatus'].startsWith('done');",
        "if (isDone) {",
          "window.top.app.HideLoader();",
        "} else {",
          //"var msg;",
          //"if (jobStat != null && jobStat != undefined) { msg = window.languageManager['loaderLoading'] + jobStat['progress'] + '%'; }",
          //"else { msg = window.languageManager['loaderLoading'] + '0%'; }",
          "window.top.app.HideLoader();",
          "window.top.app.ShowLoader(languageManager['cloningTags']);",
          "setTimeout(function(){ checkJobStatus(jobStat['handle']); }, 2000);",
        "}",
      "});",
    "}",
    "window.top.app.ShowLoader(languageManager['cloningTags']);",
    "checkJobStatus();"
  ]

  { "dis": toLocale("j2FinToolsExt::cloneToOtherPhraseTwo").replace("{0}",(recDisplayName)),
    "name": "finFormRecordTagClone",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "if(\$tonavs) jobRun(finRecordTagClone(@"+rec->id+", \""+type+" and "+idnt+"==\\\""+rec.trap(idnt)+"\\\"\", \$tags)) else jobRun(finRecordTagClone(@" + rec->id + ", \$tagFilter, \$tags))",
    //"gotoAction": "finstack:folio:axonQuery=\$tags" ,
    "completeAction": js.concat("\n"),
    "confirm": toLocale("j2FinToolsExt::cloneConfirmationPrompt"),
    "helpDoc":"/wiki/display/FINStack/Clone+Tags",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormReplace ​

finFormReplace(id, selectedDicts) ​

Axon function


meta ​

appFormOnbuilder
deffunc:finFormReplace
distoLocale("j2FinToolsExt::searchAndReplace")
folderPathtoLocale("finStackExt::advanced")
formOn(point and not schedule) or site or floor or equip
isfunc
liblib:finTools
namefinFormReplace

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, selectedDicts)=>do
  filter: "point"
  tagName: "name"
  navMetaList: read(navMeta)->equipPath.split("/").map(r => reFind(r"[a-zA-Z_0-9]+", r))

  if(id != null) do
    selectedIds: [id.toRec]
    if(selectedDicts != null) selectedIds = selectedDicts.map(r => r.toRec)
    filter = "("
    selectedIds.each() (rec,idex)=>do
      if(rec.has("navName")) tagName = "navName"
      else if(rec.has("dis") and tagName != "navName") tagName = "dis"

      if(rec.has("site")) filter =  filter + "id == @"+rec->id
      else do
        if(rec.has("floor")) filter = filter +  "id == @"+rec->id
        else do
          if(rec.has("equip")) filter = filter + "id == @"+rec->id
          else filter =  filter + "id == @" + rec->id
        end
      end
      if(idex < (selectedIds.size-1)) filter = filter + " or "
    end
    filter = filter + ")"
  end

  asdf: (selectedIds.size == 1 and selectedIds[0].has("navName"))

  body:[
    {
      name: "filterInput",
      editorType: "filter",
      prompt: toLocale("finStackExt::finFilter"),
      defVal: filter
    },

    (if(asdf)
      {name: "chkbx", editorType: "checkbox", label: toLocale("j2FinToolsExt::filterByNavName").replace("{name}", selectedIds[0]->navName.toAxonCode), selectedValue: selectedIds[0]->navName}
    else {}),

    {name: "tagName", editorType: "textinput", prompt: toLocale("finStackExt::tag"), defVal: tagName},
    {name: "searchText", editorType: "textinput", prompt: toLocale("j2FinToolsExt::searchFor")},
    {name: "replaceText", editorType: "textinput", prompt: toLocale("j2FinToolsExt::replaceWith")},

    {
      name: "table",
      editorType: "table",
      height: 200,
      visible:false,
      enabled:false,
      dataProvider: if(asdf) "try if(size([\$chkbx]) == 1) readAll(navName==([\$chkbx][0])) else readAll(parseFilter(\$filterInput)) catch [null]"
                    else "try readAll(parseFilter(\$filterInput)) catch [null]"
    },

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton",  editorType: "button", label: toLocale("j2FinToolsExt::replace"),  controlBar: true}
  ]

  { "dis":toLocale("j2FinToolsExt::searchAndReplace"),
    "name":"SearchReplaceForm",
    "body":body.toJSON,
    "cancelButton":"\$cancelButton",
    "commitButton":"\$applyButton",
    "commitAction": if(asdf) "applyReplace(\$filterInput,\$tagName,\$searchText,\$replaceText,[\$chkbx])"
                    else "applyReplace(\$filterInput,\$tagName,\$searchText,\$replaceText,false)",
    "finForm":marker(),
    "completeAction": "try {window.app.RefreshBuilderTreeNodeForId('"+(selectedIds[0][navMetaList[navMetaList.index("equip") - 1]+"Ref"].toAxonCode)+"'); window.app.RefreshBuilderGridAt(0, 'panel'); } catch { return 0; }",
    "helpDoc":"/wiki/display/FINStack/Search+and+Replace",
    "refreshTrees": marker()
  }.toGrid.addMeta({formExecute:marker()})
end


def ​

func:finFormRestoreTemplate ​

finFormRestoreTemplate() ​

Axon function


meta ​

appFormOnfolio,builder
deffunc:finFormRestoreTemplate
distoLocale("j2FinToolsExt::restoreTemplate")
folderPathtoLocale("j2FinToolsExt::templates")
formOnid
isfunc
liblib:finTools
namefinFormRestoreTemplate

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body:[
    {
      name: "templateFile",
      editorType: "file",
      fileTypes: ["fst"],
      buttonLabel: "asdasdasd",
      prompt: toLocale("j2FinToolsExt::template")+":",
      multiple: false
    },

    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true },
    { name: "applyButton", editorType: "button", label: toLocale("finStackExt::restore"), controlBar: true }
  ]

  { "dis": toLocale("j2FinToolsExt::restoreTemplate"),
    "name": "finFormRestoreTemplate",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finRestoreRecord(\$templateFile, {files: true, fixRefs}, false)",
    "completeAction": "try { window.app.RefreshBuilderTreeNodeForId('@folderPath:equip:'); } catch { undefined; }",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormSaveTemplate ​

finFormSaveTemplate(id, saveFile: false) ​

Axon function


meta ​

deffunc:finFormSaveTemplate
distoLocale("j2FinToolsExt::saveTemplate")
folderPathtoLocale("j2FinToolsExt::templates")
formOnsite or floor or equip or (point and not schedule)
isfunc
liblib:finTools
namefinFormSaveTemplate

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id, saveFile: false) => do
  if (saveFile == null)
    saveFile = false

  if(saveFile == false) do
    body: [
      {
        name: "childAndRefGroup",
        editorType: "group",
        horizontal,
        children: [
          { name: "childAndRefLabel", editorType: "label", text:toLocale("j2FinToolsExt::childrenAndRefs"), width: 425 },
          { name: "childAndRefCheck", editorType: "checkbox", defVal: true}
        ]
      },

      {
        name: "graphicsGroup",
        editorType: "group",
        horizontal,
        children: [
          { name: "graphicsLabel", editorType: "label", text:toLocale("finStackExt::rightMenuGraphicsTitle"), width: 425 },
          { name: "graphicsCheck", editorType: "checkbox", defVal: true}
        ]
      },

      {
        name: "connectorsGroup",
        editorType: "group",
        horizontal,
        children: [
          { name: "connectorsCheck", editorType: "label", text:toLocale("j2FinToolsExt::connectedDevices"), width: 425 },
          { name: "connectorsCheck", editorType: "checkbox", defVal: true}
        ]
      },

      {
        name: "progsAndAlarmsGroup",
        editorType: "group",
        horizontal,
        children: [
          { name: "progsAndAlarmsLabel", editorType: "label", text:toLocale("j2FinToolsExt::blineProgsAndAlarms"), width: 425 },
          { name: "progsAndAlarmsCheck", editorType: "checkbox", defVal: true}
        ]
      },

      {
        name: "omManualsGroup",
        editorType: "group",
        horizontal,
        children: [
          { name: "omManualsLabel", editorType: "label", text:toLocale("finStackExt::rightMenuOMTitle"), width: 425 },
          { name: "omManualsCheck", editorType: "checkbox", defVal: true}
        ]
      },

      {
        name: "summariesGroup",
        editorType: "group",
        horizontal,
        children: [
          { name: "summariesLabel", editorType: "label", text:toLocale("finStackExt::summaries"), width: 425 },
          { name: "summariesCheck", editorType: "checkbox", defVal: true}
        ]
      },

      {
        name: "tuningGroup",
        editorType: "group",
        horizontal,
        children: [
          { name: "tuningLabel", editorType: "label", text: toLocale("finStackExt::tunPolicies"), width: 425 },
          { name: "tuningCheck", editorType: "checkbox", defVal: true}
        ]
      },

      { name: "applyToAllCheck", editorType: "checkbox", label: toLocale("j2FinToolsExt::applyToAllChildObjs"), defVal: true},
      { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true },
      { name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true }
    ]

    { "dis":toLocale("j2FinToolsExt::backupRecords"),
      "name": "finFormSaveTemplate",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "finFormSaveTemplate(finBackupRecord(["+id.toAxonCode+"], {references: \$childAndRefCheck, graphics: \$graphicsCheck, connectors: \$connectorsCheck, programs: \$progsAndAlarmsCheck, omManuals:\$omManualsCheck, summaries: \$summariesCheck, tuningPolicies: \$tuningCheck, applyToAll: \$applyToAllCheck}, "+readById(id).finNavMetaWhoAmI.toAxonCode+"), true)",
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end else do
    id[0].diff({dis: id[0]->dis + ".fst", finTemplate}).commit
    body: [
      { name: "confirmLabel", editorType: "label", text: toLocale("j2FinToolsExt::fileReadyToDownload").replace(" {name}", "")},
      { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true },
      { name: "applyButton", editorType: "button", label: toLocale("finStackExt::reportsDownload"), controlBar: true }
    ]

    saveAction: [
      "var promise = finstack.eval('readByIds(["+id[0]->id.toAxonCode+"])');",
      "promise.then(function(event){",
        "var fileRec = event.result.toObj()[0];",
        "window.open((finstack.pathPrefix || '')+'/finGetFile/"+context()->projName+"?fileRef='+fileRec.id);",
      "});",
    ]

    { "dis":toLocale("j2FinToolsExt::backupRecords"),
      "name": "finFormSaveTemplateToDisk",
      "body": body.toJSON,
      "cancelButton": "\$cancelButton",
      "commitButton": "\$applyButton",
      "commitAction": "",
      "completeAction": saveAction.concat(""),
      "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})
  end
end


def ​

func:finFormSelectTuningPolicy ​

finFormSelectTuningPolicy(id) ​

Axon function


meta ​

deffunc:finFormSelectTuningPolicy
distoLocale("j2FinToolsExt::assignTuningPolicy")
folderPathtoLocale("finStackExt::rightMenuConnectors")+"/"+toLocal...
formOnconn or connRef
helpThis form will let you create a tuning policy for the se...
isfunc
liblib:finTools
namefinFormSelectTuningPolicy

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  body: [
    {
      name: "tuningPolicy",
      editorType: "combobox",
      prompt: toLocale("j2FinToolsExt::selectTuningPolicy")+":",
      dataProvider: if (readCount(connTuning) == 0) "[{dis: \"No tuning policies found.\", id:@null}]" else "readAll(connTuning)",
      labelField: "dis",
      selectedValueTags: "id",
      encapsulate: true,
      toolTip:"Make sure you are selecting the right tuning policy. This could have bad side effects"
    },

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  if(id.isList) id=id[0]

  { "dis": toLocale("j2FinToolsExt::assignTuningPolicy"),
    "name": "tuningPolicy",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "readAll(id==" + id.toAxonCode + ").finCommit({connTuningRef:\$tuningPolicy})",
    //"gotoAction": "finstack:historian:recIds=@Carytown.ElecMeter-Main.Cost",
    //"confirm": "This will change things, are you sure?",
    "helpDoc": "/wiki/display/FINStack/Create-Edit+Tuning+Policy",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormSetImmediateSubscriptionOffTime ​

finFormSetImmediateSubscriptionOffTime(refill: null) ​

Axon function


meta ​

alarmEmailToggle✓
appFormOnfolio, dbbuilder
deffunc:finFormSetImmediateSubscriptionOffTime
distoLocale("j2FinToolsExt::setImmediateSubOffTime")
isfunc
liblib:finTools
namefinFormSetImmediateSubscriptionOffTime

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(refill: null) => do
  curJob: read(job and hideSubscriptions, false)
  userRecord: userRead(emailSilenceStartTime, false)
  offTime: "11:59 PM"
  onTime: "12:01 AM"

  // read from job
  if (curJob != null) do
    offTime = curJob->offTime.format("k:mm AA")
    onTime = curJob->onTime.format("k:mm AA")
  end
  // read from first user found with tag
  else if (userRecord != null and refill == null) do
    offTime = userRecord["emailSilenceStartTime"].format("k:mm AA")
    onTime = userRecord["emailSilenceEndTime"].format("k:mm AA")
  end
  // use previously entered data (form was re-opened)
  else if(refill != null) do
    offTime = refill->off
    onTime = refill->on
  end

  body: [
    {name: "stopTimeInput", editorType: "textinput", prompt: toLocale("j2FinToolsExt::immediateSubStopTimePrompt")+":", defVal: offTime},
    {name: "startTimeInput", editorType: "textinput", prompt: toLocale("j2FinToolsExt::immediateSubResumeTimePrompt")+":", defVal: onTime},

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"),    controlBar: true},
    {name: "applyButton",  editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  // add invalid time format message to form
  if (refill != null)
    body = body.insert(0, {name: "errLabel", editorType: "label", text: toLocale("j2FinToolsExt::enterValidTimeFormat")})

  { "dis": toLocale("j2FinToolsExt::setImmediateSubOffTime"),
    "name": "finFormSetImmediateSubscriptionOffTime" + (if(refill != null) random(1..10000) else ""),
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finSetImmediateSubOffTimeCommit(\$stopTimeInput, \$startTimeInput,"+ (if(curJob != null) curJob->id.toAxonCode else "null") +")",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormStandardName ​

finFormStandardName(stage: null) ​

Axon function


meta ​

deffunc:finFormStandardName
dis:"toLocale("j2FinToolsExt::standardToNavName")"
finString✓
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
formOn(point and tempPoint) and not schedule
isfunc
liblib:finTools
namefinFormStandardName

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null) => do
  body: [
    //{name: "label", editorType: "label", text: "Press Apply to:"},
    //{name: "label", editorType: "label", text: "-- Overwrite navName with the value of standardName"},
    {name: "label", editorType: "label", text: toLocale("j2FinToolsExt::overwriteNavNameWithStandardName")},
    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  { "dis":toLocale("j2FinToolsExt::standardToNavName"),
    "name": "finFormStandardName",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "readAll(point and standardName).each(x=> x.diff({navName: x->standardName, -standardName}).commit)",
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormStringSearchCommit ​

finFormStringSearchCommit(data: null, selectedDicts: null) ​

finFormStringSearchCommit(data: null, selectedDicts: null)

This is a supporting function for finFormStringSearchTrans.

WARNING: This function is not meant to be used standalone and is instead used as a backend function for the finFormSTringSearchTrans function.


meta ​

deffunc:finFormStringSearchCommit
finString✓
isfunc
liblib:finTools
namefinFormStringSearchCommit

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(data: null, selectedDicts: null) => do
  t: ioReadZinc(`io/finFormStringTemp.zinc`)
  metas: t.meta->cName.split(",").findAll(x=> x != "")

  if(selectedDicts==null) k:[]
  if(data == 1) do
    t=t.findAll(x=> k.index(x->id)==null)
    data=true
  end

  if(data) do
    t.toRecList.each x=> do
      g:{changed}
      rec: readById(x->id)

      if(rec.has("siteRef")) do
        site: rec->siteRef.readById
        floor: rec->floorRef.readById
        equip: rec->equipRef.readById

        metas.each y=> do
          g = g.set(y, x.trap(y))
          if(y == "pointName") do //siteName < floorName < equipName !!!
            g = g.set("originalName", rec->navName)
            g = g.set("navName", x.trap(y))
          end else if(y == "siteName") do
            site = read(site and dis==x->siteName, false)
            if(site == null) site = diff(null,{geoState:"CA", site, tz:"Los_Angeles", geoCountry:"US", dis: x->siteName},{add}).commit
            g = g.set("siteRef", site->id)
          end else if(y == "floorName") do
            floor = read(floor and siteRef==site->id and dis==x->floorName, false)
            if(floor == null) floor = diff(null,{tz:"Los_Angeles", siteRef: site->id, floor, dis: x->floorName},{add}).commit
            g = g.set("floorRef", floor->id)
          end else if(y == "equipName") do
            equip = read(equip and floorRef==floor->id and siteRef==site->id and navName==x->equipName, false)
            if(equip == null) equip = diff(null,
              {floorRef:floor->id, equip, disMacro:"\$siteRef \$navName", tz:"Los_Angeles", siteRef:site->id, navName: x->equipName},{add}).commit
            g = g.set("equipRef", equip->id)
          end
        end

        rec.diff(g).commit
      end else do
        recId: rec->id
        metas.each y => rec.diff(g.set(y, x.trap(y)), {force}).commit
      end
    end
  end

  ioDelete(`io/finFormStringTemp.zinc`);
  data
end


def ​

func:finFormStringSearchTrans ​

finFormStringSearchTrans(stage: null, data: null, selectedDicts: null) ​

Form interface for these functions: finStringSearchDicts finStringSplitDicts


meta ​

appFormOnfolio
deffunc:finFormStringSearchTrans
distoLocale("j2FinToolsExt::stringParser")
finString✓
folderPathtoLocale("finStackExt::advanced")+"/"+toLocale("j2FinToo...
isfunc
liblib:finTools
namefinFormStringSearchTrans

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(stage: null, data: null, selectedDicts: null) => do
  selD: selectedDicts
  query: {
    dis:toLocale("j2FinToolsExt::stringParser"),
    name: "finFormStringSearchTrans",
    cancelButton: "\$cancelButton",
    commitButton: "\$applyButton",
    commitAction: "",
    helpDoc: "/wiki/spaces/FINStack/pages/267223041/String+Parser",
    finForm: marker()
  }

  if (ioDir(`io/`).find(x=> x->name=="finFormStringTemp.zinc")!=null)
    stage = 3

  stuff: true; tac: toAxonCode
  gh: readAll(finString and settings) //restore settings

  if (gh.size == 0 or read(finString and settings and primary, false) == null)
  do
    gh = {
      finString: marker(),
      settings: marker(),
      primary: marker(),
      filt: "",
      col: "navName",
      type: 0,
      value: 0,
      en1: true,
      en2: true,
      char: ".",
      f1opt: 0,
      f1txt: "",
      f2opt: 1,
      f2txt: "",
      split: ".",
      sname: "\"siteName\"",
      fname: "\"floor1\"",
      ename: "\"vav1\"",
      pname: "\"pointName\"",
      setid: 0
    }

    diff(null, gh, {add}).commit
    stage = 0
  end
  else if (gh.size == 1)
  do
    gh = read(finString and settings)

    read(finString and settings and primary).diff({setid: gh->id}).commit

    if(stage!=0 and stage!=1 and stage!=2 and stage!=3)
      stage = 0
  end
  else
    gh = gh.find(x=> x->id == read(finString and settings and primary)->setid)

  if(stage!=0 and stage!=1 and stage!=2 and stage!=3)
  do //template
    body: [ // +\" - \"+ x->cont +\" - \"+ x->ncont
      {
        name: "list",
        editorType: "combobox",
        prompt: toLocale("j2FinToolsExt::settingSelect"),
        labelField: "title",
        selectedValueTags: "id",
        defIndex: 0,
        dataProvider: "readAll(finString and settings).map(x=> x.set(\"title\", x->filt +\" - \"+ x->col +\" - \"+ x->value +\" - \"+ x->char))"
      },

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
    ]
    query = query.set("commitAction", "read(finString and settings and primary).diff({setid: \$list}).commit; finFormStringSearchTrans(0)").set("dis", "Choose Settings")
  end
  ////
  else if(stage == 0)
  do //search
    opts:[
      {dis: toLocale("j2FinToolsExt::hasMoreThan")+"        >", val: "hasMoreThan", ind: 0},
      {dis: toLocale("j2FinToolsExt::hasLessThan")+"        <", val: "hasLessThan", ind: 1},
      {dis: toLocale("j2FinToolsExt::hasEqualTo")+"         ==", val: "hasEqualTo", ind: 2},
      {dis: toLocale("j2FinToolsExt::notMoreThan")+"        <=", val: "notMoreThan", ind: 3},
      {dis: toLocale("j2FinToolsExt::notLessThan")+"        >=", val: "notLessThan", ind: 4},
      {dis: toLocale("j2FinToolsExt::notEqualTo")+"         !=", val: "notEqualTo", ind: 5}
    ]

    oopts: [
      {dis: toLocale("j2FinToolsExt::contains"), val: "contains", ind: 0},
      {dis: toLocale("j2FinToolsExt::doesntContain"), val: "notContains", ind: 1},
      {dis: toLocale("j2FinToolsExt::startsWith"), val: "startsWith", ind: 2},
      {dis: toLocale("j2FinToolsExt::doesntStartWith"), val: "notStartsWith", ind: 3},
      {dis: toLocale("j2FinToolsExt::endsWith"), val: "endsWith", ind: 4},
      {dis: toLocale("j2FinToolsExt::doesntEndWith"), val: "notEndsWith", ind: 5}
    ]

    body: [
      {name: "label", editorType: "separator", label: toLocale("finStackExt::finFilter")},
      {name: "filt", editorType: "filter", prompt: toLocale("finStackExt::finFilter"), defVal: gh->filt, toolTip: "point"},

      {
        name: "col",
        editorType: "combobox",
        prompt: toLocale("finStackExt::gTypeColumn")+":",
        labelField: "val",
        selectedValueTags: "val",
        defIndex: 0,
        dataProvider: "try readAll(parseFilter(\$filt)).cols.map(x=> x.toStr).findAll(x=> x != \"return\" and read(parseFilter(\$filt) and parseFilter(x)).trap(x) != marker()).sort.moveTo(\""+gh->col+"\",0) catch []"
      },

      {name: "label", editorType: "separator", label: toLocale("j2FinToolsExt::patternMatching")},
      {name: "type", editorType: "combobox", prompt: toLocale("j2FinToolsExt::comparison")+":", dataProvider: opts.tac, labelField: "dis", selectedValueTags: "val, ind", defIndex: gh->type},
      {name: "value", editorType: "numericstepper", prompt: toLocale("finStackExt::gbValue")+":", minVal: 0, defVal: gh->value},
      {name: "char", editorType: "textinput", prompt: toLocale("j2FinToolsExt::characters")+":", defVal: gh->char, toolTip: "., !, Hello"},
      {name: "en1", editorType: "checkbox", label: toLocale("j2FinToolsExt::usePatternMatching"), defVal: gh->en1},

      {name: "label", editorType: "separator", label: toLocale("j2FinToolsExt::stringMatching")},
      {name: "f1opt", editorType: "combobox", dataProvider: oopts.tac, labelField: "dis", selectedValueTags: "val, ind", defIndex: gh->f1opt},
      {name: "f1txt", editorType: "textinput", defVal: gh->f1txt, toolTip: "_, 4"},
      {name: "f2opt", editorType: "combobox", dataProvider: oopts.tac, labelField: "dis", selectedValueTags: "val, ind", defIndex: gh->f2opt},
      {name: "f2txt", editorType: "textinput", defVal: gh->f2txt, toolTip: "5"},
      {name: "en2", editorType: "checkbox", label: toLocale("j2FinToolsExt::useStringMatching"), defVal: gh->en2},

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
    ]

    query = query.set("commitAction", "finFormStringSearchTrans(1, [\$filt, \$col, \$type, \$value, \$char, \$f1opt, \$f1txt, \$f2opt, \$f2txt], [\$en1, \$en2])").set("dis", toLocale("j2FinToolsExt::stringParser"))
  end
  ////
  else if (stage == 1)
  do //split
    ttip: "NavName column of \"Room Setpoint\" split by space and unit of °F with \"point \", 2, \" Na {{unit}} me\" becomes \"point Setpoint Na °F me\""

    body: [
      {name: "label", editorType: "label", text: toLocale("finStackExt::finFilter")+": "+data[0]},
      {name: "label", editorType: "label", text: toLocale("finStackExt::gTypeColumn") +": "+data[1]},

      {
        name: "label",
        editorType: "label",
        text: toLocale("j2FinToolsExt::recordsPrompt") +": "+finStringSearchDicts(readAll(parseFilter(data[0])), {type: data[2]->val, value: data[3], char: data[4], disable: not selD[0]}, {type1: data[5]->val, val1: data[6], type2: data[7]->val, val2: data[8], disable: not selD[1]}, data[1]).size
      },

      {name: "split", editorType: "textinput", prompt: toLocale("j2FinToolsExt::splitVal")+":", defVal: gh->split, toolTip: "."},
      {name: "sname", editorType: "textinput", prompt: toLocale("j2FinToolsExt::siteName")+":", defVal: gh->sname, toolTip: ttip},
      {name: "fname", editorType: "textinput", prompt: toLocale("j2FinToolsExt::floorName")+":", defVal: gh->fname, toolTip: ttip},
      {name: "ename", editorType: "textinput", prompt: toLocale("j2FinToolsExt::equipName")+":", defVal: gh->ename, toolTip: ttip},
      {name: "pname", editorType: "textinput", prompt: toLocale("j2FinToolsExt::pointName")+":", defVal: gh->pname, toolTip: ttip},
      {name: "list", editorType: "list", dataProvider: "try finFormStringSearchTransPrev("+data.tac+",\$split,\$sname,\$fname,\$ename,\$pname,"+selD.tac+") catch \"\"", labelField: "val"},

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::view"), controlBar: true}
    ]
    query = query.set("dis", toLocale("j2FinToolsExt::stringParser")).set("gotoAction", "finstack:folio:axonQuery=finFormStringSearchTrans(2, "+data.tac+".addAll([\"\$split\", [\$sname], [\$fname], [\$ename], [\$pname]]), "+selectedDicts.tac+")")
  end
  ////
  else if (stage == 2)
  do //write file and display
    d: data
    readById(read(finString and settings and primary)->setid).diff({
      filt: d[0],
      col: d[1],
      type: d[2]->ind,
      value: d[3],
      char: d[4],
      f1opt: d[5]->ind,
      f1txt: d[6],
      f2opt: d[7]->ind,
      f2txt: d[8],
      split: d[9],
      sname: d[10].map(x=> x.tac).concat(","),
      fname: d[11].map(x=> x.tac).concat(","),
      en1: selectedDicts[0],
      en2: selectedDicts[1],
      ename: d[12].map(x=> x.tac).concat(","),
      pname: d[13].map(x=> x.tac).concat(",")
    }).commit

    m: ""
    dat: finStringSearchDicts(readAll(parseFilter(d[0])), {type: d[2]->val, value: d[3], char: d[4], disable: not selD[0]}, {type1: d[5]->val, val1: d[6], type2: d[7]->val, val2: d[8], disable: not selD[1]}, d[1])

    if(d[10].size > 0) do dat = dat.finStringSplitDicts(d[1], d[9], d[10], "siteName"); m = m + "siteName," end
    if(d[11].size > 0) do dat = dat.finStringSplitDicts(d[1], d[9], d[11], "floorName"); m = m + "floorName," end
    if(d[12].size > 0) do dat = dat.finStringSplitDicts(d[1], d[9], d[12], "equipName"); m = m + "equipName," end
    if(d[13].size > 0) do dat = dat.finStringSplitDicts(d[1], d[9], d[13], "pointName"); m = m + "pointName," end

    dat=dat.toGrid.keepCols([d[1], "siteName", "floorName", "equipName", "pointName", "id"]); dat.addMeta({cName: m, selcol: d[1]}).ioWriteZinc(`io/finFormStringTemp.zinc`)
    query = dat.reorderCols(dat.colNames.moveTo("id",0).moveTo(d[1],1).moveTo("pointName",2).moveTo("equipName",3).moveTo("floorName",4))
    stuff = false
  end
  ////
  else if (stage == 3)
  do //ask to commit
    body: [
      {name: "label", editorType: "label", text: toLocale("j2FinGToolsExt::tempFileWithChangesDetected")},
      {name: "radio", editorType: "radio", label: toLocale("j2FinGToolsExt::commitChanges"), selectedValue: true, defVal: true},
      {name: "radio", editorType: "radio", label: toLocale("j2FinGToolsExt::startFromScratch"), selectedValue: false},
      {name: "radio", editorType: "radio", label: toLocale("j2FinGToolsExt::viewChanges"), selectedValue: 0},
      {name: "radio", editorType: "radio", label: toLocale("j2FinGToolsExt::statusUpdate"), selectedValue: 2},

      {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
      {name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
    ]

    if(selectedDicts != null) do
      body = body.add({name: "radio", editorType: "radio", label: toLocale("j2FinGToolsExt::excludeSelectedPtsAndCommit"), selectedValue: 1})
      selectedDicts = selectedDicts.toGrid.colToList("id")
    end
    query = query.set("commitAction", "if(\$radio!=0 and \$radio!=2) finFormStringSearchCommit(\$radio, "+
      selectedDicts.tac+"); if(\$radio == false) finFormStringSearchTrans(); if(\$radio==2) finFormStringSearchTransStats()")
    query = query.set("gotoAction", "finstack:folio:axonQuery=if(\$radio == 0) ioReadZinc(`io/finFormStringTemp.zinc`)")
  end

  if(stuff) query.set("body", body.toJSON).toGrid.addMeta({formExecute: marker()})
  else query
end