
%   Copyright 2014 The MathWorks, Inc.

classdef (Sealed) PLCCGProcAlstom  < handle
    properties (Hidden, Access = private)
        fController
    end
    
    methods
        function obj = PLCCGProcAlstom(controller)
            obj.fController = controller;
        end
        
        function doIt(obj)
            for i = 1 : length(obj.fController.components)
                code = obj.fController.components(i).body;
                code = obj.fixTypeConversion(code);
                obj.fController.components(i).body = code;
            end
        end
                
        function controller = getController(obj)
            controller = obj.fController;
        end
        
        function code = fixTypeConversion(obj, code) %#ok<INUSL>
            type_list = '(BOOL|BYTE|WORD|DWORD|LWORD|USINT|UINT|UDINT|ULINT|SINT|INT|DINT|LINT|REAL|LREAL)';
            pattern = [type_list '_TO_' type_list '\('];
            code = regexprep(code, pattern, 'ANY_TO_$2(');
        end
    end
end

% LocalWords:  DWORD USINT UDINT ULINT LREAL LWORD
