github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/blrmresid.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  /*  rmresid.c   */
    17  package eeslism
    18  
    19  import (
    20  	"fmt"
    21  	"regexp"
    22  	"strings"
    23  )
    24  
    25  /* --------------------------------------------------------- */
    26  /*
    27  居住者スケジュ-ルの入力              */
    28  
    29  func Residata(fi *EeTokens, schdl *SCHDL, rooms []*ROOM, pmvpri *int, simc *SIMCONTL) {
    30  	errFmt := fmt.Sprintf(ERRFMT, "RESI")
    31  
    32  	for fi.IsEnd() == false {
    33  		var s, ss, sss, s4 string
    34  		s = fi.GetToken()
    35  		if s == "*" {
    36  			break
    37  		}
    38  		if s == "\n" {
    39  			continue
    40  		}
    41  		if s == "%s" || s == "%sn" {
    42  			fi.GetLogicalLine()
    43  			continue
    44  		}
    45  
    46  		errMsg := errFmt + s
    47  		i, err := idroom(s, rooms, errMsg)
    48  		if err != nil {
    49  			panic(err)
    50  		}
    51  		rm := rooms[i]
    52  
    53  		for {
    54  			s = fi.GetToken()
    55  			if s == ";" {
    56  				break
    57  			}
    58  
    59  			errMsg := errFmt + s
    60  			st := strings.Index(s, "=")
    61  			stVal := s[st+1:]
    62  
    63  			switch s[:st] {
    64  			case "H":
    65  				// 人体発熱
    66  				// H=(基準人数(人),在室率設定値名,作業強度設定値名)
    67  				regex := regexp.MustCompile(`\(([^,]+),([^,]+),([^,]+)\)`)
    68  				match := regex.FindStringSubmatch(stVal)
    69  				if len(match) == 4 {
    70  					// 基準人数(人)
    71  					rm.Nhm, err = readFloat(match[1])
    72  					if err != nil {
    73  						panic(err)
    74  					}
    75  
    76  					// 在室率設定値名
    77  					ss = match[2]
    78  					if k, err := idsch(ss, schdl.Sch, ""); err == nil {
    79  						rm.Hmsch = &schdl.Val[k]
    80  					} else {
    81  						rm.Hmsch = envptr(ss, simc, nil, nil, nil)
    82  					}
    83  
    84  					// 作業強度設定値名
    85  					sss = match[3]
    86  					if k, err := idsch(sss, schdl.Sch, ""); err == nil {
    87  						rm.Hmwksch = &schdl.Val[k]
    88  					} else {
    89  						rm.Hmwksch = envptr(sss, simc, nil, nil, nil)
    90  					}
    91  				} else {
    92  					fmt.Println("No match found.")
    93  				}
    94  			case "comfrt":
    95  				// 熱環境条件
    96  				// comfrt=(代謝率設定値名,着衣量設定値名,室内風速設定値名)
    97  				regex := regexp.MustCompile(`\(([^,]+),([^,]+),([^,]+)\)`)
    98  				match := regex.FindStringSubmatch(stVal)
    99  				if len(match) == 4 {
   100  					// 代謝率(Met値)設定値名
   101  					ss = match[1]
   102  					if k, err := idsch(ss, schdl.Sch, ""); err == nil {
   103  						rm.Metsch = &schdl.Val[k]
   104  					} else {
   105  						rm.Metsch = envptr(ss, simc, nil, nil, nil)
   106  					}
   107  
   108  					// 着衣量(Clo値)設定値名
   109  					sss = match[2]
   110  					if k, err := idsch(sss, schdl.Sch, ""); err == nil {
   111  						rm.Closch = &schdl.Val[k]
   112  					} else {
   113  						rm.Closch = envptr(sss, simc, nil, nil, nil)
   114  					}
   115  
   116  					// 室内風速設定値名
   117  					s4 = match[3]
   118  					if k, err := idsch(s4, schdl.Sch, ""); err == nil {
   119  						rm.Wvsch = &schdl.Val[k]
   120  					} else {
   121  						rm.Wvsch = envptr(s4, simc, nil, nil, nil)
   122  					}
   123  
   124  					*pmvpri = 1
   125  					if SETprint {
   126  						rm.setpri = true
   127  					}
   128  				} else {
   129  					fmt.Println("No match found.")
   130  				}
   131  
   132  			default:
   133  				Eprint("<Residata>", errMsg)
   134  			}
   135  		}
   136  	}
   137  }
   138  
   139  /* --------------------------------------------------------- */
   140  /*
   141  照明・機器利用スケジュ-ルの入力              */
   142  
   143  func Appldata(fi *EeTokens, schdl *SCHDL, rooms []*ROOM, simc *SIMCONTL) {
   144  	errFmt := fmt.Sprintf(ERRFMT, "APPL")
   145  
   146  	for fi.IsEnd() == false {
   147  		var s, ss string
   148  		s = fi.GetToken()
   149  		if s == "*" {
   150  			break
   151  		}
   152  		if s == "\n" {
   153  			continue
   154  		}
   155  		if s == "%s" || s == "%sn" {
   156  			fi.GetLogicalLine()
   157  			continue
   158  		}
   159  
   160  		errMsg := errFmt + s
   161  		i, err := idroom(s, rooms, errMsg)
   162  		if err != nil {
   163  			panic(err)
   164  		}
   165  		rm := rooms[i]
   166  
   167  		for fi.IsEnd() == false {
   168  			s = fi.GetToken()
   169  			if s == ";" {
   170  				break
   171  			}
   172  
   173  			errMsg := errFmt + s
   174  			st := strings.Index(s, "=")
   175  			stVal := s[st+1:]
   176  
   177  			switch s[:st] {
   178  			case "L":
   179  				// 照明
   180  				// L=(基準値[W],器具タイプ,照明入力設定値名)
   181  				regex := regexp.MustCompile(`\(([^,]+),([^,]+),([^,]+)\)`)
   182  				match := regex.FindStringSubmatch(stVal)
   183  				if len(match) == 4 {
   184  					// 基準値[W]
   185  					rm.Light, err = readFloat(match[1])
   186  					if err != nil {
   187  						panic(err)
   188  					}
   189  
   190  					// 器具タイプ
   191  					rm.Ltyp = rune(match[2][0])
   192  
   193  					// 照明入力設定値名
   194  					ss = match[3]
   195  					if k, err := idsch(ss, schdl.Sch, ""); err == nil {
   196  						rm.Lightsch = &schdl.Val[k]
   197  					} else {
   198  						rm.Lightsch = envptr(ss, simc, nil, nil, nil)
   199  					}
   200  				} else {
   201  					fmt.Println("No match found.")
   202  				}
   203  
   204  			case "As":
   205  				// 機器顕熱
   206  				// As=(対流成分基準値[W],放射成分基準値[W],設定値名)
   207  				regex := regexp.MustCompile(`\(([^,]+),([^,]+),([^,]+)\)`)
   208  				match := regex.FindStringSubmatch(stVal)
   209  				if len(match) == 4 {
   210  					// 対流成分基準値[W]
   211  					rm.Apsc, err = readFloat(match[1])
   212  					if err != nil {
   213  						panic(err)
   214  					}
   215  
   216  					// 放射成分基準値[W]
   217  					rm.Apsr, err = readFloat(match[1])
   218  					if err != nil {
   219  						panic(err)
   220  					}
   221  
   222  					// 設定値名
   223  					ss = match[3]
   224  					if k, err := idsch(ss, schdl.Sch, ""); err == nil {
   225  						rm.Assch = &schdl.Val[k]
   226  					} else {
   227  						rm.Assch = envptr(ss, simc, nil, nil, nil)
   228  					}
   229  				} else {
   230  					fmt.Println("No match found.")
   231  				}
   232  
   233  			case "Al":
   234  				// 機器潜熱
   235  				// Al=(基準値[W],設定値名)
   236  				regex := regexp.MustCompile(`\(([^,]+),([^,]+)\)`)
   237  				match := regex.FindStringSubmatch(stVal)
   238  				if len(match) == 3 {
   239  					// 基準値[W]
   240  					rm.Apl, err = readFloat(match[1])
   241  					if err != nil {
   242  						panic(err)
   243  					}
   244  
   245  					// 設定値名
   246  					ss = match[2]
   247  					if k, err := idsch(ss, schdl.Sch, ""); err == nil {
   248  						rm.Alsch = &schdl.Val[k]
   249  					} else {
   250  						rm.Alsch = envptr(ss, simc, nil, nil, nil)
   251  					}
   252  				} else {
   253  					fmt.Println("No match found.")
   254  				}
   255  
   256  			case "AE":
   257  				// 電力に関する集計を行う
   258  				// AE=(基準値[W],電力設定値名
   259  				regex := regexp.MustCompile(`\(([^,]+),([^,]+)\)`)
   260  				match := regex.FindStringSubmatch(stVal)
   261  				if len(match) == 3 {
   262  					// 基準値[W]
   263  					rm.AE, err = readFloat(match[1])
   264  					if err != nil {
   265  						panic(err)
   266  					}
   267  
   268  					// 電力設定値名
   269  					ss = match[2]
   270  					if k, err := idsch(ss, schdl.Sch, ""); err == nil {
   271  						rm.AEsch = &schdl.Val[k]
   272  					} else {
   273  						rm.AEsch = envptr(ss, simc, nil, nil, nil)
   274  					}
   275  				} else {
   276  					fmt.Println("No match found.")
   277  				}
   278  
   279  			case "AG":
   280  				// ガスに関する集計を行う
   281  				// AG=(基準値[W],ガス設定値名)
   282  				regex := regexp.MustCompile(`\(([^,]+),([^,]+)\)`)
   283  				match := regex.FindStringSubmatch(stVal)
   284  				if len(match) == 3 {
   285  					// 基準値[W]
   286  					rm.AG, err = readFloat(match[1])
   287  					if err != nil {
   288  						panic(err)
   289  					}
   290  
   291  					// ガス設定値名
   292  					ss = match[2]
   293  					if k, err := idsch(ss, schdl.Sch, ""); err == nil {
   294  						rm.AGsch = &schdl.Val[k]
   295  					} else {
   296  						rm.AGsch = envptr(ss, simc, nil, nil, nil)
   297  					}
   298  				} else {
   299  					fmt.Println("No match found.")
   300  				}
   301  
   302  			default:
   303  				Eprint("<Appldata>", errMsg)
   304  			}
   305  		}
   306  	}
   307  }