This commit is contained in:
2015-12-03 13:56:49 +00:00
parent fac00f4a2a
commit 98e334d4ad
6 changed files with 58 additions and 46 deletions
@@ -62,10 +62,14 @@ namespace ebbits.Arduino {
internal void clearStack(char key) {
LinkedList<ArduinoInput>.Enumerator e = readStack.GetEnumerator();
while(e.MoveNext()) {
if(e.Current.key == key) {
readStack.Remove(e.Current);
try {
while(e.MoveNext()) {
if(e.Current.key == key) {
readStack.Remove(e.Current);
}
}
} catch(InvalidOperationException) {
return;
}
}
}
+17 -12
View File
@@ -29,8 +29,9 @@ namespace ebbits.Arduino {
serialSend('b', 2, 1); //Bremse = an
}
public void trainMove() {
public void trainMove(byte speed) {
serialSend('b', 2, 0); //Bremse aus
serialSend('p', 2, speed);
}
internal void changeDir(byte dir) {
@@ -77,7 +78,7 @@ namespace ebbits.Arduino {
public bool findStart() {
changeDir(0);
if(this.whereRead() == 0) {
trainMove();
trainMove(70);
System.Threading.Thread.Sleep(3000);
}
if(this.whereRead() == 0) {
@@ -95,35 +96,35 @@ namespace ebbits.Arduino {
switch(this.whereRead()) {
case 6:
Logger.Info("Fahre von 6 nach 5");
trainMove();
trainMove(70);
readStop('r',4);
trainMove();
trainMove(70);
readStop('r',5);
break;
case 4:
Logger.Info("Fahre von 4 nach 5");
trainMove();
trainMove(70);
readStop('r',5);
break;
case 3:
Logger.Info("Fahre von 3 nach 5");
trainMove();
trainMove(70);
readStop('r',2);
trainMove();
trainMove(70);
readStop('r',1);
trainMove();
trainMove(70);
readStop('r',5);
break;
case 2:
Logger.Info("Fahre von 2 nach 5");
trainMove();
trainMove(70);
readStop('r',1);
trainMove();
trainMove(70);
readStop('r',5);
break;
case 1:
Logger.Info("Fahre von 1 nach 5");
trainMove();
trainMove(70);
readStop('r',5);
break;
}
@@ -132,6 +133,10 @@ namespace ebbits.Arduino {
return (this.whereRead() == 5);
}
public bool trainSwitchIsOff() {
serialSend('s', 0, 0);
ArduinoInput a = base.getInputWait('s');
return a.value == 0;
}
}
}