function updateopcond(this)
%  Author(s): John Glass
%  Revised:
% Copyright 1986-2003 The MathWorks, Inc.
% $Revision: 1.1.6.3 $ $Date: 2004/08/01 00:11:42 $

%% STATES
%% Get the states
states = this.OpPoint.States;

%% Convert to Matlab data types
mStateIndecies = LocalConvertToMatlabInteger(this.StateIndecies);

%% Get the tabledata
Data = this.StateCondTableModelUDD.data;

%% Set the state values
for ct1 = 1:length(states)
    for ct2 = 1:states(ct1).Nx
        try
            variable = Data(mStateIndecies(ct1)+ct2,2);
            data = evalin('base', variable);
            if LocalCheckInvalidData(data)
                errortitle = sprintf('Error evaluating the operating point: %s',this.Label); 
                lasterr(sprintf('%s. The variable %s must be a real double of length 1',errortitle,variable));
                return
            else
                states(ct1).x(ct2) = data;
            end
        catch
            errortitle = sprintf('Error evaluating the operating point: %s',this.Label); 
            str = sprintf('%s. Invalid workspace variable - %s',errortitle, variable);
            lasterr(str);
            return
        end
    end
end

%% INPUTS
%% Get the inputs
inputs = this.OpPoint.Inputs;

%% Convert to Matlab data types
mInputIndecies = LocalConvertToMatlabInteger(this.InputIndecies);

%% Get the tabledata
Data = this.InputCondTableModelUDD.data;

%% Set the input values
for ct1 = 1:length(inputs)
    for ct2 = 1:inputs(ct1).PortWidth
        try
            variable = Data(mInputIndecies(ct1)+ct2,2);
            data = evalin('base', variable);
            if LocalCheckInvalidData(data)
                errortitle = sprintf('Error evaluating the operating point: %s',this.Label); 
                lasterr(sprintf('%s. The variable %s must be a real double of length 1',errortitle,variable));
                return
            else
                inputs(ct1).u(ct2) = data;
            end
        catch
            errortitle = sprintf('Error evaluating the operating point: %s',this.Label);
            str = sprintf('%s. Invalid workspace variable - %s',errortitle,Data(mInputIndecies(ct1)+ct2,2));
            lasterr(str);
            return
        end
    end
end

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Function to check for valid data
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function isinvalid = LocalCheckInvalidData(data)

isinvalid = ~(isa(data,'double') && ...
              length(data) == 1 && ...
              isreal(data) && ...
              ~isnan(data) && ...
              ~isinf(data));

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Function to convert the java integer array to a Matlab array
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function array = LocalConvertToMatlabInteger(javaarray)

array = zeros(length(javaarray),1);

for ct = 1:length(javaarray)
    array(ct) = intValue(javaarray(ct,1)) + 1;
end