classdef calcontroller < handle
    %TEMPCONTROLLER Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
        ui
        interface
    end
    
    methods
        function obj = calcontroller(int)
           obj.interface = int;
           obj.ui = [];
        end
        
        function show(obj)
            if isempty(obj.ui)
                obj.ui = calui();
                set(obj.ui, 'UserData', obj);
            else
                set(obj.ui, 'Visible', 'on');
            end
        end
        
        function delete(obj)
            delete(obj.ui);
        end
        
        function receive(~, ~, ~)
        end
        
        function setcalibration(obj, cal)
            if cal >= -9999 && cal <= 9999
                cd = commanddata();
                cd.Calibration = cal * 10^-6;
                obj.interface.sendcommand(command(cd, commandtype.calibrate, obj));
                obj.interface.sendmessage(['System calibrated to ' num2str(cal) ' RIU']);
            elseif temp < -9999
                obj.interface.sendmessage('Calibration set too low.');
            elseif temp > 9999
                obj.interface.sendmessage('Calibration set too high.');
            end
        end
    end
end

