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

98 lines
2.6KB

  1. classdef Oscilloscope < Equipment
  2. %OSCILLOSCOPE Summary of this class goes here
  3. % Detailed explanation goes here
  4. properties
  5. nchannels
  6. horizontalPosition
  7. timescale
  8. ch1
  9. ch2
  10. ch3
  11. ch4
  12. trigger
  13. acquisition
  14. end
  15. methods
  16. function sc = Oscilloscope(ipAddress,port,nchannels)
  17. %OSCILLOSCOPE Construct an instance of this class
  18. % Detailed explanation goes here
  19. sc@Equipment(ipAddress,port,-1);
  20. sc.trigger = Trigger(sc);
  21. for i = 1:nchannels
  22. sc.(['ch',num2str(i)]) = Channel(sc,i);
  23. end
  24. end
  25. function s = get.acquisition(sc)
  26. s = sc.query('ACQ:STAT?');
  27. end
  28. function run(sc)
  29. sc.write_noerror('RUN');
  30. end
  31. function single(sc)
  32. sc.write_noerror('SING');
  33. end
  34. function stop(sc)
  35. sc.write_noerror('STOP');
  36. end
  37. function auto(sc)
  38. sc.write_noerror('AUT');
  39. end
  40. function enable_channels(sc)
  41. sc.write('CHAN:AON')
  42. end
  43. function disable_channels(sc)
  44. sc.write('CHAN:AOFF')
  45. end
  46. function setMeasurement(sc,measurement,type,source1,source2)
  47. prefix = ['MEAS',num2str(measurement),':'];
  48. fprintf(num2str(nargin))
  49. if nargin < 5
  50. source2 = 'CH2';
  51. if nargin < 4
  52. source1 = 'CH1';
  53. end
  54. end
  55. source = [source1,', ',source2];
  56. sc.write([prefix,'SOUR ',source]);
  57. sc.write([prefix,'MAIN ',type]);
  58. end
  59. function m = getMeasurement(sc,measurement)
  60. m = str2double(sc.query(['MEAS',num2str(measurement),':RES:ACT?']));
  61. end
  62. % function data = waveform(ch,cha)
  63. % ch.scope.clear;
  64. % ch.scope.write('CHAN1:TYPE HRES');
  65. % ch.scope.write('FORM REAL');
  66. % ch.scope.write('FORM:BORD MSBF');
  67. % ch.scope.write('CHAN1:DATA:POIN DEF');
  68. % ch.scope.write('SING');
  69. % header = str2num(ch.scope.query('CHAN1:DATA:HEAD?'));
  70. % ch.scope.write_unsafe('CHAN1:DATA?');
  71. % prefixstring = fscanf(ch.scope.tcp,'%c',2);
  72. % prefixlength = str2double(prefixstring(2));
  73. % datalength = fscanf(ch.scope.tcp,'%c',prefixlength);
  74. % data = fread(ch.scope.tcp,header(3),'float');
  75. % flushinput(ch.scope.tcp);
  76. % end
  77. end
  78. end