Skip to content

Model Info Manufacturer Interface

bradreevmx edited this page Jul 20, 2018 · 3 revisions

The manufacturer interface performs three primary functions: Administration management, Model and Component management, and Mediation controls. Only users contained in the AdminList shall be allowed to modify the data record. All reads are public to all users but are listed included in the Manufacturer interface as the manufacturer would be the primary user of these functions.

API List

Model Management

Write
WriteComponent
DeleteComponent

Administrator Management

WriteAdmin
ReadAdminList


Model Management

Write

This function writes the MfgId and Model Data for a ModelId. Only those listed in the AdminList are allowed to perform this operation, which is controlled with the WriteAdmin function as described in the Administration management APIs. In order to delete a device, all components must be deleted (DeleteComponent), and then all fields in the model record shall be set to null with the Write function.

Input Parameters

Type Name Description
address ModelId ModelId for the model.
string Data JSON data describing the model.
address MfgId Manufacturer's ID

Return Values

Type Name Description
bool Status True if the operation was successful

Example

var JsonData = '{"Mfg":"MfgA","Model":"ModelB","HwVer":"Hw1","FwVer":"Fw2"}'
var ModelId = "0xbd4d579e0819c4ab3d1b6d59b8429218fc923507"
ModelInfo.Write(ModelId, JsonData, {from:ContractOwner,gas:470000})

WriteComponent

This function adds a component to a ModelId. Only those listed in the AdminList are allowed to perform this operation, which is controlled with the WriteAdmin function as described in the Administration management APIs.

Input Parameters

Type Name Description
address ModelId ModelId for the model.
address Component ModelId of component.

Return Values

Type Name Description
bool Status True if the operation was successful

Example

var ModelId = "0xbd4d579e0819c4ab3d1b6d59b8429218fc923507"
var Component = "0x1bbe4a661fdcb10ccc698ff484549555513684dc"
ModelInfo.WriteComponent(ModelId, Component, {from:AdminA,gas:470000})

DeleteComponent

This function deletes a component to a ModelId. Only those listed in the AdminList are allowed to perform this operation, which is controlled with the WriteAdmin function as described in the Administration management APIs.

Input Parameters

Type Name Description
address ModelId ModelId for the model.
address Component ModelId of component.

Return Values

Type Name Description
bool Status True if the operation was successful

Example

var ModelId = "0xbd4d579e0819c4ab3d1b6d59b8429218fc923507"
var Component = "0x1bbe4a661fdcb10ccc698ff484549555513684dc"
ModelInfo.DeleteComponent(ModelId, Component, {from:AdminA,gas:470000})

Administrator Management

WriteAdmin

This function writes an AdminId to a ModelId. If the device is unclaimed, then the first user to call the WriteAdmin for the ModelId shall be granted administrator rights. Otherwise, only those listed on the AdminList shall be allowed to modify the AdminList. In order to remove a user off the AdminList, an existing Admin user shall call this function and write NULL to the admin index they wish to remove.

Currently, the maximum number of administrators per ModelId is 5.

Input Parameters

Type Name Description
address ModelId ModelId for the model.
uint Index AdminList Index
address AdminId New AdminId to be written to the AdminList

Return Values

Type Name Description
bool Status True if the operation was successful

Example

var ModelId = "0xbd4d579e0819c4ab3d1b6d59b8429218fc923507"
var Index = 0
var AdminId = "0x1bbe4a661fdcb10ccc698ff484549555513684dc"
ModelInfo.WriteAdmin(ModelId, Index, AdminId, {AdminId,gas:470000})

ReadAdminList

This function returns the entire AdminList.

Currently, the maximum number of administrators per ModelId is 5.

Input Parameters

Type Name Description
address ModelId ModelId for the model.

Return Values

Type Name Description
address[] AdminId True if the operation was successful

Example

var ModelId = "0xbd4d579e0819c4ab3d1b6d59b8429218fc923507"
ModelInfo.ReadAdminList(ModelId, {AdminId,gas:470000})
0x2ce23c3c4692079c1eba9ffce2b7175fa43d106e,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000

Clone this wiki locally