forked from absmach/magistrala
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
- Loading branch information
Showing
41 changed files
with
583 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export interface Config { | ||
thing_id: string; | ||
thing_key: string; | ||
channels: Array<string>; | ||
external_id: string; | ||
external_key: string; | ||
content: string; | ||
state: number; | ||
} | ||
|
||
export interface ConfigContent { | ||
log_level: string; | ||
http_port: string; | ||
mqtt_url: string; | ||
edgex_url: string; | ||
wowza_url: string; | ||
} | ||
|
||
export interface ConfigUpdate { | ||
content: string; | ||
name: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export interface GatewayMetadata { | ||
ctrlChannelID?: string; | ||
dataChannelID?: string; | ||
gwPassword?: string; | ||
mac?: string; | ||
cfgID?: string; | ||
type?: string; | ||
} | ||
|
||
export interface Gateway { | ||
id?: string; | ||
key?: string; | ||
name?: string; | ||
metadata?: GatewayMetadata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export interface User { | ||
email?: string; | ||
password?: string; | ||
picture?: string; | ||
metadata?: Object; | ||
} | ||
|
||
export interface Channel { | ||
id?: string; | ||
name?: string; | ||
metadata?: any; | ||
} | ||
|
||
export interface Thing { | ||
id?: string; | ||
key?: string; | ||
name?: string; | ||
metadata?: any; | ||
} | ||
|
||
export interface Message { | ||
bn: string; | ||
bt: number; | ||
bu: string; | ||
bver: number; | ||
n: string; | ||
t: number; | ||
u: string; | ||
v: number; | ||
vs: string; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export interface OpcuaMetadata { | ||
type?: string; | ||
opcua: { | ||
serverURI?: string, | ||
nodeID?: string, | ||
}; | ||
channelID?: string; | ||
} | ||
|
||
export interface OpcuaNode { | ||
name?: string; | ||
id?: string; | ||
key?: string; | ||
metadata?: OpcuaMetadata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
import { OpcuaNode } from 'app/common/interfaces/opcua.interface'; | ||
import { ThingsService } from 'app/common/services/things/things.service'; | ||
import { ChannelsService } from 'app/common/services/channels/channels.service'; | ||
import { NotificationsService } from 'app/common/services/notifications/notifications.service'; | ||
|
||
@Injectable() | ||
export class OpcuaService { | ||
typeOpcua = 'opcua'; | ||
typeOpcuaServer = 'OPC-UA-Server'; | ||
|
||
constructor( | ||
private thingsService: ThingsService, | ||
private channelsService: ChannelsService, | ||
private notificationsService: NotificationsService, | ||
) { } | ||
|
||
getNode(id: string) { | ||
return this.thingsService.getThing(id); | ||
} | ||
|
||
getNodes(offset: number, limit: number) { | ||
return this.thingsService.getThings(offset, limit, this.typeOpcua); | ||
} | ||
|
||
addNode(node: any) { | ||
const chanReq = { | ||
name: `${this.typeOpcuaServer}-${node.name}`, | ||
metadata: { | ||
type: this.typeOpcua, | ||
opcua: { | ||
serverURI: node.serverURI, | ||
}, | ||
}, | ||
}; | ||
|
||
// TODO - Check if channel exist | ||
return this.channelsService.addChannel(chanReq).map( | ||
respChan => { | ||
const chanID = respChan.headers.get('location').replace('/channels/', ''); | ||
const nodeReq: OpcuaNode = { | ||
name: node.name, | ||
metadata: { | ||
type: this.typeOpcua, | ||
channelID: chanID, | ||
opcua: { | ||
nodeID: node.nodeID, | ||
serverURI: node.serverURI, | ||
}, | ||
}, | ||
}; | ||
|
||
this.thingsService.addThing(nodeReq).subscribe( | ||
respThing => { | ||
const thingID = respThing.headers.get('location').replace('/things/', ''); | ||
this.channelsService.connectThing(chanID, thingID).subscribe( | ||
respCon => { | ||
this.notificationsService.success('OPC-UA Node successfully created', ''); | ||
}, | ||
err => { | ||
this.thingsService.deleteThing(thingID).subscribe(); | ||
this.channelsService.deleteChannel(chanID).subscribe(); | ||
}, | ||
); | ||
}, | ||
err => { | ||
this.channelsService.deleteChannel(chanID).subscribe(); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
|
||
editNode(node: any) { | ||
const nodeReq: OpcuaNode = { | ||
id: node.id, | ||
name: node.name, | ||
metadata: { | ||
type: this.typeOpcua, | ||
opcua: { | ||
serverURI: node.serverURI, | ||
nodeID: node.nodeID, | ||
}, | ||
}, | ||
}; | ||
|
||
return this.thingsService.editThing(nodeReq).map( | ||
resp => { | ||
this.notificationsService.success('OPC-UA Node successfully edited', ''); | ||
}, | ||
); | ||
} | ||
|
||
deleteNode(node: any) { | ||
const channelID = node.metadata.channelID; | ||
return this.channelsService.deleteChannel(channelID).map( | ||
respChan => { | ||
this.thingsService.deleteThing(node.id).subscribe( | ||
respThing => { | ||
this.notificationsService.success('OPC-UA Node successfully deleted', ''); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.