|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Objectohymosj.OhObject
ohymosj.OhElement
ohymosj.SimpleDam
SimpleDam. Simple dam model.
フィールドの概要 | |
protected double[] |
_cRp
|
protected int |
_dt
|
protected int |
_numberOfRp
|
protected double |
_qCrnt
|
protected double |
_qInCrnt
|
protected double |
_qInNext
|
protected double |
_qNext
|
protected double |
_qPass
|
protected double |
_ratio
|
protected OhReceiveDouble[] |
_rP
|
protected OhSendDouble |
_sP0
|
protected OhSendDouble |
_sP1
|
protected double |
_storageCrnt
|
protected double |
_storageNext
|
クラス ohymosj.OhElement から継承したフィールド |
_calReqP, _currentTime, _dataString, _fixedTime, _initialWorkDoneP, _numberOfObjects, _numberOfReceivePorts, _numberOfSendPorts, _objectArray, _objectList, _receivePortArray, _sendPortArray, _shareInfoDoneP, _targetTime, _timeStep |
クラス ohymosj.OhObject から継承したフィールド |
_className, _objectName, _objectNumber, _owner, NEWLINE |
コンストラクタの概要 | |
SimpleDam()
|
|
SimpleDam(java.lang.String aObjName,
int aObjNum,
java.lang.String aDataStr,
int aNrp)
|
メソッドの概要 | |
boolean |
calculate()
|
long |
calculateTimeStep()
|
boolean |
canYouCalculate()
|
boolean |
init(java.lang.String aObjName,
int aObjNum,
OhBufferedReader aBr)
|
boolean |
init(java.lang.String aObjName,
int aObjNum,
java.lang.String aDataStr,
int aNrp)
|
boolean |
initialOutput()
|
void |
registerReceivePorts()
|
void |
registerSendPorts()
|
void |
saveParameter(java.io.PrintWriter aPw)
|
void |
saveTerminalState(java.io.PrintWriter aPw)
|
void |
setInitialState(OhBufferedReader aBr)
|
void |
setParameter(OhBufferedReader aBr)
|
boolean |
work()
|
クラス ohymosj.OhObject から継承したメソッド |
cPrint, getAbsName, getClassName, getObjectName, getObjectNumber, getOwner, getTopOwner, objCompare, objCompare, objCompare, oPrint, setOwner |
クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
フィールドの詳細 |
protected OhReceiveDouble[] _rP
protected OhSendDouble _sP0
protected OhSendDouble _sP1
protected int _numberOfRp
protected double _qPass
protected double _ratio
protected int _dt
protected double[] _cRp
protected double _storageCrnt
protected double _qCrnt
protected double _storageNext
protected double _qNext
protected double _qInCrnt
protected double _qInNext
コンストラクタの詳細 |
public SimpleDam() throws OhError
public SimpleDam(java.lang.String aObjName, int aObjNum, java.lang.String aDataStr, int aNrp) throws OhError
メソッドの詳細 |
public boolean init(java.lang.String aObjName, int aObjNum, java.lang.String aDataStr, int aNrp) throws OhError
OhError
public boolean init(java.lang.String aObjName, int aObjNum, OhBufferedReader aBr) throws OhError
OhElement
の記述: (OhElement)elm = (OhElement)Class.forName("ohymosj." + className).newInstance(); elm.init(objectName, objectNum, br);のようにして構成要素を割り当てます。
構成要素のクラス名をファイルから読みとってつくりあげる部分系モデルで 利用されるようにするためには、 このメソッドを定義しておく必要があります。
init(aObjName, aObjNum, aBr) が未定義の構成要素が呼ばれたときには、 例外 OhError が投げられます。
Initialization with the information which is given through a file.
OhElement
内の init
aObjName
- a String
valueaObjNum
- an int
valueaBr
- an OhBufferedReader
value
boolean
value
OhError
- if an error occurspublic void registerReceivePorts() throws OhError
OhElement
の記述: このメソッドは、派生クラスの全受信端子を OhElement.register(Object) OhElement.register(Object, int) により登録します。
登録されていない端子は接続できないので送受信に利用できません。
例えば、派生クラスで受信端子 abc を定義した場合、
public void registerReceivePort() { register((Object) abc); }とすれば、abc を受信端子として登録できます。
Declares method registerReceivePorts() as abstract method. In classes derived from class Element, its definition should be given.
"registerReceivePorts()" registers all the receiving ports of an inherited class, and all sending ports by OhElement.register(Object) OhElement.register(Object, int).
The port which is not registered is not applicable to sending and receiving,
since it is not connectable.
For example, when an inherited class defines the receiving port "abc",
if it is performed as follows, "abc" can be registered as a receiving terminal.
void registerReceivePort() { register((Object)abc); }
OhElement
内の registerReceivePorts
OhError
- if an error occurspublic void registerSendPorts() throws OhError
OhElement
の記述: このメソッドは、派生クラスの全送信端子を OhElement.register(Object) OhElement.register(Object, int) により登録します。
登録されていない端子は接続できないので送受信に利用できません。
例えば、派生クラスで送信端子 abc を定義した場合、
public void registerSendPort() { register((Object) abc); }とすれば、abc を送信端子として登録できます。
Declares method "registerSendPorts() as abstract method. In classes derived from class Element, its definition should be given.
"registerSendPorts()" registers all the receiving ports of an inherited class, and all sending ports by OhElement.register(Object) OhElement.register(Object, int).
The port which is not registered is not applicable to sending and receiving, since it is not connectable. For example, when an inherited class defines the receiving port "abc", if it is performed as follows, "abc" can be registered as a receiving terminal.
void registerSendPort() { register((Object)abc); }
OhElement
内の registerSendPorts
OhError
- if an error occurspublic void setParameter(OhBufferedReader aBr) throws OhError
OhElement
の記述:
Declares method "setParameter()" as abstract method. In classes derived from class Element, its definition should be given.
Parameters are read in the input stream "aBr". It is necessary to create an element model according to each inherited class. Data is read in the file specified by the input stream "aBr", and the amount of initial states is set up.
Please have the program and consistency which save the last state at a file.
OhElement
内の setParameter
aBr
- a OhBufferedReader
value
OhError
- if an error occurspublic void saveParameter(java.io.PrintWriter aPw)
public void setInitialState(OhBufferedReader aBr) throws OhError
OhElement
の記述: 最終状態をファイルに保存するプログラムとつじつまがあうようにしてください。
Declares method "setInitialState()" as abstract method. In classes derived from class Element, its definition should be given.
The method which sets up the amount of initial states is defined according to each inherited class.
OhElement
内の setInitialState
aBr
- a OhBufferedReader
value
OhError
- if an error occurspublic void saveTerminalState(java.io.PrintWriter aPw)
OhElement
の記述: 最終状態を書き込む仕様は次のようにしてください。
(data_string)
This is the method which does the work which writes the last state of an element in the file specified by the output stream "aBr".
In classes derived from class Element, its definition should be given.
OhElement
内の saveTerminalState
aPw
- a PrintWriter
valuepublic boolean initialOutput() throws OhError
OhElement
の記述: 初期状態量を決めた直後に、_currentTime での出力を定義します。 送信端子に時刻と出力値を書き込みます。 _currnetTime での出力が計算できた場合は true を返します。 必要な入力データが得られていないなどして、 _currentTime の出力が計算できなかった場合は false を返します。
要素によっては、setInitialState() の中で 初期の出力をするようにした方が都合がよいかも知れません。 たとえば、初期値設定のために与えられる文字列によって、 初期の出力のやり方を変えたりする場合などです。 そうした場合は、initialOutput() は何もしないように定義して、 setInitialState() で初期の出力をするように定義しても構いません。
An initial output. In classes derived from class Element, its definition should be given.
The output in "_currentTime" is defined immediately after deciding the amount of initial states. Time and an output value are written in a sending port. "true" is returned when the output in "_currentTime" is able to be calculated. "false" is returned when the output of "_currentTime" is not able to be calculated by required input data not being obtained.
OhElement
内の initialOutput
boolean
value
OhError
- if an error occurspublic long calculateTimeStep() throws OhError
OhElement
の記述: 各派生クラスでモデルに応じて _timeStep [sec] を計算し、 戻り値として返すメソッドを定義して下さい。
つまり、_timeStep をどのような条件下で、どのような値にするかを定義します。
例えば、_timeStep を一定値 3600 [sec] に設定する場合、
public long calculateTimeStep() { return 3600; }と定義して下さい。
また、下記のようにメンバ変数 _k の値により _timeStep を変更することもできます。
public long calculateTimeStep() { return (_k > 0) ? 360 : 60; } public long calculateTimeStep() { return 360 * pow(10, _k); }_timeStep は、work() の中で設定されるので、
public long calculateTimeStep() { _timeStep = 1; return 1; }のように、このメソッドの中で変更しないでください。
抽象メソッドなので、派生クラスで必ず定義して下さい。
戻り値: 次回の計算のタイムステップ。[sec]
Calculation of a time step. In classes derived from class Element, its definition should be given.
Please calculate "_timeStep" according to a model in each inherited class, and define the method which returns it as a return value. That is, it defines under what conditions "_timeStep" is made into what value.
OhElement
内の calculateTimeStep
long
value
OhError
- if an error occurspublic boolean canYouCalculate() throws OhCannotGetDataError, OhError
OhElement
の記述: まず、_currentTime が _terminalTime 以上の場合、計算済みと判断し false を返します。
次に、全ての所有受信端子が getNecessaryTimeFrom(), getNecessaryTimeTo() 間の データパックを取得可能であることを確認します。 取得可能な場合、計算実行可能と判断して true を返します。 取得不可能な場合、計算実行不可と判断して false を返します。
データが取得不可能であると返事をしてきた受信端子に対して計算要求を出します。 具体的には、受信端子に calReq() メッセージを送ります。
[戻り値] ・true --> 計算実行可能の場合。 ・false -> 計算実行不可能の場合、または計算済みの場合。
Judgment whether calculation can be started or not. In classes derived from class Element, its definition should be given.
First, when "_currentTime" is more than "_terminalTime", it is judged that calculation has finished, and "false" is returned.
Next, it checks that all possession receiving ports can acquire the data pack between "getNecessaryTimeFrom" and "getNecessaryTimeTo". It is judged that calculation execution is possible the case of being acquirable, "true" is returned. It is judged that calculation execution is impossible the case of being unacquirable, "false" is returned.
A calculation request is advanced to the receiving port which will have replied that data is unacquirable. In particular, a calculation request message is sent to a receiving port.
[RETURN] ・true --> When calculation execution is possible. ・false -> When calculation execution is impossible. When calculation has finished.
OhElement
内の canYouCalculate
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic boolean work() throws OhCannotGetDataError, OhError
OhElement
の記述: calculate(), calculateTimeStep() などを用いて、_terminalTime までの計算を実行します。
まず、 OhElement.canYouCalculate() の戻り値が false ならば、計算開始不可と判断し、false を返します。
戻り値が true の場合は、 true である限り、 OhElement.calculate(), _currentTime.add(_timeStep) を繰り返し実行します。
最後に、 OhElement.setDataPackArray(), を実行し、true を返します。
[戻り値] ・true --> 計算を実行した場合。 ・false -> 計算不可能の場合、または計算済みの場合。
Calculate between "_currentTime" and "_terminalTime". In classes derived from class Element, its definition should be given.
Calculation by "_terminalTime" is performed using "calculate()", "calculateTimeStep()", etc.
First, if return value of "canYouCalculate()" becomes "false", it will be judged that a calculation start is impossible, "false" is returned.
When the return value is "true", "calculate()" and "_currentTime += _timeStep" are repeated and performed, as long as the return value of "canYouCalculate" is "true".
Finally, "setDataPackArray()" and "reportToSender()" are performed and "true" is returned.
[RETURN] ・true --> When calculation was performed. ・false -> When calculation is impossible. When calculation has finished.
OhElement
内の work
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic boolean calculate() throws OhError
OhElement
の記述: 各ユーザが独自の要素モデルを作成する際、1ステップ分の計算手続きを定義して下さい。 一般的な要素では、
(1) 受信端子からの入力。 (2) 数理計算。 (3) 送信端子への出力。 (4) 状態量の更新。(2) では、パラメータ、_currentTime における状態量、受信端子からの入力を用い、 _currentTime + _timeStep における状態量、送信すべき出力値を計算する数理モデルの1ステップ分を 具体的に定義して下さい。
このメソッドの中で _currentTime, _timeStep を変更しないで下さい。 必要ならば _timeStep を更に細かい時間区分に分割して計算できますが、 この時は作業用変数を用い、_currentTime, _timeStep を変更しないように注意して下さい。
計算に必要な全ての数値は、データメンバ及び所有受信端子からの入力として取得できます。 従って引数は不要です。
予定通り計算できた場合は、true を返します。 calculate() の内部で計算時間ステップを計算し、 その計算時間ステップ分のデータを取得できないなどして、 計算を進めることができなかった場合は、false を返します。
抽象メソッドなので、派生クラスで必ず定義して下さい。
[ACCIDENT] ・このメソッドの中で _currentTime, _timeStep が変更された場合。
Calculation procedure for 1 step. In classes derived from class Element, its definition should be given.
(1) the input from a receiving port. (2) numerical computation. (3) the output to a sending port. (4) updating of the amount of states.At (2), by using parameters, the amount of states in "_currentTime" , and the input from a receiving ports, please define concretely one step of a numerical model which calculate the amount of states and the output value which should be transmitted in "_currentTime + _timeStep".
In this method, please do not change "_currentTime" and "_timeStep".
All numerical values required for calculation are acquirable as instance variable and input from a possession receiving port. Therefore, arguments are unnecessary.
The case where it is calculable as planned, "true" is returned. When a calculation time step is calculated inside "calculate()", the data for the calculation time step cannot be acquired and calculation is not able to be advanced, "false" is returned.
OhElement
内の calculate
boolean
value
OhError
- if an error occurs
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |