Compare commits

...

51 Commits

Author SHA1 Message Date
peterlu14 52a4dac990 [update] down sample 2021-09-03 19:02:59 +08:00
peterlu14 9a3d9689fd Merge branch 'master' into feature/spike_detect 2021-09-03 19:01:53 +08:00
peterlu14 46b6918031 [update] babel src build copy python file to dist & port fix 2021-09-01 17:52:24 +08:00
peterlu14 df09a4c92b [update] add update sd card api 2021-08-30 18:47:53 +08:00
peterlu14 f4ac57c8f8 Merge branch 'release/0826_merge_spike' 2021-08-30 14:37:19 +08:00
peterlu14 64c6b20a8f [update] fix delete file error 2021-08-30 14:36:44 +08:00
peterlu14 8a65f20142 Merge remote-tracking branch 'origin/feature/spike_detect' 2021-08-27 17:46:59 +08:00
peterlu14 632d65c057 [update] new route update_by_id & update_by_mac and device calibration column type varchar(255) to TEXT and update_at update 2021-08-27 17:45:52 +08:00
TommyXin e013b9dd63 get collectiong if controller ID is null (for old version) 2021-08-24 00:29:31 +08:00
peterlu14 5605bcbe68 [update] remove wrong index 2021-08-20 19:59:32 +08:00
TommyXin 6a85c88fb7 controller id 2021-08-20 18:22:41 +08:00
TommyXin bc687cc2de collection add controller id 2021-08-20 18:15:19 +08:00
peterlu14 6bb37fd48d [update] fix sub_signal 2021-08-20 18:09:34 +08:00
TommyXin 4cbc3873f7 change controller api update path 2021-08-20 17:50:32 +08:00
peterlu14 64a6698611 [update] execute python file path 2021-08-20 16:55:03 +08:00
peterlu14 70a4f448e9 [update] change output data delimiter 2021-08-20 16:17:21 +08:00
peterlu14 ddd4524407 [update] fix start_index < 0 2021-08-20 16:06:42 +08:00
peterlu14 92a2fc8a26 [update] add spikeDetect all & partial 2021-08-20 13:27:37 +08:00
peterlu14 af999c8b33 [update] spikeDetect 2021-08-20 11:38:25 +08:00
TommyXin 5a1577db80 update mini batch 2021-08-09 23:32:05 +08:00
TommyXin f62c99c73a batch update raw&mini 2021-08-09 07:39:17 +08:00
TommyXin ac8c52b75b delete meta include subfile 2021-08-09 01:45:51 +08:00
TommyXin e240ff24b2 get meta by customer order 2021-08-07 20:29:12 +08:00
TommyXin 9fa0fd5322 meta get by attr 2021-08-07 19:51:33 +08:00
TommyXin 567855b7e5 [collection] update 2021-08-07 17:44:01 +08:00
TommyXin 8613369885 [meta] add get meta by attr&limit 2021-08-06 20:22:41 +08:00
peterlu14 88e5f0c155 [update] add route get meta all 2021-07-13 18:05:25 +08:00
TommyXin d7a3a06039 Merge branch 'task_config' 2021-07-01 21:49:31 +08:00
TommyXin 6a3c35e594 [update] task api route 2021-06-30 13:37:11 +08:00
TommyXin a9f030e95f [init] task model 2021-06-28 08:58:23 +08:00
peterlu14 71f84cb25b Merge branch 'feature/auto_connection' 2021-06-10 16:12:57 +08:00
peterlu14 13996acf5a [update] device delete 2021-05-20 03:45:06 +08:00
peterlu14 dd3328b96c [update] wifi name & software 2021-05-19 20:50:57 +08:00
peterlu14 47fd4d26b0 [update] get data by order 2021-05-05 10:29:57 +08:00
peterlu14 685e7d2f15 [update] controller & device methods 2021-04-26 10:04:27 +08:00
peterlu14 edc3859ba7 [update] getDeviceAll in order 2021-04-22 11:20:50 +08:00
peterlu14 9848de900b [update] device column & add update api 2021-04-21 11:42:47 +08:00
peterlu14 b09d39f18f [fix] spelling error 2021-04-20 20:05:01 +08:00
peterlu14 7283498e26 [update] device new column & priority 2021-04-20 20:02:38 +08:00
peterlu14 00c508fd78 Merge branch 'master' into feature/auto_connection 2021-04-15 16:40:20 +08:00
peterlu14 f02be97497 [update] routes 2021-04-14 16:56:59 +08:00
peterlu14 6845d78716 [update] device path change 2021-04-14 15:11:30 +08:00
peterlu14 1c8c26ff25 [update] add new routes get_by_ids 2021-04-12 13:56:09 +08:00
TommyXin d4f9a6f5f4 [db] task, user, scheduler model 2021-03-31 19:51:05 +08:00
peterlu14 7ddc9d8220 [update] add devcie serial number && create 2021-03-31 01:24:05 +08:00
peterlu14 a9114cc05f [update] create device routes 2021-03-31 01:03:59 +08:00
TommyXin 9cde625d0c [db] device, controller 2021-03-24 19:37:32 +08:00
peterlu14 9fa91fcd63 [update] controller & file table 2021-03-24 16:09:53 +08:00
TommyXin 27a140df3d set size,time to string 2021-03-22 17:10:04 +08:00
peterlu14 20a2b74e9f [update] time_duration type int4 to double 2021-03-02 11:56:28 +08:00
warren30815 11e90e1685 Merge branch 'develop' into 'master'
[add] delete data route (via call Sequelize destroy)

