Maxima Plugin
A SMath Plugin
Loading...
Searching...
No Matches
MaximaPlugin.MaximaSession Class Reference

Manage the maxima session, connect maxima, manage configuration file, define all of the directories relevant to the plugin More...

Classes

class  ThreadWorkClass
 Thread class to show progress bar when Maxima session is being initiated More...
 

Public Member Functions

 MaximaSession ()
 Session constructor
 
string GetMaximaStateRunning ()
 Value of maximaState if session is running More...
 
void SetRunState ()
 
string GetPathToMaximaAbs ()
 Path to maxima.bat relative to SMath dir. More...
 
string GetPathToMaximabat ()
 
string GetAssemblyFolder ()
 
string WorkingFolderPath ()
 
void StartSession ()
 Executed at first Maxima interaction of a given SMath session Called after MaximaSession() is initialized
 
void FoundNoPath ()
 Dialog if path not found. If the Settings window isn't open, offer to open it.
 
string SetNewPathToMaxima (string StartPath)
 Try to get the path to Maxima More...
 
string GetState ()
 Get the value of maximaState More...
 
bool IsAlive ()
 Test if Maxima is responsive More...
 
void CloseMaxima ()
 Close maxima session More...
 
string CleanupMaxima ()
 Implementation of MaximaControl("cleanup"). Maxima is reset without shutting down the session. More...
 
string RestartMaxima ()
 Implementation of MaximaControl("restart"). The Maxima session is closed, the logs are reset and a new session is established. More...
 
string SendInitCmd ()
 Submit configuration commands to a running Maxima session More...
 
string SendAndReceiveFromSocket (string sendString, string option="none")
 Sends a command to Maxima and gets the result if Maxima is running, otherwise the state description is returned More...
 
string ReceiveSingleCommandFromSocket ()
 Wrapper function More...
 
void SendSingleCommandToSocket (string data)
 Send and log More...
 
string GetLastLog ()
 Get the last log entry from maximaSocket More...
 
bool IsConfigFileFromCurrentPluginVersion ()
 Check if Config file was generated with the current plugin version More...
 
bool checkForXMLandMAXIMA ()
 Check and read config file. Check if the path to maxima exists and valid More...
 
void SaveConfig ()
 Specify the config items and write them to the config file
 
void ReadConfig ()
 Read the config data and report data to FullLog
 

Static Public Member Functions

static string SearchFile (string path, string name)
 File search function for AutoMaxima, function better goes to AutoMaxima.cs, because it is only used there. More...
 
static string GetRelativePath (string filespec, string folder)
 https://stackoverflow.com/questions/703281/getting-path-relative-to-the-current-working-directory More...
 
static bool DeleteFiles (List< string > filePaths)
 Helper function for migration from old style config files Returns true if just one file was found, more files were found, the user confirmed deletion and the files were deleted successfully More...
 
static bool IsAnAdministrator ()
 Check the privileges More...
 
static string FindMaximaPath (string path)
 Search for Maxima path in the given path More...
 
static List< string > GetDirectories (string path, string searchPattern="*", SearchOption searchOption=SearchOption.TopDirectoryOnly)
 Helper function for FindMaximaPath(). List all top level directories in the path More...
 

Public Attributes

MaximaSocket socket = null
 
string gnuPlotImageFolder = ""
 
string namedDrawImageFolder = ""
 
List< string > settings
 
List< string > commands
 
List< string > customCommands
 
List< ExpressionStoreexprSMathToMaxima
 
List< ExpressionStoreexprMaximaToSMath
 

Private Member Functions

List< Process > GetProcesses ()
 Gets the process objects of possible maxima processes. Possible process names are given in property ProcessNames. This was required, because different Maxima versions use different process names More...
 
void StartAndConnectMaxima (int option)
 Establish connection and initialize Maxima (show a progress bar) Detect the process handle for the Maxima process for later closing More...
 

Static Private Member Functions

static void RecursiveSearch (System.IO.DirectoryInfo root, string filename)
 The actual recursive search More...
 

Private Attributes

string assemblyFolder = ""
 
string workingFolder = ""
 
string ConfigFileName = ""
 
string XMLname = "maxima.xml"
 
string MAXIMAname = "maxima.bat"
 
string pathToMAXIMA = ""
 
string pathToMAXIMArel = ""
 
int majorV = 0
 
int minorV = 0
 
int buildV = 0
 
int revisionV = 0
 
Process maximaProcess = null
 
bool maximaConnected = false
 
List< Process > processesBeforeStart
 
List< Process > processesAfterStart
 
Process newMaximaProcess
 
string[] ProcessNames = { "maxima", "lisp", "sbcl" }
 
string maximaState = "\"Initializing error. Please check path to Maxima under Insert> Maxima> Settings.\""
 
string maximaStateClosed = "\"Maxima was closed.\""
 
string maximaStateRunning = "\"Maxima started successfully.\""
 
string maximaStateReInitialized = "\"Maxima was re-initialized\""
 
string maximaStateRestart = "\"Restart complete.\""
 
string maximaStateCleanup = "\"Cleanup complete.\""
 
int timeToWait = 100
 
bool firstCmd = false
 
int RequiredConfigFormatID = 13
 
int FoundConfigFormatID = 0
 

Static Private Attributes

static string pathToSearchFile = ""
 
static bool searchSucces = false
 

Detailed Description

Manage the maxima session, connect maxima, manage configuration file, define all of the directories relevant to the plugin

