New in SG-Lib 3.5

exp_2017_03_07- creates a solid based on moved cvl
exp_2017_03_07 % exp_2017_03_07 - creates a solid based on moved cvl
% (by Tim Lueth & Florian Schleich, VLFL-Lib, 2017-MÄR-07 as class:
% EXPERIMENTS)
%
% exp_2017_03_07
%
copyplot- copies the content of one figure into a random one
copyplot % copyplot - copies the content of one figure into a random one
% (by Tim Lueth, VLFL-Lib, 2017-MÄR-05 as class: USER INTERFACE)
%
% This fnctns helps to save figure content of figures that will be closed
% into another one (Status of: 2017-03-05)
%
% See also: snapplot, PRplot
%
% copyplot
%
RRkeyboardstring(inpstr)- processes a char array similar to an input scan process
RRkeyboardstring(inpstr) % RRrun.RRkeyboardstring(inpstr) - processes a char array similar to an input scan process
% (by Tim Lueth, RoundRobin, 2017-MÄR-03)
%
% This fnctns is required if keyboard sequences should be send to
% Matlab's eval command
% Some characters such as backspace (08) eliminate the preceding
% character. (Status of: 2017-03-07)
%
% outstr=RRkeyboardstring(inpstr)
% === INPUT PARAMETERS ===
% inpstr: input string including all control characters
% === OUTPUT RESULTS ======
% outstr: some control characters are processed
%
RRrun (RRtasklist.t0,RRmaxtime)- starts Round-Robin Task-List Realtime Environment in stopped state
RRrun (RRtasklist.t0,RRmaxtime) % RRrun (RRtasklist.t0,RRmaxtime) - starts Round-Robin Task-List Realtime Environment in stopped state
% (by Tim Lueth, RoundRobin, 2017-MÄR-02)
%
% Matlab is used to execute the task strings as command line and task
% handles as fnctn call.
% The user has the feeling to use the Matlab command interface but in
% fact in parallel a set of fnctns runs as round robin task list.
% Some commands are helpful to understand the environemnt:
% whos - shows all variable used in this environment
% RRprompt - Prompt string 'RRrun'
% RRtasklist.t0 = cycle time
%
% Some command line commands are new or treated in a different way:
% QUIT, EXIT - stops the shell; it can be restarted by RRrun,
% persistent/global
% LIST, SHOW shows the task list
% ADD - appends a task at the end of the task list
% STEP - executes the task list exactly one time
% CONT, GO, START - starts the task execution
% STOP, BREAK - stops the task execution
% SAVE - saves the task in a file in the current directory
% LOAD - load the task list from a file in the current directory
%
% KILLALL - deletes all tasks in the task list
% KILL # - delete the task with the 3rd column has the unique nr #
%
% EXE, EXECUTE - reads in command text file and executes all commands,
% requires START
%
% Have in mind that inter task communication is only possible by
% variables declared as global!
% (Status of: 2017-03-04)
%
% See also: RRshell
%
% RRrun([RRtasklist.t0,RRmaxtime])
% === INPUT PARAMETERS ===
% RRtasklist.t0: Clock cycle time; default is 0.1
% RRmaxtime: maximum duration time; default is 600 seconds
%
% EXAMPLE: start some tasks and see the result
% BREAK
% KILLALL
% global PL; PL=[0 0 0];
% ADD global PL; PL=[PL; PL(end,:)+rand(1,3)];
% ADD global PL; VLplot(PL,'b.-',2); view(-30,30); grid on;
% LIST
% STEP
% START
%
%
%
RRLappendTask(RRL,command,rep)- appends a command at the end of the task list
RRLappendTask(RRL,command,rep) % RRrun.RRLappendTask(RRL,command,rep) - appends a command at the end of the task list
% (by Tim Lueth, RoundRobin, 2017-MÄR-02)
%
% See also: RRshell, RRkeyboardCallback, RRcreateTasklist, RRhelp
%
% RRL=RRLappendTask(RRL,command,[rep])
% === INPUT PARAMETERS ===
% RRL: Round-Robin Task List
% command: command to execute
% rep: number of repeats; default is inf
% === OUTPUT RESULTS ======
% RRL: Extended RRL
%
RRhelp- returns the help text for the Round-Robin realtime-environment
RRhelp % RRhelp - returns the help text for the Round-Robin realtime-environment
% (by Tim Lueth, RoundRobin, 2017-MÄR-02)
%
% The Round-Robin realtime-environment should help to understand how
% simple realtime systems can be implemented in Matlab or on
% Mikrocontroller without realtime operating systems. Round-Robin is a
% sub-optimal realtime solution but should be understood before using
% something such QNX or Kithara. It consists of two concepts:
% a) A list of tasks (i.e. fnctn calls) that are executed sequentially
% every nn milliseconds
% b) A user shell that allow to modify dynamically this task list during
% execution
%
% THE SHELL
% - RRshell opens a figure, installs a new keyboard fnctn, collects data
% and executes commands using the Matlab fnctn EVAL. RRshell stops after
% a predefined period of time. The user has the feeling still to use the
% Matlab command line. Only the different prompt shows the difference.
% - RRkeyboardCallback is the keyboard callback fnctn installed by
% RRshell to collect keyboard data similar to the Matlab command line.
% The entered character lines are interpreted and executed by RRshell.
% The fnctn is visible since maybe also other tasks should have access to
% the keyboard chars. (Status of: 2017-03-05)
%
% See also: RRshell, RRkeyboardCallback, RRcreateTasklist
%
% RRhelp
%
RRkeyboardCallback- this callback function collects keyboard character and stores it into two global variables
RRkeyboardCallback % RRrun.RRkeyboardCallback - this callback fnctn collects keyboard character and stores it into two global variables
% (by Tim Lueth, USELESS, 2017-MÄR-02)
%
% This callback fnctn is called by RRshell after opening a figure as
% entry window. It uses several global variables for exchange with
% RRshell:
% global RRwindow - handle to the RRShell figure
% global RRkeyboardLine - command line to execute after CR
% global RRkeyboardCurs - string to collect character before execution
% (Status of: 2017-03-03)
%
% See also: RRshell, RRcreateTasklist, RRhelp
%
% RRkeyboardCallback
%
RRshell (PROMPT,MAXTIME)- Runs an interpreter shell for a limited period of time to simulate a realtime system
RRshell (PROMPT,MAXTIME) % RRrun.RRshell (PROMPT,MAXTIME) - Runs an interpreter shell for a limited period of time to simulate a realtime system
% (by Tim Lueth, RoundRobin, 2017-MÄR-02)
%
% RRshell opens a figure and installs a new keyboard callback fnctn
% "RRkeyboardCallback". The "RRkeyboardCallback" fnctn writes pressed
% keyboard character into global variables "RRkeyboardLine" and
% "RRkeyboardCurs". As soon as CR is pressed, "RRkeyboardLine" contains
% the char chain. RRshell now analyzes some master keyowrds such as
% "STOP", EXIT', QUIT" and "END". In all other cases the "eval" fnctn of
% Matlab is used to execute the string as command line.
% The user has the feeling to control Matlab directly but in fact in
% parallel a set of fnctns runs as round robin task list (Status of:
% 2017-03-05)
%
% See also: RRkeyboardCallback, RRhelp, RRcreateTasklist
%
% RRshell([PROMPT,MAXTIME])
% === INPUT PARAMETERS ===
% PROMPT: Desired entry prompt; default is "RRshell"
% MAXTIME: Maximum time before exit the shell; default is 60 seconds
%
RRcreateTasklist(t0,funclist,twarn,tstop)- creates a Round Robin task list
RRcreateTasklist(t0,funclist,twarn,tstop) % RRrun.RRcreateTasklist(t0,funclist,twarn,tstop) - creates a Round Robin task list
% (by Tim Lueth, RoundRobin, 2017-MÄR-02)
%
% Matlab is an extreme powerful programming environment that allows to
% create even simple round robin realtime systems for every body. It
% makes sense to understand the principles of a round robin system before
% using matlab threads on a not-realtime-operationg system and before
% switching to realtime-OS such as QNX or Kithara.
% This "Round Robin task list" class works with real fnctns handles and
% persistent and global variables as well as with simple matlab command
% line commands. (Status of: 2017-03-05)
%
% See also: RRshell, RRkeyboardCallback, RRhelp
%
% RRL=RRcreateTasklist([t0,funclist,twarn,tstop])
% === INPUT PARAMETERS ===
% t0: Clock cycle time
% funclist: cell list of fnctn handles
% twarn: optional warning time; default is INF
% tstop: optional stop time; default is INF
% === OUTPUT RESULTS ======
% RRL: Round Robin List struct
%
% EXAMPLE:
% RRcreateTasklist(1,{' PL=[0 0 0]; PLplot(PL); show;';...
% 'PL=[PL;PL(end,:)+rand(1,2)'})
%
RRexecuteTasklist- executes all tasks in the global RRtasklist one time
RRexecuteTasklist % RRrun.RRexecuteTasklist - executes all tasks in the global RRtasklist one time
% (by Tim Lueth, RoundRobin, 2017-MÄR-02)
%
% Private fnctn in RRrun
% The fnctn executes all tasks in the global RRtasklist one time if the
% use counter is larger than 1. Afterwards the use counter is decreased
% by 1. All tasks with use counter ==0 are deleted (Status of: 2017-03-07)
%
% RRexecuteTasklist
%
helptextofcaller- returns the helptext of the calling function
helptextofcaller % helptextofcaller - returns the helptext of the calling fnctn
% (by Tim Lueth, VLFL-Lib, 2017-MÄR-01 as class: AUXILIARY PROCEDURES)
%
% This fnctn is usefull to create fnctn such as FMhelp that just return
% their own helptext.
% Does work only as part of a fnctn. (Status of: 2017-03-01)
%
% See also: titleofcaller
%
% htext=helptextofcaller
% === OUTPUT RESULTS ======
% htext: help text
%
% EXAMPLE: FMhelp
%
FMclose(conn)- closes a connection
FMclose(conn) % FMclose(conn) - closes a connection
% (by Tim Lueth, FileMaker, 2017-MÄR-01)
%
% same as close(conn)
% (Status of: 2017-03-01)
%
% See also: FMhelp, FMinitJDBC, FMopen, FMgetFieldTabs, FMsqlQuery
%
% LITERATURE:
% Filemaker (2013): "SQL-Referenzhandbuch FM 13",
% https://fmhelp.filemaker.com/docs/13/de/fm13_sql_reference.pdf
%
% FMclose(conn)
% === INPUT PARAMETERS ===
% conn: Connection to FileMaker Database
%
FMgetFieldTabs (conn)- returns structure of the FielMaker database
FMgetFieldTabs (conn) % FMgetFieldTabs (conn) - returns structure of the FielMaker database
% (by Tim Lueth, FileMaker, 2017-FEB-28)
%
% FMsqlQuery(conn,'SELECT TableName FROM FileMaker_Tables')
% FMsqlQuery(conn,'SELECT * FROM FileMaker_Tables')
% FMsqlQuery(conn,'SELECT * FROM FileMaker_Fields')
% (Status of: 2017-02-28)
%
% See also: FMhelp, FMinitJDBC, FMopen, FMsqlQuery
%
% LITERATURE:
% Filemaker (2013): "SQL-Referenzhandbuch FM 13",
% https://fmhelp.filemaker.com/docs/13/de/fm13_sql_reference.pdf
%
% FMgetFieldTabs(conn)
% === INPUT PARAMETERS ===
% conn: Connector to Database
%
FMsqlQuery(conn,sqlreq)- returns the answer to a SQL request to a FileMaker database
FMsqlQuery(conn,sqlreq) % FMsqlQuery(conn,sqlreq) - returns the answer to a SQL request to a FileMaker database
% (by Tim Lueth, FileMaker, 2017-FEB-28)
%
% See also: FMhelp, FMinitJDBC, FMopen, FMgetFieldTabs
%
% LITERATURE:
% Filemaker (2013): "SQL-Referenzhandbuch FM 13",
% https://fmhelp.filemaker.com/docs/13/de/fm13_sql_reference.pdf
%
% ans=FMsqlQuery(conn,sqlreq)
% === INPUT PARAMETERS ===
% conn: Connector to a FileMaker database
% sqlreq: sql request
% === OUTPUT RESULTS ======
% ans: answer
%
% EXAMPLE: Different helpful requests:
% FMsqlQuery(conn,'SELECT TableName FROM FileMaker_Tables')
% FMsqlQuery(conn,'SELECT * FROM FileMaker_Tables')
% FMsqlQuery(conn,'SELECT * FROM FileMaker_Fields)
%
FMgetData(conn,fieldname,tabname)- returns all field values from a table of an open FileMaker database
FMgetData(conn,fieldname,tabname) % FMgetData(conn,fieldname,tabname) - returns all field values from a table of an open FileMaker database
% (by Tim Lueth, FileMaker, 2017-FEB-28)
%
% Uses the JDBC Driver Solution to access FileMaker from Matlab
%
% The Filemaker SQL Interface is documented in: (Status of: 2017-02-28)
%
% LITERATURE:
% Filemaker (2013): "SQL-Referenzhandbuch FM 13",
% https://fmhelp.filemaker.com/docs/13/de/fm13_sql_reference.pdf
%
% ans=FMgetData(conn,fieldname,tabname)
% === INPUT PARAMETERS ===
% conn: Connector to Database
% fieldname: Field Name
% tabname: Table Name
% === OUTPUT RESULTS ======
% ans:
%
FMinitJDBC(cname)- checks the existance of the FileMaker JDBC driver and copies it into the javaclasspath
FMinitJDBC(cname) % FMinitJDBC(cname) - checks the existance of the FileMaker JDBC driver and copies it into the javaclasspath
% (by Tim Lueth, FileMaker, 2017-FEB-28)
%
% This fnctn installs the FileMaker JDBC driver ("fmjdbc.jar") and must
% be called before accessing the database the first time. It is not
% automatically called by FMopen. It can be called several times without
% any problem. The driver file name has the same name for PC and Mac.
% Nevertheless the content differs with FileMaker version and platform.
% (Status of: 2017-03-01)
%
% See also: FMhelp, FMopen, FMgetFieldTabs, FMsqlQuery
%
% LITERATURE:
% Filemaker (2013): "SQL-Referenzhandbuch FM 13",
% https://fmhelp.filemaker.com/docs/13/de/fm13_sql_reference.pdf
%
% FMinitJDBC([cname])
% === INPUT PARAMETERS ===
% cname: full path and filename to "fmjdbc.jar". default is searching in
% searchpath
%
% EXAMPLE:
% FMinitJDBC('fmjdbc.jar')
%
%
FMopen(fname,user,passw)- opens a FileMaker Database by the FileMaker Application
FMopen(fname,user,passw) % FMopen(fname,user,passw) - opens a FileMaker Database by the FileMaker Application
% (by Tim Lueth, FileMaker, 2017-FEB-28)
%
% Tries to find the database in the working director or globally and in
% the desktopdir. Default extension is ".fmp12" (Status of: 2017-03-01)
%
% See also: FMhelp, FMinitJDBC, FMgetFieldTabs, FMsqlQuery
%
% conn=FMopen(fname,[user,passw])
% === INPUT PARAMETERS ===
% fname: filename
% user: user name default is Admin
% passw: password; default is ''
% === OUTPUT RESULTS ======
% conn: connector.
%
% EXAMPLE: Open a database using the system and try to connect using JBDC
% Driver
% conn=FMopen('FileMakerTestBase.fmp12','user','passw')
%
FMhelp- returns a help text for the FileMaker-Matlab interface
FMhelp % FMhelp - returns a help text for the FileMaker-Matlab interface
% (by Tim Lueth, FileMaker, 2017-FEB-28)
%
% Tobias Lüddemann did start the connection of FileMaker and Matlab using
% 2012b and FileMaker Pro 11. There is a document dated 2014-11-27 at TUM
% MIMED.
% Tim Lueth capsulated the JDBC FileMaker interface using Matlab 2016b
% and FileMaker 13 starting February 2017. The solution described here
% works with Filemaker 13 and later.
%
% The Matlab Database Toolbox is required. You need a license for that.
% The xDBC Drivers for Filemaker can be downloaded from the Filemaker
% WWW-Site for your Filemaker Version
% The JDBC Driver "fmjdbc.jar" is part of this package.
% This driver file has to be added to the javaclasspath (which is done by
% the fnctn FMinitJDBC)
%
% For connecting to the Filemaker App you have to:
% SWITCH ON FILESHARING for ALL Users (Filemaker & Database)
% SWITCH ON ODBC-JDBC-Sharing: for ALL Users (Filemaker & Database)
%
% Lueth's fnctns to support the connection to Filemaker are:
% FMhelp - This fnctn
% FMinitJDBC - Opens the Driver "fmjdbc.jar"
% FMopen - to open a database with user name and password
% FMgetFieldTabs - to get informations on the Database
% FMsqlQuery - to send requests or data to the Databse
% ...there are some fnctns all starting with capital letters "FM"
%
% (Status of: 2017-03-01)
%
% See also: FMhelp, FMinitJDBC, FMopen, FMgetFieldTabs, FMsqlQuery
%
% LITERATURE:
% Filemaker (2013): "SQL-Referenzhandbuch FM 13",
% https://fmhelp.filemaker.com/docs/13/de/fm13_sql_reference.pdf
%
% FMhelp
%
% EXAMPLE: How to use the library after copying "fmjdbc.jar" in a search
% path directory:
% FMinitJDBC('fmjdbc.jar')
% conn=FMopen('Basename.fmp12','user','passw')
% FMgetFieldTabs(conn)
% FMsqlQuery(conn,'SELECT * FROM FileMaker_Tables')
%
CPLoutercontour(CPL,out)- returns for a CPL the outer contour wrt cw/ccw-orientation
CPLoutercontour(CPL,out) % CPLoutercontour(CPL,out) - returns for a CPL the outer contour wrt cw/ccw-orientation
% (by Tim Lueth, VLFL-Lib, 2017-FEB-28 as class: CLOSED POLYGON LISTS)
%
% Uses PLoutercontour but returns only the outer CPL. The outer/inner
% contoru decision is made by selecting the cw/ccw-orientation of each
% contour. (Status of: 2017-04-15)
%
% See also: PLoutercontour, CPLgrow
%
% NCPL=CPLoutercontour([CPL,out])
% === INPUT PARAMETERS ===
% CPL: Closed Polygon Line; separated using NaN NaN
% out: returns the FIRST outer contour if true; if false the first inner;
% default is true
% === OUTPUT RESULTS ======
% NCPL: New CPL
%
% EXAMPLE:
% PLoutercontour(CPLgrow(CPLsample(19),4))
% CPLoutercontour(CPLgrow(CPLsample(13),2))
%
titleofcaller(n)- returns the name of the calling function plus date & time as string
titleofcaller(n) % titleofcaller(n) - returns the name of the calling fnctn plus date & time as string
% (by Tim Lueth, VLFL-Lib, 2017-FEB-28 as class: USER INTERFACE)
%
% This fnctn help to create titles for figures and axes (Status of:
% 2017-03-19)
%
% See also: SGfigure, SGtitle, title, figure, helptextofcaller
%
% t=titleofcaller([n])
% === INPUT PARAMETERS ===
% n: hierarchy of calling fnctns; default is 0;
% === OUTPUT RESULTS ======
% t: string with caller and date and clock
%
% EXAMPLE: Use at the end of your own fnctns:
% if nargout==0
% SGfigure; view (0,90); title (titlefocaller);
% end
%