Commit e4e2565f authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Merge julia changes from github

parents 3d3ae0ce 31fe6161
MobergIO.jl is licensed under the MIT License:
> Copyright (c) 2021: Anders Blomdell
>
> Permission is hereby granted, free of charge, to any person obtaining
> a copy of this software and associated documentation files (the
> "Software"), to deal in the Software without restriction, including
> without limitation the rights to use, copy, modify, merge, publish,
> distribute, sublicense, and/or sell copies of the Software, and to
> permit persons to whom the Software is furnished to do so, subject to
> the following conditions:
>
> The above copyright notice and this permission notice shall be
> included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
name = "MobergIO"
uuid = "9bdc2bb6-e40d-4944-bd5f-2bf890d3f651"
authors = ["Anders Blomdell <anders.blomdell@control.lth.se>"]
version = "<<<VERSION>>>"
version = "1.0.0"
[compat]
julia = "1"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]
# MobergIO.jl
A library for connecting to various input/output libraries with a common interface.
You need a local configuration and installation of Moberg for this package to work properly, see: [github.com/ControlLTH/moberg](https://github.com/ControlLTH/moberg).
mutable struct AnalogInChannel
context::Ptr{Nothing}
read::Ptr{Nothing}
end
mutable struct AnalogIn
mutable struct AnalogIn <: AbstractMobergIn
moberg::Ptr{Nothing}
index::UInt32
channel::AnalogInChannel
channel::MobergInChannel
function AnalogIn(moberg::Moberg, index::Unsigned)
channel = AnalogInChannel(0,0)
channel = MobergInChannel(0,0)
moberg_handle = moberg.handle
checkOK(ccall((:moberg_analog_in_open, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, Ref{AnalogInChannel}),
(Ptr{Nothing}, Cint, Ref{MobergInChannel}),
moberg_handle, index, channel))
self = new(moberg_handle, index, channel)
finalizer(close, self)
......@@ -24,7 +19,7 @@ function close(ain::AnalogIn)
DEBUG && println("closing $(ain)")
checkOK(ccall((:moberg_analog_in_close, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, AnalogInChannel),
(Ptr{Nothing}, Cint, MobergInChannel),
ain.moberg, ain.index, ain.channel))
end
......
mutable struct AnalogOutChannel
context::Ptr{Nothing}
write::Ptr{Nothing}
end
mutable struct AnalogOut
mutable struct AnalogOut <: AbstractMobergOut
moberg::Ptr{Nothing}
index::UInt32
channel::AnalogOutChannel
channel::MobergOutChannel
function AnalogOut(moberg::Moberg, index::Unsigned)
channel = AnalogOutChannel(0,0)
channel = MobergOutChannel(0,0)
moberg_handle = moberg.handle
checkOK(ccall((:moberg_analog_out_open, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, Ref{AnalogOutChannel}),
(Ptr{Nothing}, Cint, Ref{MobergOutChannel}),
moberg_handle, index, channel));
self = new(moberg_handle, index, channel)
finalizer(close, self)
......@@ -24,7 +19,7 @@ function close(aout::AnalogOut)
DEBUG && println("closing $(aout)")
checkOK(ccall((:moberg_analog_out_close, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, AnalogOutChannel),
(Ptr{Nothing}, Cint, MobergOutChannel),
aout.moberg, aout.index, aout.channel))
end
......
mutable struct DigitalInChannel
context::Ptr{Nothing}
read::Ptr{Nothing}
end
mutable struct DigitalIn
mutable struct DigitalIn <: AbstractMobergIn
moberg::Ptr{Nothing}
index::UInt32
channel::DigitalInChannel
channel::MobergInChannel
function DigitalIn(moberg::Moberg, index::Unsigned)
channel = DigitalInChannel(0,0)
channel = MobergInChannel(0,0)
moberg_handle = moberg.handle
checkOK(ccall((:moberg_digital_in_open, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, Ref{DigitalInChannel}),
(Ptr{Nothing}, Cint, Ref{MobergInChannel}),
moberg_handle, index, channel));
self = new(moberg_handle, index, channel)
finalizer(close, self)
......@@ -24,7 +19,7 @@ function close(din::DigitalIn)
DEBUG && println("closing $(din)")
checkOK(ccall((:moberg_digital_in_close, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, DigitalInChannel),
(Ptr{Nothing}, Cint, MobergInChannel),
din.moberg, din.index, din.channel))
end
......
mutable struct DigitalOutChannel
context::Ptr{Nothing}
write::Ptr{Nothing}
end
mutable struct DigitalOut
mutable struct DigitalOut <: AbstractMobergOut
moberg::Ptr{Nothing}
index::UInt32
channel::DigitalOutChannel
channel::MobergOutChannel
function DigitalOut(moberg::Moberg, index::Unsigned)
channel = DigitalOutChannel(0,0)
channel = MobergOutChannel(0,0)
moberg_handle = moberg.handle
checkOK(ccall((:moberg_digital_out_open, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, Ref{DigitalOutChannel}),
(Ptr{Nothing}, Cint, Ref{MobergOutChannel}),
moberg_handle, index, channel))
self = new(moberg_handle, index, channel)
finalizer(close, self)
......@@ -24,7 +19,7 @@ function close(dout::DigitalOut)
DEBUG && println("closing $(dout)")
checkOK(ccall((:moberg_digital_out_close, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, DigitalOutChannel),
(Ptr{Nothing}, Cint, MobergOutChannel),
dout.moberg, dout.index, dout.channel))
end
......
mutable struct EncoderInChannel
context::Ptr{Nothing}
read::Ptr{Nothing}
end
"""
encoder_in = EncoderIn(moberg::Moberg, index::Unsigned)
Example usage:
mutable struct EncoderIn
encoder_in = EncoderIn(m, UInt32(40))
result = read(encoder_in)
"""
mutable struct EncoderIn <: AbstractMobergIn
moberg::Ptr{Nothing}
index::UInt32
channel::EncoderInChannel
channel::MobergInChannel
function EncoderIn(moberg::Moberg, index::Unsigned)
channel = EncoderInChannel(0,0)
channel = MobergInChannel(0,0)
moberg_handle = moberg.handle
checkOK(ccall((:moberg_encoder_in_open, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, Ref{EncoderInChannel}),
(Ptr{Nothing}, Cint, Ref{MobergInChannel}),
moberg_handle, index, channel))
self = new(moberg_handle, index, channel)
finalizer(close, self)
......@@ -24,7 +27,7 @@ function close(ein::EncoderIn)
DEBUG && println("closing $(ein)")
checkOK(ccall((:moberg_encoder_in_close, "libmoberg"),
Status,
(Ptr{Nothing}, Cint, EncoderInChannel),
(Ptr{Nothing}, Cint, MobergInChannel),
ein.moberg, ein.index, ein.channel))
end
......
module MobergIO
export Moberg
import Base: close, read, write
abstract type AbstractMobergIO end
abstract type AbstractMobergIn <: AbstractMobergIO end
abstract type AbstractMobergOut <: AbstractMobergIO end
"""
close(io::AbstractMobergIO)
""" close
"""
result = read(io::AbstractMobergIn)
""" read
"""
write(io::AbstractMobergIn)
""" write
const DEBUG = false
struct Status
......@@ -12,6 +32,16 @@ function checkOK(status::Status)
end
end
mutable struct MobergOutChannel
context::Ptr{Nothing}
write::Ptr{Nothing}
end
mutable struct MobergInChannel
context::Ptr{Nothing}
read::Ptr{Nothing}
end
mutable struct Moberg
handle::Ptr{Nothing}
end
......
using Test
@test 1 == 1
\ No newline at end of file
......@@ -139,10 +139,8 @@ cp adaptors/matlab/Makefile.mex ${RPM_BUILD_ROOT}/opt/matlab/src/moberg/Makefile
# Julia
mkdir -p ${RPM_BUILD_ROOT}/opt/julia/local/packages/MobergIO/src
cp adaptors/julia/*.jl ${RPM_BUILD_ROOT}/opt/julia/local/packages/MobergIO/src
cat adaptors/julia/Project.toml.template \
| sed -e 's/<<<VERSION>>>/%{version}/' \
> ${RPM_BUILD_ROOT}/opt/julia/local/packages/MobergIO/Project.toml
cp adaptors/julia/src/*.jl ${RPM_BUILD_ROOT}/opt/julia/local/packages/MobergIO/src
cp adaptors/julia/Project.toml ${RPM_BUILD_ROOT}/opt/julia/local/packages/MobergIO/Project.toml
(
cd ${RPM_BUILD_ROOT}/opt/julia/local/packages/MobergIO
git init
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment