-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
91 lines (74 loc) · 2.06 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
library(shiny)
library(stringr)
shinyServer(function(input, output) {
dataInput <- reactive({
withProgress(message = 'Loading...', value = 0, {
f = file(input$dataset$datapath, "rb")
version = readBin(f, integer(), size = 1)
nchar = readBin(f, integer(), size = 2)
infoTextTemp = readChar(f, nchar)
ret = str_split(infoTextTemp, ";")[[1]]
nBits = readBin(f, integer(), size = 1)
nBytes = readBin(f, integer(), size = 1)
polarity = readBin(f, integer(), size = 1)
userData = readBin(f, numeric(), 6, size = 4)
sampRate = readBin(f, integer(), size = 4)
ADrange = readBin(f, numeric(), size = 4)
nPts = readBin(f, integer())
eodwave = readBin(f, integer(), nPts, size = 2)
close(f)
return (
list(
temp = ret[4],
specimen = ret[2],
date = ret[1],
species = ret[3],
comment = ret[5],
eodwave = eodwave,
nPts = nPts,
sampRate = sampRate,
ADRange = ADrange
)
)
})
})
output$startTimer <- renderUI({
if(is.null(input$dataset)) {
return()
}
datatable<-dataInput()
sliderInput("startTime", "Start", min=0, max=datatable$nPts/datatable$sampRate, value = 0)
})
output$endTimer <- renderUI({
if(is.null(input$dataset)) {
return()
}
datatable<-dataInput()
sliderInput("endTime", "End", min=0, max=datatable$nPts/datatable$sampRate, value = datatable$nPts/datatable$sampRate)
})
output$ADrage <- renderUI({
if(is.null(input$dataset)) {
return()
}
datatable<-dataInput()
})
output$distPlot <- renderPlot({
if(is.null(input$dataset)) {
return()
}
datatable<-dataInput()
x = 1:datatable$nPts/datatable$sampRate
y = datatable$eodwave
if(!is.null(input$startTime)) {
r=x>input$startTime
x = x[r]
y = y[r]
}
if(!is.null(input$endTime)) {
r=x<input$endTime
x = x[r]
y = y[r]
}
plot(x, y, type='l', ylab='Volts', xlab='Time')
})
})