Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

166 строки
4.4KB

  1. classdef Channel
  2. %CHANNEL Summary of this class goes here
  3. % Detailed explanation goes here
  4. properties (Hidden, Access = private)
  5. scope
  6. channelnumber
  7. end
  8. properties (Dependent)
  9. state
  10. coupling
  11. bandwidth
  12. scale
  13. offset
  14. probe
  15. label
  16. type
  17. probeunit
  18. end
  19. methods
  20. function ch = Channel(scope,channelnumber)
  21. ch.channelnumber = channelnumber;
  22. ch.scope = scope;
  23. end
  24. function s = get.state(ch)
  25. s = ch.CHAN('state?');
  26. end
  27. function out = get.coupling(ch)
  28. out = ch.CHAN('coup?');
  29. end
  30. function out = get.bandwidth(ch)
  31. out = ch.CHAN('band?');
  32. end
  33. function out = get.offset(ch)
  34. out = ch.CHAN('offs?');
  35. end
  36. function out = get.scale(ch)
  37. out = ch.CHAN('scal?');
  38. end
  39. function out = get.label(ch)
  40. out = ch.CHAN('lab?');
  41. end
  42. function out = get.type(ch)
  43. out = ch.CHAN('type?');
  44. end
  45. function out = get.probeunit(ch)
  46. out = ch.scope.query(['PROB',num2str(ch.channelnumber),':SET:ATT:UNIT?']);
  47. end
  48. function out = get.probe(ch)
  49. out = ch.scope.query(['PROB',num2str(ch.channelnumber),':SET:ATT:MAN?']);
  50. end
  51. function ch = set.state(ch,in)
  52. ch.CHAN('state',in);
  53. end
  54. function ch = set.coupling(ch,in)
  55. ch.CHAN('coup',in);
  56. end
  57. function ch = set.bandwidth(ch,in)
  58. ch.CHAN('band',in);
  59. end
  60. function ch = set.offset(ch,in)
  61. ch.CHAN('offs',in);
  62. end
  63. function ch = set.scale(ch,in)
  64. ch.CHAN('scal',in);
  65. end
  66. function ch = set.label(ch,in)
  67. ch.CHAN('lab',in);
  68. end
  69. function ch = set.type(ch,in)
  70. ch.CHAN('type',in);
  71. end
  72. function out = frequency(ch)
  73. out = str2double(ch.MEAS('freq'));
  74. end
  75. function out = peak2peak(ch)
  76. out = str2double(ch.MEAS('peak'));
  77. end
  78. function out = period(ch)
  79. out = str2double(ch.MEAS('per'));
  80. end
  81. function out = amplitude(ch)
  82. out = str2double(ch.MEAS('ampl'));
  83. end
  84. function out = mean(ch)
  85. out = str2double(ch.MEAS('mean'));
  86. end
  87. function out = rms(ch)
  88. out = str2double(ch.MEAS('rms'));
  89. end
  90. function out = phase(ch)
  91. out = str2double(ch.MEAS('phas'));
  92. end
  93. function ch = set.probeunit(ch,unit)
  94. ch.scope.write(['PROB',num2str(ch.channelnumber),':SET:ATT:UNIT ', unit]);
  95. end
  96. function ch = set.probe(ch,man)
  97. ch.scope.write(['PROB',num2str(ch.channelnumber),':SET:ATT:MAN ', double2str(man)]);
  98. end
  99. function data = waveform(ch,window)
  100. ch.scope.single;
  101. if nargin < 2
  102. window = 'DEF';
  103. end
  104. ch.scope.setWaveformSettings(window,'REAL')
  105. data = ch.getWaveform;
  106. end
  107. function data = getWaveform(ch)
  108. header = str2num(ch.CHAN('DATA:HEAD?'));
  109. data.length = header(3);
  110. data.start = header(1);
  111. data.stop = header(2);
  112. data.sampletime = str2double(ch.CHAN('DATA:XINC?'));
  113. ch.scope.opc;
  114. ch.scope.write_unsafe(['CHAN',num2str(ch.channelnumber),':DATA?']);
  115. data.data = ch.scope.readWaveform(data.length);
  116. end
  117. end
  118. methods (Hidden, Access = private)
  119. function c = CHAN(ch,string,in)
  120. if nargin == 2
  121. if strcmp(string(end),'?')
  122. c = ch.scope.query(['CHAN',num2str(ch.channelnumber),':',string]);
  123. else
  124. ch.scope.write(['CHAN',num2str(ch.channelnumber),':',string]);
  125. end
  126. else
  127. ch.scope.write(['CHAN',num2str(ch.channelnumber),':',string,' ',in]);
  128. end
  129. end
  130. function c = MEAS(ch,string)
  131. c = ch.scope.query(['MEAS',num2str(ch.channelnumber),':RES:ACT?',string]);
  132. end
  133. end
  134. end