Engee documentation

Genie’s Public Software Management Methods

An example of creating a simple application using the Genie framework is also presented in Community Engee.

All public methods of program management are presented here. genie to work with the framework Genie. To use them in Genie applications, connect the Engee tool library using the command using Engee inside your code (app.jl).

Methods genie

EngeeDSP.modulate(x, fc, fs)
EngeeDSP.modulate(x, fc, fs, method)
EngeeDSP.modulate(x, fc, fs, method, opt)

Modulation for modeling communication systems.

Function call

  • (y, t) = modulate(x, fc, fs, method, opt) — modulates a real useful signal x using a carrier frequency fc, sampling rates fs and the method method with additional parameters specified in opt, and returns the internal time vector t.

  • (y, t) = modulate(x, fc, fs, method) — modulates a real useful signal x using a carrier frequency fc, sampling rates fs and the method method.

  • (y, t) = modulate(x, fc, fs) — modulates a real useful signal x using a carrier frequency fc and sampling rates fs. If x If the modulated signal is a matrix, then the modulated signal is calculated independently for each column and stored in the corresponding column. y.

Arguments

# Input arguments

  • x::AbstractVector{<:Real} | AbstractMatrix{<:Real} useful signal (real vector or matrix). If x — matrix, the modulation is performed independently for each column.

  • fc::Real carrier frequency (real positive scalar).

  • fs::Real: sampling rate (real positive scalar).

  • method::String: the modulation method. Possible values: "am" (by default), "amdsb-sc", "amdsb-tc", "amssb", "fm", "pm", "pwm", "ppm", "qam".

  • "am" or "amdsb-sc" Amplitude modulation (two side bands, suppressed carrier). Multiplies x per cosine with frequency fc.

    y = x .* cos(2*pi*fc*t)
  • "amdsb-tc": амплитудная модуляция (две боковые полосы, передаваемая несущая). Вычитает скаляр opt из x и умножает результат на косинус с частотой fc.

    y = (x - opt) .* cos(2*pi*fc*t)

    Если opt не задан, используется значение по умолчанию min(min(x)), чтобы (x - opt) был неотрицательным и имел минимальное значение 0.

  • "amssb": амплитудная модуляция (одиночная боковая полоса). Умножает x на косинус с частотой fc и добавляет преобразование Гильберта x, умноженное на синус с частотой fc.

    y = x .* cos(2*pi*fc*t) + imag(hilbert(x)) .* sin(2*pi*fc*t)

    Этот метод эффективно устраняет верхнюю боковую полосу частот.

  • "fm": частотная модуляция. Создает косинус с мгновенной частотой, которая изменяется в зависимости от x.

    y = cos(2*pi*fc*t + opt*cumsum(x))

    cumsum(x) — прямоугольная аппроксимация интеграла от x. opt используется как константа частотной модуляции. Если opt не задан, по умолчанию: opt = (fc/fs)*2*pi/(max(max(x))), поэтому максимальное отклонение частоты от fc будет fc Гц.

  • "pm": фазовая модуляция. Создает косинус с частотой fc, фаза которого изменяется в зависимости от x.

    y = cos(2*pi*fc*t + opt*x)

    opt используется как константа фазовой модуляции. Если opt не задан, по умолчанию: opt = pi/(max(max(x))), поэтому максимальное отклонение фазы будет π рад.

  • "pwm": широтно-импульсная модуляция. Создает ШИМ-сигнал на основе длин импульсов в x. Элементы x должны быть в диапазоне [0, 1] и задают длительность каждого импульса в долях периода. Импульсы начинаются в начале каждого периода несущей (выровнены по левому краю). При вызове modulate(x, fc, fs, "pwm", "centered") импульсы центрируются в начале каждого периода. Длина (y, t) равна length(x)*fs/fc.

  • "ppm": позиционно-импульсная модуляция. Создает сигнал с ПИМ из позиций импульсов в x. Элементы x должны быть в диапазоне [0, 1] и задают левый край каждого импульса в долях периода. opt — скаляр от 0 до 1, задающий длину каждого импульса в долях периода (по умолчанию 0.1). Длина (y, t) равна length(x)*fs/fc.

  • "qam": квадратурная амплитудная модуляция. Создает сигнал из x и opt.

    y = x .* cos(2*pi*fc*t) + opt .* sin(2*pi*fc*t)

    Входной аргумент opt должен быть той же размерности, что и x.

  • opt: дополнительные параметры для некоторых методов. Подробнее в method.

