% Class for controlling the auto manifold of ColdEdge stinger cryostat.
% The manifold is managed by an Arduino board that communicates with 
% computer via serial protocol. 

classdef MyCeCryo < MyScpiInstrument
    
    methods (Access = public)
        function this = MyCeCryo(interface, address, varargin)
            this@MyScpiInstrument(interface, address, varargin{:});
            
            % Buffer size of 64 kB should be way an overkill. The labview
            % program provided by ColdEdge use 256 Bytes.
            this.Device.InputBufferSize=2^16;
            this.Device.OutputBufferSize=2^16;
        end
        
        function switchAllOff(this)
            writePropertyHedged(this, ...
                'valve1',   false, ...
                'valve2',   false, ...
                'valve3',   false, ...
                'valve4',   false, ...
                'valve5',   false, ...
                'valve7',   false, ...
                'recirc',   false, ...
                'cryocooler',   false);
        end
    end
    
    methods (Access = protected)
        function createCommandList(this)
            
            % Valve states
            for i=1:7
                if i == 6
                    continue % No valve 6
                end
                
                tag = sprintf('valve%i',i);
                cmd = sprintf(':VALVE%i',i);
                addCommand(this, tag, cmd,...
                    'default',  false, ...
                    'fmt_spec', '%b', ...
                    'info',     'Valve open(true)/clsed(false)');
            end
            
            addCommand(this, 'recirc', ':REC',...
                'default',  false, ...
                'fmt_spec', '%b', ...
                'info',     'Recirculator on/off');
            
            addCommand(this, 'cryocooler', ':COOL',...
                'default',  false, ...
                'fmt_spec', '%b', ...
                'info',     'Cryocooler on/off');
            
            addCommand(this, 'press', ':PRES',...
                'default',  false, ...
                'fmt_spec', '%e', ...
                'access',   'r', ...
                'info',     'Supply pressure (PSI)');
        end
    end
end