7 baudRateArduino = 9600;
12 %
true = open; Aktueller Zustand des Shutters
14 %Winkel in DEG des Servomotors, bei dem der Shutter geöffnet ist
16 %Winkel in DEG des Servomotors, bei dem der Shutter geschlossen ist
19 %Power Control Properties
21 ELL14Connected =
false;
26 ELL14SafetyWarning =
false;
27 ELL14SafetyWarningType =
'Warning Message';
33 obj.rawBeamDiameter = 5.1;
39 obj.comPortArduino = serialport(strcat("COM", num2str(obj.ArduinoPort)), obj.baudRateArduino);
41 %Warten, bis Arduino verbunden ist
43 %Setzen der Shutterwinkel
44 obj.setShutterOpenAngle();
46 obj.setShutterCloseAngle();
49 function disconnect(obj)
50 obj.comPortArduino = [];
52 %
#muss hier auch Verbindung zum ELL14 gelöscht werden?
56 obj.arduinoCommandQuick("LaserOpen");
60 function laserOff(obj)
61 obj.arduinoCommandQuick("LaserClose");
65 function shutterOpen(obj)
66 obj.arduinoCommandQuick("ShutterOpen");
70 function shutterClose(obj)
71 obj.arduinoCommandQuick("ShutterClose");
75 function setShutterOpenAngle(obj)
76 obj.arduinoCommand(strcat("ServoPositionOpen ",num2str(obj.angleOpen)));
79 function setShutterCloseAngle(obj)
80 obj.arduinoCommand(strcat("ServoPositionClose ",num2str(obj.angleClose)));
83 function laserTime(obj, time)
84 obj.arduinoCommand(strcat("LaserTime ",num2str(time*1000)));
89 function text = arduinoCommand(obj, command)
90 %Wartet Antwort des Arduinio ab und schreibt sie ins Protokoll
91 writeline(obj.comPortArduino,command);
92 message = strcat("send: ",command);
93 obj.ArduinoMessages = [message obj.ArduinoMessages];
97 while (response == "got: ")
98 value = readline(obj.comPortArduino);
99 response = strcat("got: ",value);
102 msgbox("ERROR - no response from Arduino");
105 obj.ArduinoMessages = [strcat(datestr(now), response) obj.ArduinoMessages];
108 %
#prüfen, was wirklich zurückgegeben werden muss
111 function arduinoCommandQuick (obj, command)
112 writeline(obj.comPortArduino,command);
117 function PowerAdjustmentConnect(obj)
118 obj.comPortELL14 = serialport(strcat(
"COM", num2str(obj.ELL14Port)), obj.baudRateELL14);
119 obj.ELL14Connected =
true;
122 function PowerAdjustmentDisconnect(obj)
123 obj.comPortELL14 = [];
124 obj.ELL14Connected =
false;
127 function PowerAdjustmentRotate(obj)
128 hexstr = dec2hex(single(round(obj.ELL14Angle*398.2)));%398.2 ausgelesener Wert aus ELL-Software
129 while length(hexstr)<8
130 hexstr = [
'0' hexstr];
132 code = strcat(
'0ma',hexstr);
133 writeline(obj.comPortELL14,code);
136 function PowerPlus(obj)
137 obj.ELL14Angle = obj.ELL14Angle + obj.ELL14Step;
138 obj.PowerAdjustmentRotate();
141 function PowerMinus(obj)
142 obj.ELL14Angle = obj.ELL14Angle - obj.ELL14Step;
143 obj.PowerAdjustmentRotate();
146 function value = powerAdjustmentWarning(obj)
147 if(obj.ELL14SafetyWarning)
148 if(obj.ELL14SafetyWarningType ==
"Warning Message")
149 %Dialog öffnen, ob Leistung verstellt werden soll
150 answer = questdlg(
'This will change the Power. Are you sure that the beam will not hit critical components?', ...
152 'Yes',
'No --> Cancel');
160 elseif(obj.ELL14SafetyWarningType ==
"Only at Closed Shutter")
161 %Leistungsänderung nur erlauben, wenn Shutter
163 if(obj.connected && obj.shutter ==
false)
168 elseif(obj.ELL14SafetyWarningType ==
"Only During Power Measurement")
169 %Leistungsänderung nur erlauben, wenn Leistung auf