See merge request bioproscientific/bioproapiserver!1
2021-02-25 05:03:09 +00:00
29 changed files with 1635 additions and 52 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
"scripts": {
"start": "gulp nodemon",
"dev": "gulp",
"build": "babel src -d dist",
"build": "babel src -d dist --copy-files",
"production": "node dist/app.js",
"test": "jest",
"link": "eslint .",
+57
View File
@@ -0,0 +1,57 @@
import RecordingDataMeta from '../../models/file/recording_data_meta'
import childProcess from 'child_process'
import path from 'path'
const recordingDataMeta = new RecordingDataMeta()
export const spikeDetect = async (ctx, next) => {
const request = ctx.request.body
const id = request.id
const channel = request.channel
const cutOffFreq = request.cut_off_freq
const threshold = request.threshold
const waveForm = request.waveForm
const retDataType = request.ret_data_type
// console.log(id, channel, cutOffFreq, threshold, waveForm)
const result = await recordingDataMeta.getByID(id)
const channels = JSON.parse(result[0].channels)
const sampleRate = 8e5 / result[0].parameter_set.ADC_CLOCK / channels.length
const timeDuration = result[0].time_duration / 1e6
// console.log(sampleRate, timeDuration)
const process = childProcess.spawnSync('python3', [
path.join(__dirname, '/spikeDetect.py'),
'meta_id=' + id,
'channel=' + channel,
'cut_off_freq=' + cutOffFreq,
'threshold=' + threshold,
'waveform=' + waveForm,
'sample_rate=' + sampleRate,
'time_duration=' + timeDuration,
'ret_data_type=' + retDataType
], { maxBuffer: 2 * 1024 * 1024 * 1024 })
// console.log('out', process.stdout.toString())
console.log('err', process.stderr.toString())
ctx.body = process.stdout.toString()
// const process = child_process.execSync('python3 /Users/lubokai/Desktop/bioproapiserver/src/controllers/analysis/test.py 1089 0')
// console.log(process)
// process.stdout.on('data', (data) => {
// _data += data.toString()
// })
// process.stderr.on('data', (data) => {
// console.error(data.toString())
// })
// process.on('exit', (code) => {
// console.log(_data)
// console.log(`Child exited with code ${code}`)
// })
next()
}
+121
View File
@@ -0,0 +1,121 @@
import sys
import ast
import time
import psycopg2
import numpy as np
import pandas as pd
from math import ceil, floor
from json import loads, dumps
from scipy.fft import fft, fftfreq, rfft, rfftfreq, irfft, ifft
import lttb
from lttb.validators import has_two_columns, x_is_regular
def get_downsampled_signal(ori_signal, output_length):
signal_length = len(ori_signal)
signal = np.array([range(signal_length), ori_signal]).T
assert signal.shape == (signal_length, 2)
# Downsampling
downsampled_signal = lttb.downsample(signal, n_out=output_length, validators=[has_two_columns, x_is_regular])
assert downsampled_signal.shape == (output_length, 2)
downsampled_signal_index = downsampled_signal[:, 0]
downsampled_signal_value = downsampled_signal[:, 1]
return downsampled_signal_index, downsampled_signal_value
if __name__ == '__main__':
params = {}
for input in sys.argv[1:]: #Now we're going to iterate over argv[1:] (argv[0] is the program name)
param = input.split("=") #Get what's left of the '='
params[param[0]] = param[1]
meta_id = params['meta_id']
channel = params['channel']
cut_off_freq = int(params['cut_off_freq'])
threshold = ast.literal_eval('[' + params['threshold'] + ']')
waveform = ast.literal_eval('[' + params['waveform'] + ']')
SAMPLE_RATE = int(float(params['sample_rate']))
DURATION = ceil(float(params['time_duration']))
DELTA_TIME = 1e6 / SAMPLE_RATE
N = SAMPLE_RATE * DURATION
ret_data_type = params['ret_data_type']
# print(meta_id, channel, cut_off_freq, threshold, waveForm, SAMPLE_RATE, DURATION, N)
conn = psycopg2.connect(database="postgres", user="biopro", password="BioProControlBox", host="127.0.0.1", port="5432")
cur = conn.cursor()
sql_str = 'SELECT data FROM "public"."' + str(channel) + '_recording_data_raws" WHERE parent = ' + meta_id + 'ORDER BY id ASC'
cur.execute(sql_str)
ret = None
try:
ret = cur.fetchall()
except BaseException as e:
print(e)
exit
finally:
timeArray = np.array([], dtype=int)
dataArray = np.array([])
for sub_data in ret:
for split_data in sub_data[0].split('"***"')[:-1]:
value = np.array(split_data.split(' '))
timeArray = np.append(timeArray, value[::2].astype(np.int32))
dataArray = np.append(dataArray, value[1::2].astype(np.int32))
xf = rfftfreq(N, 1 / SAMPLE_RATE)
points_per_freq = len(xf) / (SAMPLE_RATE / 2)
target_idx = int(points_per_freq * cut_off_freq)
# print(xf[target_idx])
yf = rfft(dataArray)
yf[:target_idx] = 0
new_sig = np.round(irfft(yf, len(dataArray)),3)
if threshold[0] == 'below':
th = new_sig < threshold[1]
elif threshold[0] == 'over':
th = new_sig > threshold[1]
elif threshold[0] == 'auto':
th = new_sig
threshold_edges = np.convolve([1, -1], th, mode='same')
thresholded_edge_indices = np.where(threshold_edges==1)[0]
filter_array = []
for idx, point in enumerate(thresholded_edge_indices):
if idx > 0:
if timeArray[thresholded_edge_indices[idx]] - int(waveform[2]) >= timeArray[thresholded_edge_indices[idx-1]]:
filter_array.append(True)
elif timeArray[thresholded_edge_indices[idx]] - int(waveform[1]) >= timeArray[thresholded_edge_indices[idx-1]]:
filter_array.append(True)
else:
filter_array.append(False)
else:
if timeArray[thresholded_edge_indices[idx]] - int(waveform[1]) < 0:
filter_array.append(False)
else:
filter_array.append(True)
timemark_list = thresholded_edge_indices[filter_array]
OUTPUT_SIGNAL_SIZE = 2000
downsampled_signal_index, downsampled_signal_value = get_downsampled_signal(new_sig, OUTPUT_SIGNAL_SIZE)
if ret_data_type == 'all':
print(' '.join(str(x) for x in timeArray))
print(' '.join(str(x) for x in downsampled_signal_index))
print(' '.join(str(x) for x in downsampled_signal_value))
print(' '.join(str(x) for x in timemark_list))
elif ret_data_type == 'partial':
return_sub_signal_lists = {}
for timemark in timemark_list:
start_index = timemark - floor(int(waveform[1] / DELTA_TIME))
end_index = timemark + ceil(int(waveform[2] / DELTA_TIME))
subSignal = new_sig[start_index: end_index + 2]
return_sub_signal_lists[str(timemark)] = ' '.join(str(x) for x in subSignal)
print(dumps(return_sub_signal_lists))
conn.commit()
conn.close()
exit
+69
View File
@@ -0,0 +1,69 @@
import TaskModal from '../../models/controller/task'
const task = new TaskModal()
export const create = async (ctx, next) => {
const data = ctx.request.body
const result = await task.create(data)
ctx.body = result
next()
}
export const update = async (ctx, next) => {
const data = ctx.request.body
const result = await task.update(data)
ctx.body = result
next()
}
export const updateByID = async (ctx, next) => {
const data = ctx.request.body
const id = ctx.params.id
const result = await task.updateByID(data, id)
ctx.body = result
next()
}
export const updateByAttr = async (ctx, next) => {
const data = ctx.request.body
const attr = ctx.params.attr
const value = ctx.params.value
const result = await task.updateByAttr(data, attr, value)
ctx.body = result
next()
}
export const clearDeleted = async (ctx, next) => {
const result = await task.clearDeleted()
ctx.body = result
next()
}
export const getByID = async (ctx, next) => {
const id = ctx.params.id
const result = await task.getByID(id)
ctx.body = result
next()
}
export const getByAttr = async (ctx, next) => {
const attr = ctx.params.attr
const value = ctx.params.value
const result = await task.getByAttr(attr, value)
ctx.body = result
next()
}
export const getAll = async (ctx, next) => {
const result = await task.getAll()
ctx.body = result
next()
}
+6 -3
View File
@@ -20,7 +20,8 @@ export const update = async (ctx, next) => {
}
export const clearDeleted = async (ctx, next) => {
const result = await collection.clearDeleted()
const controllerID = ctx.params.controller_id
const result = await collection.clearDeleted(controllerID)
ctx.body = result
next()
@@ -36,7 +37,8 @@ export const getByID = async (ctx, next) => {
export const getByName = async (ctx, next) => {
const name = ctx.params.name
const result = await collection.getByName(name)
const controllerID = ctx.params.controller_id
const result = await collection.getByName(name, controllerID)
ctx.body = result
next()
@@ -62,7 +64,8 @@ export const getByParentName = async (ctx, next) => {
}
export const getAll = async (ctx, next) => {
const result = await collection.getAll()
const controllerID = ctx.params.controller_id
const result = await collection.getAll(controllerID)
ctx.body = result
next()
@@ -6,6 +6,7 @@ const recordingDataMeta = new RecordingDataMeta()
export const create = async (ctx, next) => {
const data = ctx.request.body
console.log(auth.CheckAuth(ctx))
// console.log(data)
// console.log(ctx.request.header.authorization)
const result = await recordingDataMeta.create(data)
// console.log(result)
@@ -47,6 +48,40 @@ export const getByParent = async (ctx, next) => {
next()
}
export const getCountByParent = async (ctx, next) => {
const type = ctx.params.type
const parent = ctx.params.parent
const result = await recordingDataMeta.getCountByParent(type, parent)
ctx.body = result
next()
}
export const getByParentWithLimit = async (ctx, next) => {
const type = ctx.params.type
const parent = ctx.params.parent
const limit = ctx.params.limit
const offset = ctx.params.offset
const order = ctx.params.order
const result = await recordingDataMeta.getByParentWithLimit(type, parent, limit, offset, order)
ctx.body = result
next()
}
export const getByAttrsParentWithLimit = async (ctx, next) => {
const type = ctx.params.type
const parent = ctx.params.parent
const limit = ctx.params.limit
const offset = ctx.params.offset
const order = ctx.params.order
const attr = ctx.params.attr
const result = await recordingDataMeta.getByAttrsParentWithLimit(type, parent, limit, offset, order, attr)
ctx.body = result
next()
}
export const getByUUID = async (ctx, next) => {
const uuid = ctx.params.uuid
const result = await recordingDataMeta.getByUUID(uuid)
@@ -25,6 +25,16 @@ export const update = async (ctx, next) => {
next()
}
export const updateByIDs = async (ctx, next) => {
const index = ctx.params.channel
const data = ctx.request.body
const id = ctx.params.id
const result = await recordingDataMini.updateByIDs(data, id, index)
ctx.body = result
next()
}
// export const get = async (ctx, next) => {
// const index = ctx.params.channel
// const id = ctx.params.id
@@ -51,6 +61,15 @@ export const getByID = async (ctx, next) => {
next()
}
export const getByIDs = async (ctx, next) => {
const index = ctx.params.channel
const id = ctx.params.id
const result = await recordingDataMini.getByIDs(id, index)
ctx.body = result
next()
}
export const getMeanDataByID = async (ctx, next) => {
const index = ctx.params.channel
const id = ctx.params.id
@@ -25,6 +25,26 @@ export const update = async (ctx, next) => {
next()
}
export const updateSdData = async (ctx, next) => {
const index = ctx.params.channel
const data = ctx.request.body
const id = ctx.params.id
const result = await recordingDataRaw.updateSdData(data, id, index)
ctx.body = result
next()
}
export const updateByIDs = async (ctx, next) => {
const index = ctx.params.channel
const data = ctx.request.body
const id = ctx.params.id
const result = await recordingDataRaw.updateByIDs(data, id, index)
ctx.body = result
next()
}
export const clearDeleted = async (ctx, next) => {
const index = ctx.params.channel
const result = await recordingDataRaw.clearDeleted(index)
@@ -42,6 +62,15 @@ export const getByID = async (ctx, next) => {
next()
}
export const getByIDs = async (ctx, next) => {
const index = ctx.params.channel
const id = ctx.params.id
const result = await recordingDataRaw.getByIDs(id, index)
ctx.body = result
next()
}
export const getDataByID = async (ctx, next) => {
const index = ctx.params.channel
const id = ctx.params.id
@@ -70,6 +99,16 @@ export const getAttrByID = async (ctx, next) => {
next()
}
export const getAttrByIDs = async (ctx, next) => {
const index = ctx.params.channel
const id = ctx.params.id
const attr = ctx.params.attr
const result = await recordingDataRaw.getByAttrIDs(id, attr, index)
ctx.body = result
next()
}
export const getAttrByParent = async (ctx, next) => {
const index = ctx.params.channel
const parent = ctx.params.parent
+9 -1
View File
@@ -1,17 +1,25 @@
import upload from './upload'
import * as api from './api'
import * as auth from './auth'
import * as controller from './product/controller'
import * as device from './product/device'
import * as collection from './file/collection'
import * as task from './controller/task'
import * as recordingDataMeta from './file/recording_data_meta'
import * as recordingDataRaw from './file/recording_data_raw'
import * as recordingDataMini from './file/recording_data_mini'
import * as analysis from './analysis'
export default {
upload,
api,
auth,
controller,
device,
collection,
task,
recordingDataMeta,
recordingDataRaw,
recordingDataMini
recordingDataMini,
analysis
}
+95
View File
@@ -0,0 +1,95 @@
import ControllerModal from '../../models/product/controller'
const controller = new ControllerModal()
export const create = async (ctx, next) => {
const data = ctx.request.body
const result = await controller.create(data)
ctx.body = result
next()
}
export const update = async (ctx, next) => {
const data = ctx.request.body
const id = ctx.params.id
const result = await controller.update(data, id)
ctx.body = result
next()
}
export const updateByID = async (ctx, next) => {
const data = ctx.request.body
const id = ctx.params.id
const result = await controller.updateByID(data, id)
ctx.body = result
next()
}
export const updateByAttr = async (ctx, next) => {
const data = ctx.request.body
const attr = ctx.params.attr
const value = ctx.params.value
const result = await controller.updateByAttr(data, attr, value)
ctx.body = result
next()
}
export const clearDeleted = async (ctx, next) => {
const result = await controller.clearDeleted()
ctx.body = result
next()
}
export const getByMac = async (ctx, next) => {
const mac = ctx.params.mac
const result = await controller.getByMac(mac)
ctx.body = result
next()
}
export const getByAttr = async (ctx, next) => {
const attr = ctx.params.attr
const value = ctx.params.value
const result = await controller.getByAttr(attr, value)
ctx.body = result
next()
}
export const getAll = async (ctx, next) => {
const result = await controller.getAll()
ctx.body = result
next()
}
// export const createTest = async (ctx, next) => {
// const data = {
// name: 'test',
// parent: -1,
// size: 0
// }
// const result = await controller.create(data)
// ctx.body = result
// next()
// }
// export const updateTest = async (ctx, next) => {
// const data = {
// name: 'test121',
// parent: -1232,
// size: 1243
// }
// const id = 2
// const result = await controller.update(data, id)
// ctx.body = result
// next()
// }
+103
View File
@@ -0,0 +1,103 @@
import DeviceModal from '../../models/product/device'
const device = new DeviceModal()
export const create = async (ctx, next) => {
const data = ctx.request.body
const result = await device.create(data)
ctx.body = result
next()
}
export const update = async (ctx, next) => {
const data = ctx.request.body
const result = await device.update(data)
ctx.body = result
next()
}
export const updateByID = async (ctx, next) => {
const data = ctx.request.body
const id = ctx.params.id
const result = await device.updateByID(data, id)
ctx.body = result
next()
}
export const updateByMac = async (ctx, next) => {
const data = ctx.request.body
const mac = ctx.params.mac
const result = await device.updateByMac(data, mac)
ctx.body = result
next()
}
export const updateByAttr = async (ctx, next) => {
const data = ctx.request.body
const attr = ctx.params.attr
const value = ctx.params.value
const result = await device.updateByAttr(data, attr, value)
ctx.body = result
next()
}
export const clearDeleted = async (ctx, next) => {
const result = await device.clearDeleted()
ctx.body = result
next()
}
export const getByMac = async (ctx, next) => {
const mac = ctx.params.mac
const result = await device.getByMac(mac)
ctx.body = result
next()
}
export const getByAttr = async (ctx, next) => {
const attr = ctx.params.attr
const value = ctx.params.value
const result = await device.getByAttr(attr, value)
ctx.body = result
next()
}
export const getAll = async (ctx, next) => {
const result = await device.getAll()
ctx.body = result
next()
}
// export const createTest = async (ctx, next) => {
// const data = {
// name: 'test',
// parent: -1,
// size: 0
// }
// const result = await device.create(data)
// ctx.body = result
// next()
// }
// export const updateTest = async (ctx, next) => {
// const data = {
// name: 'test121',
// parent: -1232,
// size: 1243
// }
// const id = 2
// const result = await device.update(data, id)
// ctx.body = result
// next()
// }
+3
View File
@@ -23,6 +23,9 @@ db.Sequelize = Sequelize
db.sequelize = sequelize
db.tutorials = require('./schema/tutirial.model')(sequelize, Sequelize)
db.controllers = require('./schema/controller.model')(sequelize, Sequelize)
db.tasks = require('./schema/task.model')(sequelize, Sequelize)
db.devices = require('./schema/device.model')(sequelize, Sequelize)
db.collections = require('./schema/collection.model')(sequelize, Sequelize)
db.recording_data_metas = require('./schema/recording_data_meta.model')(sequelize, Sequelize)
for (let i = 0; i < 32; i++) {
+4
View File
@@ -7,6 +7,10 @@ module.exports = (sequelize, Sequelize) => {
type: Sequelize.JSONB,
defaultValue: {}
},
controller_id: {
type: Sequelize.INTEGER,
defaultValue: -1
},
size: {
type: Sequelize.INTEGER,
defaultValue: -1
+125
View File
@@ -0,0 +1,125 @@
module.exports = (sequelize, Sequelize) => {
const Controller = sequelize.define('controller', {
name: {
type: Sequelize.STRING,
defaultValue: ''
},
spec: {
type: Sequelize.STRING,
defaultValue: ''
},
mac_address: {
type: Sequelize.STRING,
defaultValue: ''
},
ip_address: {
type: Sequelize.STRING,
defaultValue: ''
},
configuration: {
type: Sequelize.JSONB,
defaultValue: {}
},
wifi_name: {
type: Sequelize.STRING,
defaultValue: ''
},
wifi_password: {
type: Sequelize.STRING,
defaultValue: ''
},
mqtt_id: {
type: Sequelize.STRING,
defaultValue: ''
},
mqtt_address: {
type: Sequelize.STRING,
defaultValue: ''
},
api_mqtt_address: {
type: Sequelize.STRING,
defaultValue: ''
},
root: {
type: Sequelize.INTEGER,
defaultValue: -1
},
// group/user: {
// admin: [id...],
// normal: [id...],
// guest: [id...]
// }
group_auth: {
type: Sequelize.JSONB,
defaultValue: {
owner: [],
maintainer: [],
guest: []
}
},
user_auth: {
type: Sequelize.JSONB,
defaultValue: {
owner: [],
maintainer: [],
guest: []
}
},
device: {
type: Sequelize.JSONB,
defaultValue: {}
},
device_scanned: {
type: Sequelize.ARRAY(Sequelize.STRING),
defaultValue: []
},
device_connected: {
type: Sequelize.ARRAY(Sequelize.STRING),
defaultValue: []
},
// project/task: {
// running: [id...],
// library: [id...]
// }
project: {
type: Sequelize.STRING,
defaultValue: ''
},
task: {
type: Sequelize.STRING,
defaultValue: ''
},
// task: {
// type: Sequelize.JSONB,
// defaultValue: {
// running: [],
// library: []
// }
// },
software_version: {
type: Sequelize.STRING,
defaultValue: ''
},
status: {
type: Sequelize.STRING,
defaultValue: ''
},
deleted: {
type: Sequelize.BOOLEAN,
defaultValue: false
},
created_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
}
},
{
timestamps: false
})
return Controller
}
+95
View File
@@ -0,0 +1,95 @@
module.exports = (sequelize, Sequelize) => {
const Device = sequelize.define('device', {
name: {
type: Sequelize.STRING
},
mac_address: {
type: Sequelize.STRING
},
serial_number: {
type: Sequelize.STRING
},
configuration: {
type: Sequelize.JSONB,
defaultValue: {}
},
library: {
type: Sequelize.STRING
},
library_version: {
type: Sequelize.STRING
},
device_version: {
type: Sequelize.STRING
},
type: {
type: Sequelize.STRING,
defaultValue: ''
},
battery: {
type: Sequelize.INTEGER,
defaultValue: 0
},
temperature: {
type: Sequelize.DOUBLE,
defaultValue: 0
},
auto_connect: {
type: Sequelize.BOOLEAN,
defaultValue: true
},
connect_priority: {
type: Sequelize.INTEGER,
defaultValue: 0
},
connect_time: {
type: Sequelize.BIGINT,
defaultValue: 0
},
connect_status: {
type: Sequelize.STRING,
defaultValue: 'idle'
},
connect_id: {
type: Sequelize.INTEGER,
defaultValue: -1
},
parameter_set: {
type: Sequelize.JSONB,
defaultValue: {}
},
running: {
type: Sequelize.BOOLEAN,
defaultValue: false
},
calibration: {
type: Sequelize.TEXT,
defaultValue: ''
},
user_auth: {
type: Sequelize.JSONB,
defaultValue: {
owner: [],
maintainer: [],
guest: []
}
},
deleted: {
type: Sequelize.BOOLEAN,
defaultValue: false
},
created_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
}
},
{
timestamps: false
})
return Device
}
+9 -5
View File
@@ -22,12 +22,12 @@ module.exports = (sequelize, Sequelize) => {
defaultValue: ''
},
size: {
type: Sequelize.INTEGER,
defaultValue: -1
type: Sequelize.STRING,
defaultValue: '-1'
},
time_duration: {
type: Sequelize.INTEGER,
defaultValue: 0
type: Sequelize.STRING,
defaultValue: '0'
},
configuration: {
type: Sequelize.JSONB,
@@ -79,7 +79,11 @@ module.exports = (sequelize, Sequelize) => {
},
user_auth: {
type: Sequelize.JSONB,
defaultValue: {}
defaultValue: {
owner: [],
maintainer: [],
guest: []
}
},
created_at: {
type: Sequelize.DATE,
+6 -6
View File
@@ -8,8 +8,8 @@ module.exports = (sequelize, Sequelize, i) => {
defaultValue: 0
},
size: {
type: Sequelize.INTEGER,
defaultValue: -1
type: Sequelize.STRING,
defaultValue: '-1'
},
path: {
type: Sequelize.STRING,
@@ -36,12 +36,12 @@ module.exports = (sequelize, Sequelize, i) => {
defaultValue: -1
},
start_time: {
type: Sequelize.INTEGER,
defaultValue: -1
type: Sequelize.STRING,
defaultValue: '-1'
},
end_time: {
type: Sequelize.INTEGER,
defaultValue: -1
type: Sequelize.STRING,
defaultValue: '-1'
},
data_random: {
type: Sequelize.TEXT,
+10 -6
View File
@@ -8,8 +8,8 @@ module.exports = (sequelize, Sequelize, i) => {
defaultValue: 0
},
size: {
type: Sequelize.INTEGER,
defaultValue: -1
type: Sequelize.STRING,
defaultValue: '-1'
},
path: {
type: Sequelize.STRING,
@@ -32,17 +32,21 @@ module.exports = (sequelize, Sequelize, i) => {
defaultValue: -1
},
start_time: {
type: Sequelize.INTEGER,
defaultValue: -1
type: Sequelize.STRING,
defaultValue: '-1'
},
end_time: {
type: Sequelize.INTEGER,
defaultValue: -1
type: Sequelize.STRING,
defaultValue: '-1'
},
data: {
type: Sequelize.TEXT,
defaultValue: ''
},
sd_data: {
type: Sequelize.TEXT,
defaultValue: ''
},
compressed: {
type: Sequelize.BOOLEAN,
defaultValue: false
+36
View File
@@ -0,0 +1,36 @@
module.exports = (sequelize, Sequelize) => {
const Scheduler = sequelize.define('scheduler', {
name: {
type: Sequelize.STRING
},
description: {
type: Sequelize.STRING,
defaultValue: ''
},
script: {
type: Sequelize.STRING,
defaultValue: ''
},
configuration: {
type: Sequelize.JSONB,
defaultValue: {}
},
deleted: {
type: Sequelize.BOOLEAN,
defaultValue: false
},
created_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
}
},
{
timestamps: false
})
return Scheduler
}
+49
View File
@@ -0,0 +1,49 @@
module.exports = (sequelize, Sequelize) => {
const Task = sequelize.define('task', {
name: {
type: Sequelize.STRING,
defaultValue: ''
},
describe: {
type: Sequelize.STRING,
defaultValue: ''
},
status: {
type: Sequelize.STRING,
defaultValue: ''
},
device_config: {
type: Sequelize.JSONB,
defaultValue: {}
},
chart_config: {
type: Sequelize.JSONB,
defaultValue: {}
},
formula_config: {
type: Sequelize.JSONB,
defaultValue: {}
},
controller_id: {
type: Sequelize.INTEGER,
defaultValue: -1
},
deleted: {
type: Sequelize.BOOLEAN,
defaultValue: false
},
created_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
}
},
{
timestamps: false
})
return Task
}
+70
View File
@@ -0,0 +1,70 @@
module.exports = (sequelize, Sequelize) => {
const User = sequelize.define('user', {
account: {
type: Sequelize.STRING
},
paword: {
type: Sequelize.STRING
},
name: {
type: Sequelize.STRING
},
mail: {
type: Sequelize.STRING,
defaultValue: ''
},
configuration: {
type: Sequelize.JSONB,
defaultValue: {}
},
devices_list: {
type: Sequelize.JSONB,
defaultValue: {
owner: [],
maintainer: [],
guest: []
}
},
controller_list: {
type: Sequelize.JSONB,
defaultValue: {
owner: [],
maintainer: [],
guest: []
}
},
collection_list: {
type: Sequelize.JSONB,
defaultValue: {
owner: [],
maintainer: [],
guest: []
}
},
meta_list: {
type: Sequelize.JSONB,
defaultValue: {
owner: [],
maintainer: [],
guest: []
}
},
deleted: {
type: Sequelize.BOOLEAN,
defaultValue: false
},
created_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
}
},
{
timestamps: false
})
return User
}
+105
View File
@@ -0,0 +1,105 @@
const db = require('../../db/database')
// const Op = db.Sequelize.Op
class TaskModel {
async create (req) {
console.log(req)
return db.tasks.create(req)
}
async update (req) {
const ret = await db.tasks.update(
req,
{
where: {}
}
)
return ret
}
async updateByID (req, id) {
const ret = await db.tasks.update(
req,
{
where: {
id: id
}
}
)
return ret
}
async updateByAttr (req, attr, value) {
const whereObj = {}
const attrList = attr.split('-')
const valueList = value.split('-')
attrList.forEach((key, idx) => {
whereObj[key] = valueList[idx]
})
const ret = await db.tasks.update(
req,
{
where: whereObj
}
)
return ret
}
async clearDeleted () {
const ret = await db.tasks.delete(
{
where: {
deleted: true
}
}
)
return ret
}
async getByID (id) {
const ret = await db.tasks.findAll(
{
where: {
id: id
}
}
)
return ret
}
async getByName (name) {
const ret = await db.tasks.findAll(
{
where: {
name: name
}
}
)
return ret
}
async getByAttr (attr, value) {
const whereObj = {}
const attrList = attr.split('-')
const valueList = value.split('-')
attrList.forEach((key, idx) => {
whereObj[key] = valueList[idx]
})
const ret = await db.tasks.findAll(
{
where: whereObj
}
)
return ret
}
async getAll () {
const ret = await db.tasks.findAll()
return ret
}
}
export default TaskModel
+52 -21
View File
@@ -4,11 +4,7 @@ const Op = db.Sequelize.Op
class CollectionModel {
async create (req) {
return db.collections.create({
name: req.name,
parent: req.parent,
size: req.size
})
return db.collections.create(req)
}
async update (req, id) {
@@ -23,14 +19,26 @@ class CollectionModel {
return ret
}
async clearDeleted () {
const ret = await db.collections.delete(
{
where: {
deleted: true
async clearDeleted (controllerID) {
let ret
if (controllerID == null) {
ret = await db.collections.destroy(
{
where: {
deleted: true
}
}
}
)
)
} else {
ret = await db.collections.destroy(
{
where: {
controller_id: controllerID,
deleted: true
}
}
)
}
return ret
}
@@ -45,14 +53,26 @@ class CollectionModel {
return ret
}
async getByName (name) {
const ret = await db.collections.findAll(
{
where: {
name: name
async getByName (name, controllerID) {
let ret
if (controllerID == null) {
ret = await db.collections.findAll(
{
where: {
name: name
}
}
}
)
)
} else {
ret = await db.collections.findAll(
{
where: {
controller_id: controllerID,
name: name
}
}
)
}
return ret
}
@@ -100,8 +120,19 @@ class CollectionModel {
return ret
}
async getAll () {
const ret = await db.collections.findAll()
async getAll (controllerID) {
let ret
if (controllerID == null) {
ret = await db.collections.findAll()
} else {
ret = await db.collections.findAll(
{
where: {
controller_id: controllerID
}
}
)
}
return ret
}
}
+102 -2
View File
@@ -1,4 +1,10 @@
import RecordingDataRaw from './recording_data_raw'
import RecordingDataMini from './recording_data_mini'
const db = require('../../db/database')
// const RecordingDataMini = require('./recording_data_mini')
const recordingDataRaw = new RecordingDataRaw()
const recordingDataMini = new RecordingDataMini()
const Op = db.Sequelize.Op
@@ -36,7 +42,40 @@ class RecordingDataMeta {
}
async clearDeleted () {
const ret = await db.recording_data_metas.destroy(
let ret = await db.recording_data_metas.findAll(
{
attributes: [
'id',
'raw_data',
'mini_data'
],
where: {
deleted: true
}
}
)
for (let i = 0; i < ret.length; i++) {
const meta = ret[i]
for (const channel in meta.raw_data) {
if (meta.raw_data[channel] != null) {
await recordingDataRaw.updateByIDs({ deleted: true }, meta.raw_data[channel], channel)
recordingDataRaw.clearDeleted(channel)
}
if (meta.mini_data[channel] != null) {
if (meta.mini_data[channel]['10'] !== undefined) {
await recordingDataMini.updateByIDs({ deleted: true }, meta.mini_data[channel]['10'], channel)
}
if (meta.mini_data[channel]['100'] !== undefined) {
await recordingDataMini.updateByIDs({ deleted: true }, meta.mini_data[channel]['100'], channel)
}
if (meta.mini_data[channel]['1000'] !== undefined) {
await recordingDataMini.updateByIDs({ deleted: true }, meta.mini_data[channel]['1000'], channel)
}
recordingDataMini.clearDeleted(channel)
}
}
}
ret = await db.recording_data_metas.destroy(
{
where: {
deleted: true
@@ -58,13 +97,74 @@ class RecordingDataMeta {
parent: parentOp
},
order: [
['id', 'ASC']
['id', 'DESC']
]
}
)
return ret
}
async getCountByParent (type, parent) {
const collectionType = type + '::jsonb'
const parentOp = {}
parentOp[collectionType] = {
[Op.contains]: '[' + parent + ']'
}
const ret = await db.recording_data_metas.count(
{
where: {
parent: parentOp
}
}
)
return ret
}
async getByParentWithLimit (type, parent, limit, offset, order) {
const collectionType = type + '::jsonb'
const parentOp = {}
parentOp[collectionType] = {
[Op.contains]: '[' + parent + ']'
}
const ret = await db.recording_data_metas.findAndCountAll(
{
where: {
parent: parentOp
},
order: [
['id', order]
],
limit: limit,
offset: offset
}
)
return ret
}
async getByAttrsParentWithLimit (type, parent, limit, offset, order, attr) {
const attrList = attr.split('-')
const orderList = order.split('-')
const collectionType = type + '::jsonb'
const parentOp = {}
parentOp[collectionType] = {
[Op.contains]: '[' + parent + ']'
}
const ret = await db.recording_data_metas.findAndCountAll(
{
where: {
parent: parentOp
},
attributes: attrList,
order: [
[orderList[0], orderList[1]]
],
limit: limit,
offset: offset
}
)
return ret
}
async getByID (id) {
const ret = await db.recording_data_metas.findAll(
{
+25
View File
@@ -19,6 +19,18 @@ class RecordingDataMini {
return ret
}
async updateByIDs (req, id, index) {
const ret = await db[index + '_recording_data_minis'].update(
req,
{
where: {
id: id
}
}
)
return ret
}
async clearDeleted (index) {
const ret = await db[index + '_recording_data_minis'].destroy(
{
@@ -57,6 +69,19 @@ class RecordingDataMini {
return ret
}
async getByIDs (id, index) {
const _id = JSON.parse('[' + id + ']')
const ret = await db[index + '_recording_data_minis'].findAllWithStream(
{
batchSize: 1000,
where: {
id: _id
}
}
)
return ret
}
async getMeanDataByID (id, index) {
const ret = await db[index + '_recording_data_minis'].findAllWithStream(
{
+48
View File
@@ -1,4 +1,5 @@
const db = require('../../db/database')
const sequelize = require('sequelize')
class RecordingDataRaw {
async create (req, index) {
@@ -19,6 +20,23 @@ class RecordingDataRaw {
return ret
}
async updateSdData (req, id, index) {
const ret = await db.sequelize.query(`UPDATE "public"."${index}_recording_data_raws" SET sd_data = sd_data || '${req.data}' WHERE id = ${String(id)}`)
return ret
}
async updateByIDs (req, id, index) {
const ret = await db[index + '_recording_data_raws'].update(
req,
{
where: {
id: id
}
}
)
return ret
}
async clearDeleted (index) {
const ret = await db[index + '_recording_data_raws'].destroy(
{
@@ -57,6 +75,19 @@ class RecordingDataRaw {
return ret
}
async getByIDs (id, index) {
const _id = JSON.parse('[' + id + ']')
const ret = await db[index + '_recording_data_raws'].findAllWithStream(
{
batchSize: 1000,
where: {
id: _id
}
}
)
return ret
}
async getDataByID (id, index) {
const ret = await db[index + '_recording_data_raws'].findAllWithStream(
{
@@ -85,6 +116,23 @@ class RecordingDataRaw {
return ret
}
async getByAttrIDs (id, attr, index) {
const attrList = attr.split('-')
const _id = JSON.parse('[' + id + ']')
const ord = [sequelize.literal(`ARRAY_POSITION(ARRAY[${_id}]::integer[], "id")`)]
const ret = await db[index + '_recording_data_raws'].findAll(
{
where: {
id: _id
},
attributes: attrList,
order: ord
}
)
return ret
}
async getByAttrParent (parent, attr, index) {
const attrList = attr.split('-')
const ret = await db[index + '_recording_data_raws'].findAll(
+130
View File
@@ -0,0 +1,130 @@
const db = require('../../db/database')
// const Op = db.Sequelize.Op
class ControllerModel {
async create (req) {
console.log(req)
return db.controllers.create(req)
}
async update (req, id) {
req.updated_at = db.Sequelize.literal('CURRENT_TIMESTAMP')
if (id != null) {
const ret = await db.controllers.update(
req,
{
where: {
id: id
}
}
)
return ret
} else {
const ret = await db.controllers.update(
req,
{
where: {}
}
)
return ret
}
}
async updateByID (req, id) {
req.updated_at = db.Sequelize.literal('CURRENT_TIMESTAMP')
const ret = await db.controllers.update(
req,
{
where: {
id: id
}
}
)
return ret
}
async updateByAttr (req, attr, value) {
const whereObj = {}
const attrList = attr.split('-')
const valueList = value.split('-')
attrList.forEach((key, idx) => {
whereObj[key] = valueList[idx]
})
req.updated_at = db.Sequelize.literal('CURRENT_TIMESTAMP')
const ret = await db.controllers.update(
req,
{
where: whereObj
}
)
return ret
}
async clearDeleted () {
const ret = await db.controllers.delete(
{
where: {
deleted: true
}
}
)
return ret
}
async getByID (id) {
const ret = await db.controllers.findAll(
{
where: {
id: id
}
}
)
return ret
}
async getByName (name) {
const ret = await db.controllers.findAll(
{
where: {
name: name
}
}
)
return ret
}
async getByMac (mac) {
const ret = await db.controllers.findAll(
{
where: {
mac_address: mac
}
}
)
return ret
}
async getByAttr (attr, value) {
const whereObj = {}
const attrList = attr.split('-')
const valueList = value.split('-')
attrList.forEach((key, idx) => {
whereObj[key] = valueList[idx]
})
const ret = await db.controllers.findAll(
{
where: whereObj
}
)
return ret
}
async getAll () {
const ret = await db.controllers.findAll()
return ret
}
}
export default ControllerModel
+151
View File
@@ -0,0 +1,151 @@
const db = require('../../db/database')
// const Op = db.Sequelize.Op
class DeviceModel {
async create (req) {
return db.devices.create({
name: req.name,
serial_number: req.serial_number,
mac_address: req.mac_address,
connect_priority: await db.devices.count()
})
}
async update (req, id) {
req.updated_at = db.Sequelize.literal('CURRENT_TIMESTAMP')
if (id != null) {
const ret = await db.devices.update(
req,
{
where: {
id: id
}
}
)
return ret
} else {
const ret = await db.devices.update(
req,
{
where: {}
}
)
return ret
}
}
async updateByID (req, id) {
req.updated_at = db.Sequelize.literal('CURRENT_TIMESTAMP')
const ret = await db.devices.update(
req,
{
where: {
id: id
}
}
)
return ret
}
async updateByMac (req, mac) {
req.updated_at = db.Sequelize.literal('CURRENT_TIMESTAMP')
const ret = await db.devices.update(
req,
{
where: {
mac_address: mac
}
}
)
return ret
}
async updateByAttr (req, attr, value) {
const whereObj = {}
const attrList = attr.split('-')
const valueList = value.split('-')
attrList.forEach((key, idx) => {
whereObj[key] = valueList[idx]
})
const ret = await db.devices.update(
req,
{
where: whereObj
}
)
return ret
}
async clearDeleted () {
const ret = await db.devices.destroy(
{
where: {
deleted: true
}
}
)
return ret
}
async getByID (id) {
const ret = await db.devices.findAll(
{
where: {
id: id
}
}
)
return ret
}
async getByName (name) {
const ret = await db.devices.findAll(
{
where: {
name: name
}
}
)
return ret
}
async getByMac (mac) {
const ret = await db.devices.findAll(
{
where: {
mac_address: mac
}
}
)
return ret
}
async getByAttr (attr, value) {
const attrList = attr.split('-')
const valueList = value.split('-')
const whereObj = {}
attrList.forEach((key, idx) => {
whereObj[key] = valueList[idx]
})
const ret = await db.devices.findAll(
{
where: whereObj
}
)
return ret
}
async getAll () {
const ret = await db.devices.findAll({
order: [
['connect_priority', 'ASC']
]
})
return ret
}
}
export default DeviceModel
+61 -7
View File
@@ -17,32 +17,46 @@ export default router
.get('/public/auth/get_cookie', controllers.auth.getCookie)
// collection
.post('/api/collection/create', controllers.collection.create)
.get('/api/collection/get_by_id/:id', controllers.collection.getByID)
.get('/api/collection/get_by_name/:name', controllers.collection.getByName)
.get('/api/collection/get_by_parent/:type/:parent', controllers.collection.getByParent)
.get('/api/collection/get_by_parent_name/:type/:parent/:name', controllers.collection.getByParentName)
.get('/api/collection/get/all', controllers.collection.getAll)
.post('/api/file/collection/create', controllers.collection.create)
.post('/api/file/collection/update/:id', controllers.collection.update)
.get('/api/file/collection/clear_deleted/:controller_id', controllers.collection.clearDeleted)
.get('/api/file/collection/get_by_id/:id', controllers.collection.getByID)
.get('/api/file/collection/get_by_name/:name/:controller_id', controllers.collection.getByName)
.get('/api/file/collection/get_by_parent/:type/:parent', controllers.collection.getByParent)
.get('/api/file/collection/get_by_parent_name/:type/:parent/:name', controllers.collection.getByParentName)
.get('/api/file/collection/get/all/:controller_id', controllers.collection.getAll)
.get('/api/file/collection/get_by_name/:name', controllers.collection.getByName)
.get('/api/file/collection/get/all', controllers.collection.getAll)
.get('/api/file/collection/clear_deleted/', controllers.collection.clearDeleted)
// meta
.post('/api/file/meta/create', controllers.recordingDataMeta.create)
.post('/api/file/meta/update/:id', controllers.recordingDataMeta.update)
.get('/api/file/meta/clear_deleted/:id', controllers.recordingDataMeta.clearDeleted)
.get('/api/file/meta/clear_deleted/', controllers.recordingDataMeta.clearDeleted)
.get('/api/file/meta/get_by_name/:name', controllers.recordingDataMeta.getByName)
.get('/api/file/meta/get_by_uuid/:uuid', controllers.recordingDataMeta.getByUUID)
.get('/api/file/meta/get_by_id/:id', controllers.recordingDataMeta.getByID)
.get('/api/file/meta/get_by_path/:path', controllers.recordingDataMeta.getByPath)
.get('/api/file/meta/get_by_parent/:type/:parent', controllers.recordingDataMeta.getByParent)
.get('/api/file/meta/get_count_by_parent/:type/:parent', controllers.recordingDataMeta.getCountByParent)
.get('/api/file/meta/get_by_parent_with_limit/:type/:parent/:limit/:offset/:order', controllers.recordingDataMeta.getByParentWithLimit)
.get('/api/file/meta/get_by_attr_parent_with_limit/:type/:parent/:limit/:offset/:order/:attr', controllers.recordingDataMeta.getByAttrsParentWithLimit)
.get('/api/file/meta/get_or_create_by_path/:path', controllers.recordingDataMeta.getOrCreateByPath)
.get('/api/file/meta/get/all', controllers.recordingDataMeta.getAll)
// raw
.post('/api/file/raw/create/:channel', controllers.recordingDataRaw.create)
.post('/api/file/raw/update/:channel/:id', controllers.recordingDataRaw.update)
.post('/api/file/raw/update_sd_data/:channel/:id', controllers.recordingDataRaw.updateSdData)
.get('/api/file/raw/clear_deleted/:channel/:id', controllers.recordingDataRaw.clearDeleted)
.get('/api/file/raw/get_by_id/:channel/:id', controllers.recordingDataRaw.getByID)
.get('/api/file/raw/get_by_ids/:channel/:id', controllers.recordingDataRaw.getByIDs)
.get('/api/file/raw/get_data_by_id/:channel/:id', controllers.recordingDataRaw.getDataByID)
.get('/api/file/raw/get_by_parent/:channel/:parent', controllers.recordingDataRaw.getByParent)
.get('/api/file/raw/get_attr_by_id/:channel/:id/:attr', controllers.recordingDataRaw.getAttrByID)
.get('/api/file/raw/get_attr_by_ids/:channel/:id/:attr', controllers.recordingDataRaw.getAttrByIDs)
.get('/api/file/raw/get_attr_by_parent/:channel/:parent/:attr', controllers.recordingDataRaw.getAttrByParent)
// mini
@@ -55,3 +69,43 @@ export default router
.get('/api/file/mini/get_attr_by_parent/:channel/:parent/:attr', controllers.recordingDataMini.getAttrByParent)
.get('/api/file/mini/random/get_by_id/:channel/:id', controllers.recordingDataMini.getRandomDataByID)
.get('/api/file/mini/mean/get_by_id/:channel/:id', controllers.recordingDataMini.getMeanDataByID)
// device
.post('/api/device/create', controllers.device.create)
.post('/api/device/update/all', controllers.device.update)
.post('/api/device/update_by_id/:id', controllers.device.updateByID)
.post('/api/device/update_by_mac/:mac', controllers.device.updateByMac)
.post('/api/device/update_by_attr/:attr/:value', controllers.device.updateByAttr)
.get('/api/device/clear_deleted/:id', controllers.device.clearDeleted)
.get('/api/device/get_by_mac/:mac', controllers.device.getByMac)
.get('/api/device/get_by_attr/:attr/:value', controllers.device.getByAttr)
.get('/api/device/get/all', controllers.device.getAll)
.post('/api/device/update_by_id/:id', controllers.device.updateByID)
.post('/api/device/update', controllers.device.update)
// controller
.post('/api/controller/create', controllers.controller.create)
.post('/api/controller/update/:id', controllers.controller.update)
.post('/api/controller/update/all', controllers.controller.update)
.post('/api/controller/update_by_attr/:attr/:value', controllers.controller.updateByAttr)
.get('/api/controller/get_by_mac/:mac', controllers.controller.getByMac)
.get('/api/controller/get_by_attr/:attr/:value', controllers.controller.getByAttr)
.get('/api/controller/get/all', controllers.controller.getAll)
.post('/api/controller/update_by_id/:id', controllers.controller.updateByID)
.post('/api/controller/update', controllers.controller.update)
// task
.post('/api/task/create', controllers.task.create)
.post('/api/task/update/:id', controllers.task.update)
.post('/api/task/update_by_attr/:attr/:value', controllers.task.updateByAttr)
.post('/api/task/update/all', controllers.task.update)
.get('/api/task/get_by_id/:id', controllers.task.getByID)
.get('/api/task/get_by_attr/:attr/:value', controllers.task.getByAttr)
.get('/api/task/get/all', controllers.task.getAll)
.post('/api/task/update', controllers.task.update)
.post('/api/task/update_by_id/:id', controllers.task.updateByID)
// analyze
.post('/api/analysis/spike_detect', controllers.analysis.spikeDetect)