github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/eschval.go (about)

     1  //This file is part of EESLISM.
     2  //
     3  //Foobar is free software : you can redistribute itand /or modify
     4  //it under the terms of the GNU General Public License as published by
     5  //the Free Software Foundation, either version 3 of the License, or
     6  //(at your option) any later version.
     7  //
     8  //Foobar is distributed in the hope that it will be useful,
     9  //but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
    11  //GNU General Public License for more details.
    12  //
    13  //You should have received a copy of the GNU General Public License
    14  //along with Foobar.If not, see < https://www.gnu.org/licenses/>.
    15  
    16  /*      schdlr.c     */
    17  
    18  package eeslism
    19  
    20  /*  1日スケジュ-ルから設定値の選択   */
    21  
    22  func schval(nday, ttmm int, Sch *SCH, Dsch []DSCH) float64 {
    23  	sc := Sch.day[nday]
    24  
    25  	if sc < 0 {
    26  		return FNOP
    27  	}
    28  
    29  	Ds := &Dsch[sc]
    30  	N := Ds.N
    31  
    32  	for k := 0; k < N; k++ {
    33  		stime := Ds.stime[k]
    34  		etime := Ds.etime[k]
    35  		val := Ds.val[k]
    36  		if stime <= ttmm && ttmm <= etime {
    37  			return val
    38  		}
    39  	}
    40  	return FNOP
    41  }
    42  
    43  /* ----------------------------------------------------- */
    44  
    45  /*  1日スケジュ-ルから設定モ-ドの選択   */
    46  
    47  func scwmode(nday, ttmm int, Scw *SCH, Dscw []DSCW) ControlSWType {
    48  	sw := Scw.day[nday]
    49  	Ds := &Dscw[sw]
    50  	N := Ds.N
    51  
    52  	for k := 0; k < N; k++ {
    53  		stime := Ds.stime[k]
    54  		etime := Ds.etime[k]
    55  		mode := Ds.mode[k]
    56  		if stime <= ttmm && ttmm <= etime {
    57  			return mode
    58  		}
    59  	}
    60  	return 'x'
    61  }
    62  
    63  /* ----------------------------------------------------- */
    64  
    65  /*  スケジュ-ルモ-ドから設定番号の検索   */
    66  
    67  func iswmode(c rune, N int, mode []rune) int {
    68  	if N == 1 {
    69  		return 0
    70  	} else {
    71  		for i := 0; i < N; i++ {
    72  			if c == mode[i] {
    73  				return i
    74  			}
    75  		}
    76  		return -1
    77  	}
    78  }
    79  
    80  /* ----------------------------------------------------- */