Schaltuhr Programmierung Kategorie: Programmierung (von guido - 28.11.2004 19:39) | ||
| ||
Hallo @all Ich habe mal wieder ein Programmtechnisches Problem Folgendes Programm soll für verschieden Situationen verschieden Schaltzeiten zur Verfügung stellen mir erschein es jedoch sehr umfangreich um die Zeiten zu speichern wie kann ich das Problem anders Lösen ?? Ich bin für jede Hilfe dankbar Mfg Guido Hier der Code //---------------------------- //berechnung der Schaltzeiten //---------------------------- function schaltuhr () returns byte { byte u; int hour, min, time; hour=system.hour(); min=system.minute(); time=(hour*100)+ min; if var.safe1==0 // Programm Gäste aktiv { if var.zeit1[0]<time and time<var.zeit1[1] u=-1;//Schaltzeit 1 else if var.zeit1[2]<time and time<var.zeit1[3] u=-1;//Schaltzeit 2 else if var.zeit1[4]<time and time<var.zeit1[5] u=-1;//Schaltzeit 3 else if var.zeit1[6]<time and time<var.zeit1[7] u=-1;//Schaltzeit 4 else u=0; } else if var.safe1==1 // Programm Gäste im Haus aktiv { if var.zeit2[0]<time and time<var.zeit2[1] u=-1;//Schaltzeit 1 else if var.zeit2[2]<time and time<var.zeit2[3] u=-1;//Schaltzeit 2 else if var.zeit2[4]<time and time<var.zeit2[5] u=-1;//Schaltzeit 3 else if var.zeit2[6]<time and time<var.zeit2[7] u=-1;//Schaltzeit 4 else u=0; } else if var.safe1==2 // Programm Allein aktiv { if var.zeit3[0]<time and time<var.zeit3[1] u=-1;//Schaltzeit 1 else if var.zeit3[2]<time and time<var.zeit3[3] u=-1;//Schaltzeit 2 else if var.zeit3[4]<time and time<var.zeit3[5] u=-1;//Schaltzeit 3 else if var.zeit3[6]<time and time<var.zeit3[7] u=-1;//Schaltzeit 4 else u=0; } else if var.safe1==3 // Programm Tag aktiv { if var.zeit4[0]<time and time<var.zeit4[1] u=-1;//Schaltzeit 1 else if var.zeit4[2]<time and time<var.zeit4[3] u=-1;//Schaltzeit 2 else if var.zeit4[4]<time and time<var.zeit4[5] u=-1;//Schaltzeit 3 else if var.zeit4[6]<time and time<var.zeit4[7] u=-1;//Schaltzeit 4 else u=0; } else if var.safe1==4 // Programm Nacht aktiv { if var.zeit5[0]<time and time<var.zeit5[1] u=-1;//Schaltzeit 1 else if var.zeit5[2]<time and time<var.zeit5[3] u=-1;//Schaltzeit 2 else if var.zeit5[4]<time and time<var.zeit5[5] u=-1;//Schaltzeit 3 else if var.zeit5[6]<time and time<var.zeit5[7] u=-1;//Schaltzeit 4 else u=0; } else { if var.safe1==5 //Programm 24h if var.zeit6[0]<time and time<var.zeit6[1] u=-1;//Schaltzeit 1 else if var.zeit6[2]<time and time<var.zeit6[3] u=-1;//Schaltzeit 2 else if var.zeit6[4]<time and time<var.zeit6[5] u=-1;//Schaltzeit 3 else if var.zeit6[6]<time and time<var.zeit6[7] u=-1;//Schaltzeit 4 else u=0; } return u; } //---------------------------- | ||
Antwort schreiben Antworten: ![]() ![]() ![]() ![]() ![]() ![]() ![]() |