function CstDiscretePort(fid,CPNum,CType,CImp,CVolt,CCurr,CPoint1,CPoint2,...
    CUsePickedPoints,CLocalCoordinates,CMonitor)
global mws;

% Vytvoreni Discrete portu
    fprintf(fid, '%% Vytvoreni Discrete portu\n');
    fprintf(fid, 'discreteport = mws.invoke(''DiscretePort'');\n');
    fprintf(fid, 'discreteport.invoke(''Reset'');\n');
    fprintf(fid, ['discreteport.invoke(''PortNumber'',',num2str(CPNum),');\n']);
    fprintf(fid, ['discreteport.invoke(''Type'',''',CType,''');\n']);
    fprintf(fid, ['discreteport.invoke(''Impedance'',',num2str(CImp),');\n']);
    fprintf(fid, ['discreteport.invoke(''Voltage'',',num2str(CVolt),');\n']);
    fprintf(fid, ['discreteport.invoke(''Current'',',num2str(CCurr),');\n']);
    fprintf(fid, ['discreteport.invoke(''Point1'',',num2str(CPoint1(1)),',',num2str(CPoint1(2)),',',num2str(CPoint1(3)),');\n']);
    fprintf(fid, ['discreteport.invoke(''Point2'',',num2str(CPoint2(1)),',',num2str(CPoint2(2)),',',num2str(CPoint2(3)),');\n']);
    fprintf(fid, ['discreteport.invoke(''UsePickedPoints'',''',CUsePickedPoints,''');\n']);
    fprintf(fid, ['discreteport.invoke(''LocalCoordinates'',''',CLocalCoordinates,''');\n']);
    fprintf(fid, ['discreteport.invoke(''Monitor'',''',CMonitor,''');\n']);
    fprintf(fid, 'discreteport.invoke(''Create'');\n\n');

% Prime vytvoreni noveho Discrete portu v CST
    discreteport = mws.invoke('DiscretePort');
    discreteport.invoke('Reset');
    discreteport.invoke('PortNumber',CPNum);
    discreteport.invoke('Type',CType);
    discreteport.invoke('Impedance',CImp);
    discreteport.invoke('Voltage',CVolt);
    discreteport.invoke('Current',CCurr);
    discreteport.invoke('Point1',CPoint1(1),CPoint1(2),CPoint1(3));
    discreteport.invoke('Point2',CPoint2(1),CPoint2(2),CPoint2(3));
    discreteport.invoke('UsePickedPoints',CUsePickedPoints);
    discreteport.invoke('LocalCoordinates',CLocalCoordinates);
    discreteport.invoke('Monitor',CMonitor);
    discreteport.invoke('Create');


end