new abstract BankItemsBase(registry, controller, logSource, dbKey)
Creates an item base object
Parameters:
Name | Type | Description |
---|---|---|
registry |
Registry | the core registry |
controller |
BankActionController | BankFeedbackController | the item's parent controller |
logSource |
string | module name to be used in logs |
dbKey |
string | the key to fetch from the database |
- Since:
- 2.2.0
Extends
Members
-
protected controller :BankActionController|BankFeedbackController
-
The parent controller
-
protected dbKey :string
-
The database to use load/save the items
-
protected definitions :Object.<string, Array.<BankItemDefinition>>
-
Nested arrays for the definitions from the instances:
[instance_id][item_id]
-
protected items :Object.<number, Array.<number, Object.<number, BankItem>>>
-
Nested arrays containing the items in the banks:
[page][bank][item]
Also is the data that is stored to the DB. -
protected logSource :string
-
The module name to use in UI logs
- Overrides:
-
protected registry :Registry
-
the core registry
- Overrides:
-
protected system :EventEmitter
-
the application's event smitter
- Overrides:
Methods
-
addItem(page, bank, item)
-
Add an item to a bank
Parameters:
Name Type Description page
number the bank's page bank
number the bank number item
string item information in form: `"instance_id:type"` -
addItemByClient(client, result, page, bank, item)
-
Add item to a bank via a client socket
Parameters:
Name Type Description client
IO.Socket the client socket sending the request result
string the name of the call to send the results back to the client page
number the bank's page bank
number the bank number item
string item information in form: `"instance_id:type"` -
protected bank() → {BankController}
-
Returns:
BankController - the core bank controller- Overrides:
-
protected checkBankExists(page, bank)
-
Check if a bank exists and initialize it if it doesn't
Parameters:
Name Type Description page
number the bank's page bank
number the bank number -
checkInstanceStatus(id, type, checkQueuenullable) → {Array.<string, boolean>}
-
Scan the page/bank array to find items for an instance or just specific types and populate an array with the findings
Parameters:
Name Type Attributes Description id
string the instance ID to check for type
string the item type to check for checkQueue
Array.<string, boolean> <nullable>
array of flagged banks with keys of `[page_bank]`; empty by default but can have a populated version passed to be added to Returns:
Array.<string, boolean> - the populated `checkQueue` -
protected checkStatus(page, bank, i)
-
Check an item's status
Parameters:
Name Type Description page
number the item's page bank
number the item's bank i
number the item's index -
protected db() → {Database}
-
Returns:
Database - the core database library- Overrides:
-
deleteInstance(id, checkQueuenullable) → {Array.<string, boolean>}
-
Scan the page/bank array for items from an instance and delete them
Parameters:
Name Type Attributes Description id
string the instance ID to delete checkQueue
Array.<string, boolean> <nullable>
array of changed banks with keys of `[page_bank]`; empty by default but can have a populated version passed to be added to Returns:
Array.<string, boolean> - the populated `checkQueue` -
deleteItem(page, bank, index)
-
Delete an item
Parameters:
Name Type Description page
number the item's page bank
number the item's bank index
number the item's index -
deleteItemByClient(client, result, page, bank, index)
-
Delete an item from a bank via a client socket
Parameters:
Name Type Description client
IO.Socket the client socket sending the request result
string the name of the call to send the results back to the client page
number the item's page bank
number the item's bank index
string the item's id (`item.id`) -
protected elgatoDM() → {DeviceController}
-
Returns:
DeviceController - the core device controller- Overrides:
-
getAll(clone) → {Object}
-
Get the entire items array
Parameters:
Name Type Default Description clone
boolean false whether or not the return should be a deep clone Returns:
Object - the array in the form `[page][bank][item]` -
getBank(page, bank, clone) → {Array.<BankItem>}
-
Get the items in a bank
Parameters:
Name Type Default Description page
number the bank's page bank
number the bank number clone
boolean false whether or not the return should be a deep clone Returns:
Array.<BankItem> - the items array -
getBankByClient(client, result, page, bank)
-
Get the items in a bank via a client socket
Parameters:
Name Type Description client
IO.Socket the client socket sending the request result
string the name of the call to send the results back to the client page
number the bank's page bank
number the bank number -
getInstanceItems(id, clone) → {Array.<BankItem>}
-
Get all the items for a specific instance
Parameters:
Name Type Default Description id
string the instance id clone
boolean false whether or not the return should be a deep clone Returns:
Array.<BankItem> - the items array -
getPage(page, clone) → {Array.<number, Array.<BankItem>>}
-
Get the items on a page
Parameters:
Name Type Default Description page
number the page number clone
boolean false whether or not the return should be a deep clone Returns:
Array.<number, Array.<BankItem>> - the array in the form `[bank][item]` -
protected graphics() → {Graphics}
-
Returns:
Graphics - the core graphics controller- Overrides:
-
importBank(page, bank, items)
-
Import and subscribe items to a bank
Parameters:
Name Type Description page
number the bank's page bank
number the bank number items
Array.<BankItem> the items to import -
protected instance() → {InstanceController}
-
Returns:
InstanceController - the core instance controller- Overrides:
-
protected io() → {InterfaceClient}
-
Returns:
InterfaceClient - the core interface client- Overrides:
-
protected log(level, message)
-
Send a log message to the UI
Parameters:
Name Type Description level
string 'debug' | 'info' | 'warn' | 'error' message
atring the message to print - Overrides:
-
protected page() → {PageController}
-
Returns:
PageController - the core page controller- Overrides:
-
resetBank(page, bank)
-
Unsubscribe, clear a bank, and save
Parameters:
Name Type Description page
number the bank's page bank
number the bank number -
save()
-
Flag the database to save
-
protected schedule() → {ScheduleController}
-
Returns:
ScheduleController - the core schedule controller- Overrides:
-
protected services() → {ServiceController}
-
Returns:
ServiceController - the core service controller- Overrides:
-
setDefinitions(definitions)
-
Set a new definitions array
Parameters:
Name Type Description definitions
Array.<BankItemDefinition> the new definitions -
protected subscribe(item)
-
Find a subscribe function for an item and execute it
Parameters:
Name Type Description item
BankItem the item object -
subscribeBank(page, bank)
-
Execute subscribes for all the items in a bank
Parameters:
Name Type Description page
number the bank's page bank
number the bank number -
protected unsubscribe(item)
-
Find an unsubscribe function for an item and execute it
Parameters:
Name Type Description item
BankItem the item object -
unsubscribeBank(page, bank)
-
Execute unsubscribes for all the items in a bank
Parameters:
Name Type Description page
number the bank's page bank
number the bank number -
updateItemOption(page, bank, item, option, value)
-
Update an option for an item, subscribe, and save
Parameters:
Name Type Description page
number the item's page bank
number the item's bank item
string the item's id (`item.id`) option
string the option id/key value
string | Array.<string> | number | boolean the new value -
updateItemOrder(page, bank, oldIndex, newIndex)
-
Update a bank item order by swapping two keys
Parameters:
Name Type Description page
number the bank's page bank
number the bank number oldIndex
number the moving item's index newIndex
number the other index to swap with -
protected userconfig() → {UserConfig}
-
Returns:
UserConfig - the core user config manager- Overrides: