Skip to content

Commit

Permalink
Add Aqua (#62)
Browse files Browse the repository at this point in the history
* Add Aqua

* Fix all Aqua errors
  • Loading branch information
jonschumacher authored Apr 28, 2023
1 parent 44002ed commit a49a53f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 34 deletions.
16 changes: 2 additions & 14 deletions src/client/julia/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,18 @@ authors = ["Tobias Knopp <[email protected]>"]
version = "0.6.0"

[deps]
#Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
#GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26"
#LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
#OpenSSH_jll = "9bd350c2-7e96-507f-8002-3f2e150b4e1b"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
#Scratch = "6c6a2e73-6563-6170-7368-637461726353"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
#URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
#ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"

[compat]
#GitHub = "5"
ProgressMeter = "1"
#Scratch = "1"
#URIs = "1"
#ZipFile = "0.9, 0.10"
julia = "1.7"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Random"]
test = ["Aqua", "Test", "Random"]
2 changes: 1 addition & 1 deletion src/client/julia/src/ADC.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export TriggerMode, INTERNAL, EXTERNAL, ADCPerformanceData, RPStatus, PerformanceData, RPPerformance, RPInfo,
decimation, decimation!, numChan, samplesPerPeriod, samplesPerPeriod!, periodsPerFrame, periodsPerFrame!,
currentWP, currentPeriod, currentFrame, masterTrigger, masterTrigger!, keepAliveReset, keepAliveReset!,
triggerMode, triggerMode!, startADC, stopADC, overwritten, corrupted, serverStatus, performanceData,
triggerMode, triggerMode!, overwritten, corrupted, serverStatus, performanceData,
readSamples, startPipelinedData, stopTransmission, triggerPropagation, triggerPropagation!

"""
Expand Down
2 changes: 1 addition & 1 deletion src/client/julia/src/ClusterView.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export RedPitayaClusterView, master, readDataPeriods, numChan, readDataSlow, readFrames, readPeriods, readPipelinedSamples, startPipelinedData, collectSamples!, readData, readDataPeriods, modeDAC, viewToCluster, clusterToView
export RedPitayaClusterView, master, numChan, readFrames, readPeriods, startPipelinedData, collectSamples!, viewToCluster, clusterToView

import Base: length, iterate, getindex, firstindex, lastindex

Expand Down
8 changes: 4 additions & 4 deletions src/client/julia/src/RedPitayaDAQServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import LinearAlgebra: normalize

import Base: reset, iterate, length, push!, pop!

export RedPitaya, send, receive, query, start, stop, disconnect, ServerMode, serverMode, serverMode!, CONFIGURATION, ACQUISITION, TRANSMISSION, getLog, ScpiBatch, execute!, clear!, @add_batch
export RedPitaya, send, receive, query, disconnect, ServerMode, serverMode, serverMode!, CONFIGURATION, ACQUISITION, TRANSMISSION, getLog, ScpiBatch, execute!, clear!, @add_batch

# TODO: The update stuff increases load times quite a bit. Should we move this to a script?
# using ProgressMeter
Expand Down Expand Up @@ -139,7 +139,7 @@ function query(rp::RedPitaya, cmd::String, T::Type, timeout::Number=getTimeout()
end

# connect with timeout implementation
function Sockets.connect(host, port::Integer, timeout::Number)
function connectTimeout(host, port::Integer, timeout::Number)
s = TCPSocket()
t = Timer(_ -> close(s), timeout)
try
Expand All @@ -156,8 +156,8 @@ end
function connect(rp::RedPitaya)
if !rp.isConnected
begin
rp.socket = connect(rp.host, rp.port, getTimeout())
rp.dataSocket = connect(rp.host, rp.dataPort, getTimeout())
rp.socket = connectTimeout(rp.host, rp.port, getTimeout())
rp.dataSocket = connectTimeout(rp.host, rp.dataPort, getTimeout())
rp.isConnected = true
updateCalib!(rp)
temp = findall([calibDACScale(rp, 1) < _scaleWarning, calibDACScale(rp, 2) < _scaleWarning])
Expand Down
23 changes: 11 additions & 12 deletions src/client/julia/src/Sequence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ struct SimpleSequence <: AbstractSequence
return new(SequenceLUT(lut, repetitions), enable)
end
end
SimpleSequence(lut::Array, repetitions::Integer, enable=nothing) = SimpleSequence(map(Float32, lut), repetitions, enable)
SimpleSequence(lut::Vector, repetitions::Integer, enable=nothing) = SimpleSequence(reshape(lut, 1, :), repetitions, enable)
SimpleSequence(lut::Array{T}, repetitions::Integer, enable::Union{Array{Bool}, Nothing}=nothing) where T <: Real = SimpleSequence(map(Float32, lut), repetitions, enable)
SimpleSequence(lut::Vector{T}, repetitions::Integer, enable::Union{Array{Bool}, Nothing}=nothing) where T <: Real = SimpleSequence(reshape(lut, 1, :), repetitions, enable)

enableLUT(seq::SimpleSequence) = seq.enable
valueLUT(seq::SimpleSequence) = seq.lut
Expand Down Expand Up @@ -179,8 +179,8 @@ struct HoldBorderRampingSequence <: RampingSequence
end
end

HoldBorderRampingSequence(lut::Array, repetitions::Integer, rampingSteps::Integer, enable=nothing) = HoldBorderRampingSequence(map(Float32, lut), repetitions, rampingSteps, enable)
HoldBorderRampingSequence(lut::Vector, repetitions::Integer, rampingSteps::Integer, enable=nothing) = HoldBorderRampingSequence(reshape(lut, 1, :), repetitions, rampingSteps, enable)
HoldBorderRampingSequence(lut::Array{T}, repetitions::Integer, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) where T <: Real = HoldBorderRampingSequence(map(Float32, lut), repetitions, rampingSteps, enable)
HoldBorderRampingSequence(lut::Vector{T}, repetitions::Integer, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) where T <: Real = HoldBorderRampingSequence(reshape(lut, 1, :), repetitions, rampingSteps, enable)

function HoldBorderRampingSequence(rp::RedPitaya, lut, repetitions, enable=nothing)
rampTime = maximum([rampingDAC(rp,i) for i=1:2 if enableRamping(rp, i)])
Expand All @@ -197,17 +197,17 @@ struct ConstantRampingSequence <: RampingSequence
lut::SequenceLUT
enable::Union{Array{Bool}, Nothing}
ramping::SequenceLUT
function ConstantRampingSequence(lut::Array{Float32}, repetitions::Integer, rampingValue::Float32, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing} = nothing)
function ConstantRampingSequence(lut::Array{Float32}, repetitions::Integer, rampingValue::Float32, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing)
if !isnothing(enable) && size(lut) != size(enable)
throw(DimensionMismatch("Size of enable LUT does not match size of value LUT"))
end
rampingLut = SequenceLUT([rampingValue for i = 1:size(lut, 1)], rampingSteps)
return new(SequenceLUT(lut, repetitions), enable, rampingLut)
end
end

ConstantRampingSequence(lut::Array, repetitions, rampingValue, rampingSteps, enable=nothing) = ConstantRampingSequence(map(Float32, lut), repetitions, Float32(rampingValue), rampingSteps, enable)
ConstantRampingSequence(lut::Vector, repetitions, rampingValue, rampingSteps, enable=nothing) = ConstantRampingSequence(reshape(lut, 1, :), repetitions, rampingValue, rampingSteps, enable)
ConstantRampingSequence(lut::Array{T}, repetitions::Integer, rampingValue::Real, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) where T <: Real = ConstantRampingSequence(map(Float32, lut), repetitions, Float32(rampingValue), rampingSteps, enable)
ConstantRampingSequence(lut::Vector{Float32}, repetitions::Integer, rampingValue::Float32, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) = ConstantRampingSequence(reshape(lut, 1, :), repetitions, rampingValue, rampingSteps, enable)
ConstantRampingSequence(lut::Vector{T}, repetitions::Integer, rampingValue::Real, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) where T <: Real = ConstantRampingSequence(reshape(lut, 1, :), repetitions, rampingValue, rampingSteps, enable)

enableLUT(seq::ConstantRampingSequence) = seq.enable
valueLUT(seq::ConstantRampingSequence) = seq.lut
Expand Down Expand Up @@ -240,10 +240,9 @@ struct StartUpSequence <: RampingSequence
return new(SequenceLUT(lut, repetitions), enable, up, down)
end
end


StartUpSequence(lut::Array, repetitions::Integer, rampingSteps::Integer, startUpSteps::Integer, enable=nothing) = StartUpSequence(map(Float32, lut), repetitions, rampingSteps, startUpSteps, enable)
StartUpSequence(lut::Vector, repetitions::Integer, rampingSteps::Integer, startUpSteps::Integer, enable=nothing) = StartUpSequence(reshape(lut, 1, :), repetitions, rampingSteps, startUpSteps, enable)
StartUpSequence(lut::Array{T}, repetitions::Integer, rampingSteps::Integer, startUpSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) where T <: Real = StartUpSequence(map(Float32, lut), repetitions, rampingSteps, startUpSteps, enable)
#StartUpSequence(lut::Vector{Float32}, repetitions::Integer, rampingSteps::Integer, startUpSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) = StartUpSequence(reshape(lut, 1, :), repetitions, rampingSteps, startUpSteps, enable)
StartUpSequence(lut::Vector{T}, repetitions::Integer, rampingSteps::Integer, startUpSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) where T <: Real = StartUpSequence(reshape(lut, 1, :), repetitions, rampingSteps, startUpSteps, enable)

enableLUT(seq::StartUpSequence) = seq.enable
valueLUT(seq::StartUpSequence) = seq.lut
Expand Down
8 changes: 6 additions & 2 deletions src/client/julia/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using RedPitayaDAQServer
using Test
using Aqua

# write your own tests here
@test 1 == 1
@testset "RedPitayaDAQServer" begin
@testset "Aqua" begin
Aqua.test_all(RedPitayaDAQServer)
end
end

0 comments on commit a49a53f

Please sign in to comment.