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" Amplitude modulation (two side bands, transmitted carrier). Subtracts a scalar opt from x and multiplies the result by the cosine with the frequency fc.

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

      If opt not specified, the default value is used min(min(x)) to (x - opt) It was non-negative and had a minimal value . 0.

    • "amssb": amplitude modulation (single sideband). Multiplies x per cosine with frequency fc and adds the Hilbert transform x multiplied by a sine with frequency fc.

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

      This method effectively eliminates the upper sideband.

    • "fm": frequency modulation. Creates a cosine with an instantaneous frequency that varies depending on x.

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

      cumsum(x) — rectangular approximation of the integral of x. opt It is used as a frequency modulation constant. If opt not specified, by default: opt = (fc/fs)*2*pi/(max(max(x))), therefore , the maximum frequency deviation from fc will be fc Hz.

    • "pm": phase modulation. Creates a cosine with a frequency fc, the phase of which varies depending on x.

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

      opt It is used as a phase modulation constant. If opt not specified, by default: opt = pi/(max(max(x))), therefore , the maximum phase deviation will be π glad.

    • "pwm" Pulse width modulation. Creates a PWM signal based on the pulse lengths in x. Elements x must be in the range of [0, 1] and set the duration of each pulse in fractions of a period. The pulses start at the beginning of each carrier period (aligned to the left). When calling modulate(x, fc, fs, "pwm", "centered") the pulses are centered at the beginning of each period. Length (y, t) equal to length(x)*fs/fc.

    • "ppm": pulse-position modulation. Creates a PIM signal from pulse positions in x. Elements x must be in the range of [0, 1] and set the left edge of each pulse in fractions of a period. opt — a scalar from 0 before 1, which sets the length of each pulse in fractions of a period (by default 0.1). Length (y, t) equal to length(x)*fs/fc.

    • "qam" Quadrature amplitude modulation. Creates a signal from x and opt.

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

      Input argument opt must be of the same dimension as x.

  • opt: additional parameters for some methods. Learn more in method. Data types: Float32, Float64, Char, String. Support for complex numbers: yes.

Output arguments

  • y modulated useful signal (real vector or matrix). The signal y has the same dimension as x, except for the methods method: "pwm" and "ppm".

  • t: the internal vector of time.

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

Demodulation for modeling communication systems.

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.

      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 available 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).

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.

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

# Launch Genie through the application file app.jl, without the development mode and saving logs
engee.genie.start("/user/app.jl")

# Launch Genie through the application file app.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 on 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 a variable x from the module Main
engee.genie.recv("x", Main)

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

# Getting the value of a variable value 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 a variable x The value is 124
engee.genie.send("x", 124)

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