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
#
engee.genie.start — Function
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 signalxusing a carrier frequencyfc, sampling ratesfsand the methodmethodwith additional parameters specified inopt, and returns the internal time vectort. -
(y, t) = modulate(x, fc, fs, method)— modulates a real useful signalxusing a carrier frequencyfc, sampling ratesfsand the methodmethod. -
(y, t) = modulate(x, fc, fs)— modulates a real useful signalxusing a carrier frequencyfcand sampling ratesfs. IfxIf 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). Ifx— matrix, the modulation is performed independently for each column. -
fc::Realcarrier 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). Multipliesxper cosine with frequencyfc.y = x .* cos(2*pi*fc*t) -
"amdsb-tc"Amplitude modulation (two side bands, transmitted carrier). Subtracts a scalaroptfromxand multiplies the result by the cosine with the frequencyfc.y = (x - opt) .* cos(2*pi*fc*t)If
optnot specified, the default value is usedmin(min(x))to(x - opt)It was non-negative and had a minimal value .0. -
"amssb": amplitude modulation (single sideband). Multipliesxper cosine with frequencyfcand adds the Hilbert transformxmultiplied by a sine with frequencyfc.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 onx.y = cos(2*pi*fc*t + opt*cumsum(x))cumsum(x)— rectangular approximation of the integral ofx.optIt is used as a frequency modulation constant. Ifoptnot specified, by default:opt = (fc/fs)*2*pi/(max(max(x))), therefore , the maximum frequency deviation fromfcwill befcHz. -
"pm": phase modulation. Creates a cosine with a frequencyfc, the phase of which varies depending onx.y = cos(2*pi*fc*t + opt*x)optIt is used as a phase modulation constant. Ifoptnot 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 inx. Elementsxmust 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 callingmodulate(x, fc, fs, "pwm", "centered")the pulses are centered at the beginning of each period. Length(y, t)equal tolength(x)*fs/fc. -
"ppm": pulse-position modulation. Creates a PIM signal from pulse positions inx. Elementsxmust be in the range of[0, 1]and set the left edge of each pulse in fractions of a period.opt— a scalar from0before1, which sets the length of each pulse in fractions of a period (by default0.1). Length(y, t)equal tolength(x)*fs/fc. -
"qam"Quadrature amplitude modulation. Creates a signal fromxandopt.y = x .* cos(2*pi*fc*t) + opt .* sin(2*pi*fc*t)Input argument
optmust be of the same dimension asx.
-
-
opt: additional parameters for some methods. Learn more inmethod. Data types:Float32,Float64,Char,String. Support for complex numbers: yes.
Output arguments
-
ymodulated useful signal (real vector or matrix). The signalyhas the same dimension asx, except for the methodsmethod:"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 signalyusing a carrier frequencyfc, sampling ratesfsand the methodmethodwith additional parameters specified inopt. -
x = demod(y, fc, fs, method)— demodulates a real useful signalyusing a carrier frequencyfc, sampling ratesfsand the methodmethod.
Arguments
Input arguments
-
y::AbstractVector{<:Real} | AbstractMatrix{<:Real}modulated signal (real vector or matrix). The signalyhas the same dimension asx, except for the methodsmethod:"pwm"and"pmm". -
fc::Realcarrier 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). Multipliesyper cosine with frequencyfcand applies the Butterworth low-pass filter of the 5th order usingfiltfilt.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). Multipliesyper cosine with frequencyfcand applies the Butterworth low-pass filter of the 5th order usingfiltfilt. If specifiedopt, then after filtering it subtracts the scalaroptfromx(by defaultopt = 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). Multipliesyper cosine with frequencyfcand applies the Butterworth low-pass filter of the 5th order usingfiltfilt.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 transformythe complex exponent of the frequency-fcHz and gets an instantaneous frequency as a result. -
"pm"phase demodulation. Demodulates the FM signal by modulating the Hilbert transformythe complex exponent of the frequency-fcHz and gets an instantaneous phase as a result. -
"pwm"pulse width demodulation. Determines the pulse width of the PWM signalyand returns the vectorx, the elements of which set the duration of each pulse in fractions of a period. Pulses inyThey must start from the beginning of each carrier period (aligned to the left). When modulatingmodulate(x, fc, fs, "pwm", "centered")the pulses are centered at the beginning of each period. Lengthyequal tolength(x)*fs/fc. -
"pmm": positional pulse demodulation. Determines the positions of the pulses in the signaly. For proper demodulation, the pulses should not overlap. Lengthxequal tolength(t)*fc/fs. -
"qam"Quadrature amplitude demodulation. Challengedemod(y, fc, fs, "qam")returns two signals(x1, x2): multipliesyfor cosine and sine with frequencyfcand applies the Butterworth low-pass filter of the 5th order, usingfiltfilt.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 inmethod. Data types:Float32,Float64,Char,String. Support for complex numbers: yes.
Output arguments
-
xdemodulated 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 period2πfor time array elementst. Functionsquareit is similar to a sine, but it creates a rectangular signal with values-1and1. -
x = square(t, duty)— generates a rectangular signal with a specified fill factorduty. 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). Functionsquareworks with the first dimension of the arrayt, the size of which is larger1. Data types:Float32,Float64. -
duty::Real: fill factor (default50). The real scalar of0before100. 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: iftrue, 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 — Function
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 — Function
engee.genie.list()
Displays a list of all running Genie applications.
Examples
engee.genie.list()
#
engee.genie.eval — Function
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 — Function
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 moduleGenieAPI.
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 — Function
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")