Типы данных: Float32, Float64, Char, String. Поддержка комплексных чисел: да.

# Output arguments

  • y: модулированный полезный сигнал (вещественный вектор или матрица). Сигнал y имеет ту же размерность, что и x, за исключением методов method: "pwm" и "ppm".

  • t: внутренний вектор времени.

EngeeDSP.demod(y, fc, fs, method)
EngeeDSP.demod(y, fc, fs, method, opt)

Демодуляция для моделирования систем связи.

Function call

  • x = demod(y, fc, fs, method, opt) — demodulates a real useful signal y using a carrier frequency fc, sampling rates fs and the method method with additional parameters specified in opt.

  • x = demod(y, fc, fs, method) — demodulates a real useful signal y using a carrier frequency fc, sampling rates fs and the method method.

Arguments

# Input arguments

  • y::AbstractVector{<:Real} | AbstractMatrix{<:Real} modulated signal (real vector or matrix). The signal y has the same dimension as x, except for the methods method: "pwm" and "pmm".

  • fc::Real carrier frequency (real positive scalar).

  • fs::Real: sampling rate (real positive scalar).

  • method::String: the modulation method. Possible values: "am" (by default), "amdsb-sc", "amdsb-tc", "amssb", "fm", "pm", "pwm", "pmm", "qam".

    • "am" or "amdsb-sc" Amplitude demodulation (two side bands, suppressed carrier). Multiplies y per cosine with frequency fc and applies the Butterworth low-pass filter of the 5th order using filtfilt.

      julia x = y .* cos(2*pi*fc*t) b, a = butter(5, fc*2/fs) x = filtfilt(b, a, x)

    • "amdsb-tc" Amplitude demodulation (two side bands, transmitted carrier). Multiplies y per cosine with frequency fc and applies the Butterworth low-pass filter of the 5th order using filtfilt. If specified opt, then after filtering it subtracts the scalar opt from x (by default opt = 0).

    x = y .* cos(2__pi__fc*t)
    
    b, a = butter(5, fc*2/fs) x = filtfilt(b, a,x)
    
    *if there is an opt: x = x .- opt*
    • "amssb" Amplitude demodulation (SSB). Multiplies y per cosine with frequency fc and applies the Butterworth low-pass filter of the 5th order using filtfilt. x = y .* cos(2*pi*fc*t) b, a = butter(5, fc*2/fs) x = filtfilt(b, a, x)

* `"fm"`: frequency demodulation. Demodulates the FM signal by modulating the Hilbert transform `y` the complex exponent of the frequency `-fc` Hz and gets an instantaneous frequency as a result.
* `"pm"` phase demodulation. Demodulates the FM signal by modulating the Hilbert transform `y` the complex exponent of the frequency `-fc` Hz and gets an instantaneous phase as a result.
* `"pwm"` pulse width demodulation. Determines the pulse width of the PWM signal `y` and returns the vector `x`, the elements of which set the duration of each pulse in fractions of a period. Pulses in `y` They must start from the beginning of each carrier period (aligned to the left). When modulating `modulate(x, fc, fs, "pwm", "centered")` the pulses are centered at the beginning of each period. Length `y` equal to `length(x)*fs/fc`.
* `"pmm"`: positional pulse demodulation. Determines the positions of the pulses in the signal `y`. For proper demodulation, the pulses should not overlap. Length `x` equal to `length(t)*fc/fs`.
* `"qam"` Quadrature amplitude demodulation. Challenge `demod(y, fc, fs, "qam")` returns two signals `(x1, x2)`: multiplies `y` for cosine and sine with frequency `fc` and applies the Butterworth low-pass filter of the 5th order, using `filtfilt`.
   x1 = y .* cos(2*pi*fc*t)
   x2 = y .* sin(2*pi*fc*t)
   b, a = butter(5, fc*2/fs)
   x1 = filtfilt(b, a, x1)
   x2 = filtfilt(b, a, x2)
  • opt: additional parameters for some methods. Learn more in method. Data types: Float32, Float64, Char, String. Support for complex numbers: yes.

    = # Output arguments

  • x demodulated useful signal (real vector or matrix). For the method "qam" two signals are returned: (x1, x2).

julia EngeeDSP.square(t) EngeeDSP.square(t, duty)

A rectangular signal.

# Function call - x = square(t) — generates a rectangular signal with a period for time array elements t. Function square it is similar to a sine, but it creates a rectangular signal with values -1 and 1. - x = square(t, duty) — generates a rectangular signal with a specified fill factor duty. Fill factor is the percentage of the signal period during which the rectangular signal is positive.

# Arguments # # Input arguments - t::AbstractArray{<:Real} time array (vector, matrix, or N-dimensional array). Function square works with the first dimension of the array t, the size of which is larger 1. Data types: Float32, Float64. - duty::Real: fill factor (default 50). The real scalar of 0 before 100. Data types: Float32, Float64. # # Output arguments - x: a rectangular signal returned as a vector, matrix, or N-dimensional array.

julia engee.genie.start(app__path::String; devel::Bool=false, log__file::String="", open_url::Bool=false)

Launches the Genie application using the specified path.

After running, the function returns GenieApplicationStatus, in which the link to the application is available (also displayed in the console as …​ at 'https://…​/genie/<appname>/'). The link can be opened in a new tab/window or copied to open manually.

Before usage of the command engee.genie.start make sure that if the application is a directory, it contains a file with the application code and extension.jl. Also delete the config and *.toml files (if present).

# Arguments - app_path::String: path to the application directory. It can be relative or absolute. - devel::Bool=false: A parameter for enabling development mode, in which changes to the code are applied without restarting the application. - log_file::String="": parameter for specifying the path to the log file. If not specified, the logs are not saved separately. - open_url::Bool=false: if true, then Engee will automatically open the application URL in the browser (the link is also available in the returned status).

# Examples

julia-repl

*Launching Genie via the app.jl application file, without development mode and saving logs*

engee.genie.start("/user/app.jl")

*Launching Genie via the app file.jl, with development mode and log saving*

engee.genie.start("/user/app.jl", devel=true, log_file="/user/logs.txt")

*Launching and automatically opening the application in the browser*

engee.genie.start("RadarCalculate", open_url=true) ```
engee.genie.stop(app_path::String)

Stops the running Genie application.

Arguments

app_path::String: path to the application directory. It can be relative or absolute.

Examples

# Stopping the app on an absolute path
engee.genie.stop("/user/app.jl")

# Stopping the app by relative path
engee.genie.stop("app.jl")
engee.genie.list()

Displays a list of all running Genie applications.

Examples

engee.genie.list()
engee.genie.eval(code::AbstractString)

Executes the specified code in the Engee workspace outside the context of the running Genie application. It is used to run individual expressions, debug, or dynamically execute code without having to restart the application.

Arguments

code::AbstractString: a line of code for Julia, which will be executed in the workspace Engee.

Examples

engee.genie.eval("x = 5")
engee.genie.recv(wsVarName::AbstractString; context::Module=GenieAPI )

Returns the value of a variable from the specified context (module) in the Engee workspace during the execution of the Genie application.

By default, the variable is searched in the module GenieAPI, but if necessary, you can explicitly specify another module through the parameter context. So, if the variable is defined in another module, then the parameter is used context, indicating in which namespace to search for it.

Arguments

  • wsVarName::AbstractString: name of the variable whose value you want to get.

  • context::Module=GenieAPI: the module in which the variable is searched. It is specified explicitly if the variable does not belong to the module GenieAPI.

Examples

# Getting the value of variable x from the Main module
engee.genie.recv("x", Main)

# Getting the value of variable a from the module by default
engee.genie.recv("a")

# Getting the value of the value variable from the user module
engee.genie.recv("value"; context=MyModule)
engee.genie.send(wsVarName::AbstractString, value::Any)

Saves the value value to a variable wsVarName in the workspace Engee during the execution of the application on Genie.

If a variable with this name did not exist before, it will be created automatically. The function is convenient for transferring intermediate results or user data from the Genie application to the Engee session.

Arguments

  • wsVarName::AbstractString: name of the variable to which the value is assigned.

  • value::Any: the value to be stored in the variable. Can be of any type.

Examples

# Assigning the value 124 to variable x
engee.genie.send("x", 124)

# Saving a string in the message variable
engee.genie.send("message", "Hello")