diff --git a/matlab/AnalyseComputationalEnviroment.m b/matlab/AnalyseComputationalEnviroment.m index 0028bcbba..3453e1cc0 100644 --- a/matlab/AnalyseComputationalEnviroment.m +++ b/matlab/AnalyseComputationalEnviroment.m @@ -1,5 +1,12 @@ function [ErrorCode] = AnalyseComputationalEnviroment(DataInput) -% Input/Output description: + +% DESCRIPTION + +% This function is used to check the user computational request. +% If no error happen the function return 0. + + +% INPUT/OUTPUT description: % % DataInput is the strcture option_.parallel, with the follow fields: % @@ -37,10 +44,17 @@ function [ErrorCode] = AnalyseComputationalEnviroment(DataInput) % % Value 3: The remote computer is unreachable!!! % -% Value 4: The user name and/or password is/are incorrect on the -% remote computer! +% Value 4: The fields user name and/or password are/is empty! +% +% Value 5: Remote Drive and/or Remote Folder not exist! +% +% Value 6: It is impossible write/read file on remote computer. +% +% Value 7: The valu user and/or passwd are incorret or the user have +% no permission to execute a Matlab section. +% +% % -% Value 5: It is impossible write/read file on remote computer. % % Then at the point call of this function it is possible react in a best way, in accord % with the ErrorCode. @@ -95,13 +109,13 @@ if (DataInput.Local == 1) % We look for the information on local computer hardware. - si=[]; - de=[]; + si0=[]; + de0=[]; - [si de]=system(['psinfo \\']); + [si0 de0]=system(['psinfo \\']); RealNumCPU=-1; - RealNumCPU=GiveCPUnumber(de); + RealNumCPU=GiveCPUnumber(de0); % Trasforming the input data provided in a form [n1:n2] in a single numerical % value. @@ -125,15 +139,15 @@ end % In this case we need more sophisticated check. - + if (DataInput.Local == 0) - si=[]; - de=[]; + si1=[]; + de1=[]; - [si de]=system(['ping ', DataInput.PcName]); + [si1 de1]=system(['ping ', DataInput.PcName]); - if si==1 + if si1==1 % It is impossiblie to be connected to the % remote computer. @@ -141,56 +155,93 @@ if (DataInput.Local == 0) return; end - - % -> IL CODICE SEGUENTE E' DA CONTROLLARE E VERIFICARE! - % The Local Machine can be connetted with Remote Computer. + % Now we verify if user name and password are correct and if remote % drive and remote folder exist on the remote computer and it is % possible to exchange data with them. + + + if (isempty(DataInput.user)) || (isempty(DataInput.passwd)) + + % The fields user name and/or password are/is empty! + + ErrorCode=4; + return - si=[]; - de=[]; - - [si de]=system(['psinfo \\', DataInput.PcName, ' -u ',DataInput.user, ' -p ',DataInput.passwd ]); - - if si<0 - % It is possible to be connected to the remote computer but it is not usable because the user - % name and/or password is/are incorrect. - - ErrorCodeComputer=4; - return; - else - % Username and Password are correct! end - % Now we verify if it possible to exchange data with the remote - % computer: + + % Now we very if RemoteDrive and/or RemoteFolder exist on remote + % computer + StartPwd=pwd; - fid = fopen('Tracing.txt','w+'); - fclose (fid); + try + cd(['\\',DataInput.PcName,'\',DataInput.RemoteDrive,'$\',DataInput.RemoteFolder]); + catch + + cd ([StartPwd]); + disp 'Remote Drive and/or Remote Folder not exist!'; + + ErrorCode=5; + return + + end - % ATTENZIONE: verificare perche sembra funzionare anche se il RemoteFolder non - % esiste. + cd ([StartPwd]); - Status=movefile('Tracing.txt', ['\\',DataInput.PcName,'\',DataInput.RemoteDrive,'$\',DataInput.RemoteFolder]); + + % Now we verify if it possible to exchange data with the remote + % computer: + + + Status=copyfile('Tracing.m', ['\\',DataInput.PcName,'\',DataInput.RemoteDrive,'$\',DataInput.RemoteFolder]); if Status==1 % Remote Drive/Folder exist on Remote computer and % it is possible to exchange data with him. else - % Move file error! - ErrorCodeComputer=5; + ErrorCode=6; return; end + + % Now we verify if it is possible execute a matlab section on remote + % machine when the user is .user with password .passwd + + si2=[]; + de2=[]; + + [si2 de2]=system(['start /B /WAIT psexec \\',DataInput.PcName,' -e -u ',DataInput.user,' -p ',DataInput.passwd,' -W ',DataInput.RemoteDrive,':\',DataInput.RemoteFolder, ' -low matlab -nosplash -nodesktop -minimize -r Tracing']); + + NoError='error code 0'; + + StrError= findstr(NoError,de2); + + + if isempty (StrError) + + % Bad user and/or passwd! + ErrorCode=7; + return; + + else + + % No error it is possible execute a matlab section on remote + % machine when the user is .user with password .passwd + end + + % At this point we can to analyze the remote computer hardware. - RealNumCPU=-1; - RealNumCPU=GiveCPUnumber(de); + + + [si0 de0]=system(['psinfo \\']); + RealNumCPU=GiveCPUnumber(de0); + % Trasforming the input data provided in a form [n1:n2] in a single numerical % value.