Skip to content

Commit

Permalink
commented out device.config.disconnect on EthernetIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joyja committed May 21, 2020
1 parent 3d796ec commit 44f970f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/device/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Device extends Model {
description,
type,
createdBy,
createdOn
createdOn,
}
return super.create(fields)
}
Expand Down Expand Up @@ -69,11 +69,11 @@ Device.fields = [
{ colName: 'description', colType: 'TEXT' },
{ colName: 'type', colType: 'TEXT' },
{ colName: 'createdBy', colRef: 'user', onDelete: 'SET NULL' },
{ colName: 'createdOn', colType: 'INTEGER' }
{ colName: 'createdOn', colType: 'INTEGER' },
]
Device.instances = []
Device.initialized = false

module.exports = {
Device
Device,
}
12 changes: 6 additions & 6 deletions src/device/ethernetip.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class EthernetIP extends Model {
this.connected = false
}
this.pubsub.publish('deviceUpdate', {
deviceUpdate: this.device
deviceUpdate: this.device,
})
}
}
async disconnect() {
this.client.destroy()
this.connected = false
this.pubsub.publish('deviceUpdate', {
deviceUpdate: this.device
deviceUpdate: this.device,
})
}
get host() {
Expand Down Expand Up @@ -77,7 +77,7 @@ EthernetIP.table = `ethernetip`
EthernetIP.fields = [
{ colName: 'device', colRef: 'device', onDelete: 'CASCADE' },
{ colName: 'host', colType: 'TEXT' },
{ colName: 'slot', colType: 'INTEGER' }
{ colName: 'slot', colType: 'INTEGER' },
]
EthernetIP.instances = []
EthernetIP.initialized = false
Expand All @@ -87,7 +87,7 @@ class EthernetIPSource extends Model {
const fields = {
ethernetip,
tag,
tagname
tagname,
}
return super.create(fields)
}
Expand Down Expand Up @@ -125,12 +125,12 @@ EthernetIPSource.table = `ethernetipSource`
EthernetIPSource.fields = [
{ colName: 'ethernetip', colRef: 'ethernetip', onDelete: 'CASCADE' },
{ colName: 'tag', colRef: 'tag', onDelete: 'CASCADE' },
{ colName: 'tagname', colType: 'TEXT' }
{ colName: 'tagname', colType: 'TEXT' },
]
EthernetIPSource.instances = []
EthernetIPSource.initialized = false

module.exports = {
EthernetIP,
EthernetIPSource
EthernetIPSource,
}
8 changes: 4 additions & 4 deletions src/resolvers/Mutation/device/ethernetip.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
EthernetIP,
EthernetIPSource,
Tag,
User
User,
} = require('../../../relations')

async function createEthernetIP(root, args, context, info) {
Expand Down Expand Up @@ -48,7 +48,7 @@ async function deleteEthernetIP(root, args, context, info) {
const user = await User.getUserFromContext(context)
const device = Device.findById(args.id)
if (device) {
await device.config.disconnect()
// await device.config.disconnect()
return device.delete()
} else {
throw new Error(`Device with id ${args.id} does not exist.`)
Expand All @@ -65,7 +65,7 @@ async function createEthernetIPSource(root, args, context, info) {
if (tag) {
const config = {
register: args.register,
registerType: args.registerType
registerType: args.registerType,
}
return EthernetIPSource.create(
device.config.id,
Expand Down Expand Up @@ -115,5 +115,5 @@ module.exports = {
deleteEthernetIP,
createEthernetIPSource,
updateEthernetIPSource,
deleteEthernetIPSource
deleteEthernetIPSource,
}
2 changes: 1 addition & 1 deletion src/resolvers/Mutation/device/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ const ethernetip = require('./ethernetip')

module.exports = {
...modbus,
...ethernetip
...ethernetip,
}
6 changes: 3 additions & 3 deletions src/resolvers/Mutation/device/modbus.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
Modbus,
ModbusSource,
Tag,
User
User,
} = require('../../../relations')

async function createModbus(root, args, context, info) {
Expand Down Expand Up @@ -85,7 +85,7 @@ async function createModbusSource(root, args, context, info) {
if (tag) {
const config = {
register: args.register,
registerType: args.registerType
registerType: args.registerType,
}
return ModbusSource.create(
device.config.id,
Expand Down Expand Up @@ -137,5 +137,5 @@ module.exports = {
deleteModbus,
createModbusSource,
updateModbusSource,
deleteModbusSource
deleteModbusSource,
}

0 comments on commit 44f970f

Please sign in to comment.