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

98 строки
2.4KB

  1. classdef Trigger
  2. %TRIGGER Summary of this class goes here
  3. % Detailed explanation goes here
  4. properties (Hidden, Access = private)
  5. scope
  6. end
  7. properties (Dependent)
  8. mode
  9. type
  10. source
  11. slope
  12. level
  13. coupling
  14. end
  15. methods
  16. function tr = Trigger(scope)
  17. tr.scope = scope;
  18. end
  19. function s = get.mode(tr)
  20. s = tr.gettrig('mode?');
  21. end
  22. function s = get.type(tr)
  23. s = tr.gettrig('type?');
  24. end
  25. function s = get.source(tr)
  26. s = tr.gettrig('sour?');
  27. end
  28. function s = get.level(tr)
  29. s = tr.gettrig(['LEV',tr.trigsource,'?']);
  30. end
  31. function s = get.coupling(tr)
  32. s = tr.gettrig('EDGE:COUP?');
  33. end
  34. function tr = set.mode(tr,string)
  35. tr.settrig(['mode ',string]);
  36. end
  37. function tr = set.type(tr,string)
  38. tr.settrig(['type ',string]);
  39. end
  40. function tr = set.source(tr,string)
  41. tr.settrig(['sour ',string]);
  42. end
  43. function tr = set.level(tr,level)
  44. tr.settrig(['LEV',tr.trigsource,' ',num2str(level)]);
  45. end
  46. function tr = set.coupling(tr,string)
  47. tr.settrig(['EDGE:COUP ',string]);
  48. end
  49. end
  50. methods (Hidden, Access = private)
  51. function c = gettrig(tr,string)
  52. c = tr.scope.query(['TRIG:A:',string]);
  53. end
  54. function settrig(tr,string)
  55. tr.scope.write(['TRIG:A:',string]);
  56. end
  57. function c = MEAS(ch,string)
  58. c = ch.scope.query(['MEAS',num2str(ch.channelnumber),':RES:ACT?',string]);
  59. end
  60. function c = CHANsend(ch,string,in)
  61. c = ['CHAN',num2str(ch.channelnumber),':',string,' ',in];
  62. end
  63. function src = trigsource(tr)
  64. src = tr.source;
  65. channel = regexp(src,'(?<=CH)[1-4]','match','once');
  66. if ~isempty(channel)
  67. src = channel;
  68. elseif strcmp(src,'EXT')
  69. src = '5';
  70. else
  71. error('Cannot get a trigger level for these settings. Try to switch the trigger source to a channel or external');
  72. end
  73. end
  74. end
  75. end