25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.7KB

  1. classdef TriggerClass
  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. hfreject
  15. end
  16. methods
  17. function tr = TriggerClass(scope)
  18. tr.scope = scope;
  19. end
  20. function s = get.mode(tr)
  21. s = tr.gettrig('mode?');
  22. end
  23. function s = get.type(tr)
  24. s = tr.gettrig('type?');
  25. end
  26. function s = get.source(tr)
  27. s = tr.gettrig('sour?');
  28. end
  29. function s = get.level(tr)
  30. s = tr.gettrig(['LEV',tr.trigsource,'?']);
  31. end
  32. function s = get.coupling(tr)
  33. s = tr.gettrig('EDGE:COUP?');
  34. end
  35. function s = get.hfreject(tr)
  36. s = tr.gettrig('EDGE:FILT:HFR?');
  37. end
  38. function tr = set.mode(tr,string)
  39. tr.settrig(['mode ',string]);
  40. end
  41. function tr = set.type(tr,string)
  42. tr.settrig(['type ',string]);
  43. end
  44. function tr = set.source(tr,string)
  45. tr.settrig(['sour ',string]);
  46. end
  47. function tr = set.level(tr,level)
  48. tr.settrig(['LEV',tr.trigsource,' ',num2str(level)]);
  49. end
  50. function tr = set.coupling(tr,string)
  51. tr.settrig(['EDGE:COUP ',string]);
  52. end
  53. function tr = set.hfreject(tr,string)
  54. tr.settrig(['EDGE:FILT:HFR ' string]);
  55. end
  56. end
  57. methods (Hidden, Access = private)
  58. function c = gettrig(tr,string)
  59. c = tr.scope.query(['TRIG:A:',string]);
  60. end
  61. function settrig(tr,string)
  62. tr.scope.write(['TRIG:A:',string]);
  63. end
  64. function c = MEAS(ch,string)
  65. c = ch.scope.query(['MEAS',num2str(ch.channelnumber),':RES:ACT?',string]);
  66. end
  67. function c = CHANsend(ch,string,in)
  68. c = ['CHAN',num2str(ch.channelnumber),':',string,' ',in];
  69. end
  70. function src = trigsource(tr)
  71. src = tr.source;
  72. channel = regexp(src,'(?<=CH)[1-4]','match','once');
  73. if ~isempty(channel)
  74. src = channel;
  75. elseif strcmp(src,'EXT')
  76. src = '5';
  77. else
  78. error('Cannot get a trigger level for these settings. Try to switch the trigger source to a channel or external');
  79. end
  80. end
  81. end
  82. end