Member Function Documentation

◆ checkForXMLandMAXIMA()

bool MaximaPlugin.MaximaSession.checkForXMLandMAXIMA ( )

Check and read config file. Check if the path to maxima exists and valid

Returns
Returns true if the config file exists and the path to maxima from therein is valid.

◆ CleanupMaxima()

string MaximaPlugin.MaximaSession.CleanupMaxima ( )

Implementation of MaximaControl("cleanup"). Maxima is reset without shutting down the session.

Returns
Maxima state message

◆ CloseMaxima()

void MaximaPlugin.MaximaSession.CloseMaxima ( )

Close maxima session

Returns

◆ DeleteFiles()

static bool MaximaPlugin.MaximaSession.DeleteFiles ( List< string >  filePaths)
static

Helper function for migration from old style config files Returns true if just one file was found, more files were found, the user confirmed deletion and the files were deleted successfully

Parameters
filePathslist of file names
Returns
success flag

◆ FindMaximaPath()

static string MaximaPlugin.MaximaSession.FindMaximaPath ( string  path)
static

Search for Maxima path in the given path

Parameters
pathSearch path

<return>full path to maxima<

Returns
>

◆ GetDirectories()

static List< string > MaximaPlugin.MaximaSession.GetDirectories ( string  path,
string  searchPattern = "*",
SearchOption  searchOption = SearchOption.TopDirectoryOnly 
)
static

Helper function for FindMaximaPath(). List all top level directories in the path

Parameters
pathSearch path

///

Parameters
searchPatternSearch pattern

///

Parameters
searchOptionSearch option

<return>List directories in the path<

Returns
>

◆ GetLastLog()

string MaximaPlugin.MaximaSession.GetLastLog ( )

Get the last log entry from maximaSocket

Returns
Last log from socket

◆ GetMaximaStateRunning()

string MaximaPlugin.MaximaSession.GetMaximaStateRunning ( )

Value of maximaState if session is running

Returns

◆ GetPathToMaximaAbs()

string MaximaPlugin.MaximaSession.GetPathToMaximaAbs ( )

Path to maxima.bat relative to SMath dir.

Returns

◆ GetProcesses()

List< Process > MaximaPlugin.MaximaSession.GetProcesses ( )
private

Gets the process objects of possible maxima processes. Possible process names are given in property ProcessNames. This was required, because different Maxima versions use different process names

Returns
List of processes

◆ GetRelativePath()

static string MaximaPlugin.MaximaSession.GetRelativePath ( string  filespec,
string  folder 
)
static

◆ GetState()

string MaximaPlugin.MaximaSession.GetState ( )

Get the value of maximaState

Returns
value

◆ IsAlive()

bool MaximaPlugin.MaximaSession.IsAlive ( )

Test if Maxima is responsive

Returns
result of the check

◆ IsAnAdministrator()

static bool MaximaPlugin.MaximaSession.IsAnAdministrator ( )
static

Check the privileges

Returns
true if the user is an admin

◆ IsConfigFileFromCurrentPluginVersion()

bool MaximaPlugin.MaximaSession.IsConfigFileFromCurrentPluginVersion ( )

Check if Config file was generated with the current plugin version

Returns
Returns true if config file is up to date

◆ ReceiveSingleCommandFromSocket()

string MaximaPlugin.MaximaSession.ReceiveSingleCommandFromSocket ( )

Wrapper function

Returns

◆ RecursiveSearch()

static void MaximaPlugin.MaximaSession.RecursiveSearch ( System.IO.DirectoryInfo  root,
string  filename 
)
staticprivate

The actual recursive search

Parameters
rootDirinfo object
filenameFilename

◆ RestartMaxima()

string MaximaPlugin.MaximaSession.RestartMaxima ( )

Implementation of MaximaControl("restart"). The Maxima session is closed, the logs are reset and a new session is established.

Returns
Maxima state message

◆ SearchFile()

static string MaximaPlugin.MaximaSession.SearchFile ( string  path,
string  name 
)
static

File search function for AutoMaxima, function better goes to AutoMaxima.cs, because it is only used there.

Parameters
pathPath name
nameFile name
Returns
Full filename if file exists, null otherwise

◆ SendAndReceiveFromSocket()

string MaximaPlugin.MaximaSession.SendAndReceiveFromSocket ( string  sendString,
string  option = "none" 
)

Sends a command to Maxima and gets the result if Maxima is running, otherwise the state description is returned

Parameters
sendString
option
Returns
If maxima is connected, return response from Maxima. If maxima is not connected, return maxima state message

◆ SendInitCmd()

string MaximaPlugin.MaximaSession.SendInitCmd ( )

Submit configuration commands to a running Maxima session

Returns
Initializing message

◆ SendSingleCommandToSocket()

void MaximaPlugin.MaximaSession.SendSingleCommandToSocket ( string  data)

Send and log

Parameters
data

◆ SetNewPathToMaxima()

string MaximaPlugin.MaximaSession.SetNewPathToMaxima ( string  StartPath)

Try to get the path to Maxima

Parameters
StartPath
Returns
Relative path or error message

◆ StartAndConnectMaxima()

void MaximaPlugin.MaximaSession.StartAndConnectMaxima ( int  option)
private

Establish connection and initialize Maxima (show a progress bar) Detect the process handle for the Maxima process for later closing

Parameters
option
Returns

The documentation for this class was generated from the following file: