|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Objectohymosj.OhObject
ohymosj.OhElement
抽象クラスです。
要素モデルは、パラメタ, 状態量, 受信端子, 送信端子をデータメンバに記憶し、
パラメタ・状態量・受信端子からの入力データを用いて数理計算を行ない、状態量を更新し、
送信端子から出力データを送信します。
こうした計算作業のうち、各要素モデルに共通な作業と共通でない作業とを分離し、
共通部分のみ抽出・規格化したものが基本型要素モデルです。
このクラスは、基本型要素モデルを表すクラスを定義しています。
要素モデルが所有する全送信端子, 全受信端子は、
_receivePortArray, _sendPortArray に登録します。
基本型要素モデルでは、この登録手続きに関する規格化を行ない、
要素モデルの作成作業の簡素化を進めるとともに、
各要素モデルに登録手続きに関する同等の信頼性を与えています。
また、各要素の送受信端子の接続は部分系モデルが行ないますが、
この作業を容易にするため、要素モデルが所有する送受信端子に関する検索機能も定義しました。
通常は、要素モデルがその状態を更新するために必要なデータは受信端子を経て取得するように設計しますが、
やむを得ない場合は、「直接通信」によって必要なデータを取得する仕組みをユーザが定義できるように、
直接通信する要素の配列を記憶するためのメンバ変数 _objectArray が用意されています。
OhElement; Abstract class for element models.
An element model
Class OhElement expresses the common part of those hydrologic element models.
フィールドの概要 | |
protected boolean |
_calReqP
|
protected OhTimePoint |
_currentTime
|
protected java.lang.String |
_dataString
|
protected OhTimePoint |
_fixedTime
|
protected boolean |
_initialWorkDoneP
|
protected int |
_numberOfObjects
|
protected int |
_numberOfReceivePorts
|
protected int |
_numberOfSendPorts
|
protected java.lang.Object[] |
_objectArray
|
protected OhLinkedList |
_objectList
|
protected java.lang.Object[] |
_receivePortArray
|
protected java.lang.Object[] |
_sendPortArray
|
protected boolean |
_shareInfoDoneP
|
protected OhTimePoint |
_targetTime
|
protected long |
_timeStep
|
クラス ohymosj.OhObject から継承したフィールド |
_className, _objectName, _objectNumber, _owner, NEWLINE |
コンストラクタの概要 | |
OhElement()
|
|
OhElement(java.lang.String aObjName,
int aObjNum,
int aNumOfObjs,
java.lang.String aStr)
|
|
OhElement(java.lang.String aObjName,
int aObjNum,
java.lang.String aStr)
|
メソッドの概要 | |
boolean |
areYouReady()
|
abstract boolean |
calculate()
|
long |
calculateIterationStep()
|
abstract long |
calculateTimeStep()
|
void |
calReq()
|
abstract boolean |
canYouCalculate()
|
boolean |
canYouCalculate0()
|
boolean |
canYouCalculate1()
|
boolean |
canYouGetDataString(java.lang.String aDataStr)
|
boolean |
canYouRenewCurrentTime()
|
boolean |
canYouSetObjectArray(int aNumOfObjs)
|
boolean |
canYouShareInfo()
|
boolean |
canYouSwitch()
|
void |
clearDataString()
|
boolean |
construct()
|
static OhElement |
create(java.lang.String aClassName)
|
OperationFlag |
doInitialWork()
|
OperationFlag |
doShareInfo()
|
boolean |
doYouConverge()
|
boolean |
doYouReachTargetTime()
|
void |
flushData()
|
java.lang.Object |
getComponent(java.lang.String aObjName)
|
java.lang.Object |
getComponent(java.lang.String aObjName,
int aObjNum)
|
java.lang.Object |
getComponent(java.lang.String aClassName,
java.lang.String aObjName)
|
java.lang.Object |
getComponent(java.lang.String aClassName,
java.lang.String aObjName,
int aObjNum)
|
OhTimePoint |
getCurrentTime()
|
OhTimePoint |
getFixedTime()
|
java.lang.Object |
getFromArray(java.lang.String aObjName,
int aObjNum,
java.lang.Object[] aObjArray,
int aNumOfObjs)
|
java.lang.Object |
getFromArray(java.lang.String aClassName,
java.lang.String aObjName,
int aObjNum,
java.lang.Object[] aObjArray,
int aNumOfObjs)
|
java.lang.Object |
getFromList(java.lang.String aObjName,
int aObjNum)
|
java.lang.Object |
getFromList(java.lang.String aClassName,
java.lang.String aObjName,
int aObjNum)
|
void |
getInitialState(OhBufferedReader aBr)
|
OhTimePoint |
getMediumTermTargetTime()
|
OhTimePoint |
getNecessaryTimeFrom(OhReceivePort aRp)
|
OhTimePoint |
getNecessaryTimeTo(OhReceivePort aRp)
|
OhTimePoint |
getNextTime()
|
java.lang.Object |
getObject(java.lang.String aClassName,
java.lang.String aObjName)
|
java.lang.Object |
getObject(java.lang.String aClassName,
java.lang.String aObjName,
int aObjNum)
|
void |
getParameter(OhBufferedReader aBr)
|
java.lang.Object |
getReceivePort(java.lang.String aObjName)
|
java.lang.Object |
getReceivePort(java.lang.String aObjName,
int aObjNum)
|
java.lang.Object |
getReceivePort(java.lang.String aClassName,
java.lang.String aObjName)
|
java.lang.Object |
getReceivePort(java.lang.String aClassName,
java.lang.String aObjName,
int aObjNum)
|
java.lang.Object |
getSendPort(java.lang.String aObjName)
|
java.lang.Object |
getSendPort(java.lang.String aObjName,
int aObjNum)
|
java.lang.Object |
getSendPort(java.lang.String aClassName,
java.lang.String aObjName)
|
java.lang.Object |
getSendPort(java.lang.String aClassName,
java.lang.String aObjName,
int aObjNum)
|
OhTimePoint |
getTargetTime()
|
OhTimePoint |
getTerminalTime()
|
long |
getTimeStep()
|
boolean |
init(java.lang.String aObjName,
int aObjNum)
|
boolean |
init(java.lang.String aObjName,
int aObjNum,
int aNumOfObjs)
|
boolean |
init(java.lang.String aObjName,
int aObjNum,
int aNumOfObjs,
java.lang.String aDataStr)
|
boolean |
init(java.lang.String aObjName,
int aObjNum,
OhBufferedReader aBr)
|
boolean |
init(java.lang.String aObjName,
int aObjNum,
java.lang.String aDataStr)
|
void |
initializeTargetTime()
|
abstract boolean |
initialOutput()
|
boolean |
initialWork()
|
boolean |
isInitialTime(OhTimePoint aTp)
|
java.lang.Object[] |
makeObjectArray(int[] aNumOfObjs)
|
void |
printConnection()
|
void |
printConnection(java.io.PrintWriter aPw)
|
void |
printConnection(java.io.PrintWriter aPw,
java.lang.String aHead)
|
void |
printConnection(java.lang.String aHead)
|
void |
printObjects(java.io.PrintWriter aPw,
java.lang.String aHead,
java.lang.String aTitle,
java.lang.Object[] aPortArray,
int aNumOfObjs)
|
void |
printReceivePorts()
|
void |
printReceivePorts(java.io.PrintWriter aPw)
|
void |
printReceivePorts(java.io.PrintWriter aPw,
java.lang.String aHead)
|
void |
printReceivePorts(java.lang.String aHead)
|
void |
printSendPorts()
|
void |
printSendPorts(java.io.PrintWriter aPw)
|
void |
printSendPorts(java.io.PrintWriter aPw,
java.lang.String aHead)
|
void |
printSendPorts(java.lang.String aHead)
|
boolean |
printStatus()
Returns true. |
boolean |
recordStatus()
Records status. |
void |
reduceDataPackStock()
|
boolean |
register(java.lang.Object aObj)
|
boolean |
register(java.lang.Object aObj,
int aNum)
|
abstract void |
registerReceivePorts()
|
abstract void |
registerSendPorts()
|
void |
renewFixedTime()
|
void |
renewTargetTime(long aT)
|
void |
restoreSendPortStock()
|
void |
rewindCurrentTime()
|
void |
saveSendPortStock(java.io.PrintWriter aPw)
|
abstract void |
saveTerminalState(java.io.PrintWriter aPr)
|
void |
sendStockedData()
|
void |
setCur2Fix2Tar()
|
void |
setDataPackArray()
|
abstract void |
setInitialState(OhBufferedReader aBr)
|
abstract void |
setParameter(OhBufferedReader aBr)
|
void |
terminalState(java.io.PrintWriter aPw)
|
abstract boolean |
work()
|
boolean |
work0()
|
boolean |
work1()
|
boolean |
work2()
|
クラス 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 boolean _initialWorkDoneP
Whether the initial work has been completed or not.
protected boolean _shareInfoDoneP
Whether the "shareInfo" has been completed or not.
protected OhLinkedList _objectList
A list for storing Object. It is used as an object for work at the time of creation of "_receivePortArray" and "_sendPortArray".
protected java.lang.Object[] _receivePortArray
Array of "OhReceivePort".
protected int _numberOfReceivePorts
Number of receive ports.
protected java.lang.Object[] _sendPortArray
Array of "OhSendPort".
protected int _numberOfSendPorts
Number of send ports.
protected java.lang.Object[] _objectArray
Array of "OhObject".
protected int _numberOfObjects
Number of objects.
protected java.lang.String _dataString
Data string.
protected OhTimePoint _currentTime
Current(Calculated time) time. "OhTimePoint" is defined in "OhTimePoint.java".
protected long _timeStep
Time step.[sec]
protected OhTimePoint _fixedTime
Time which the state has decided in repeated calculation.
protected OhTimePoint _targetTime
(※注意※) 反復計算する要素では、計算開始時に _fixedTime, _targetTime を _currentTime と一致させる必要があります。 OhElement.setInitialState(OhBufferedReader) で _currentTime が初期設定された後、 OhElement.setCur2Fix2Tar() を呼ぶか、 直接 _targetTime = _fixedTime = _currentTime; としてください。
Repeated calculation target time. [sec]
It is necessary to make "_fixedTime" and "_targetTime" in agreement with "_currentTime" with the element which carries out repeated calculation at the time of a calculation start.
After initial setting of the "_currentTime" is carried out by "setInitialState()", call "void cur2fix2tar()" which the bottom defines or give as direct "_targetTime = _fixedTime = _currentTime;".
protected boolean _calReqP
Flag of request of calculation. Initial value is NO. When a cause incalculable although the lower-stream-of-a-river side tended to calculate is in this element, it is made to be set as "_calReqP = true". And, "OhElement" tries to calculate hard at the time of "_calReqP = true".
コンストラクタの詳細 |
public OhElement()
に設定します。
public OhElement(java.lang.String aObjName, int aObjNum, int aNumOfObjs, java.lang.String aStr) throws OhError
aObjName
- a String
valueaObjNum
- an int
valueaNumOfObjs
- an int
valueaStr
- a String
value
OhError
- if an error occurs
public OhElement(java.lang.String aObjName, int aObjNum, java.lang.String aStr) throws OhError
aObjName
- a String
valueaObjNum
- an int
valueaStr
- a String
value
OhError
- if an error occurs
メソッドの詳細 |
public abstract void registerReceivePorts() throws OhError
このメソッドは、派生クラスの全受信端子を 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); }
OhError
- if an error occurspublic abstract void registerSendPorts() throws OhError
このメソッドは、派生クラスの全送信端子を 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); }
OhError
- if an error occurspublic abstract void setParameter(OhBufferedReader aBr) throws OhError
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.
aBr
- a OhBufferedReader
value
OhError
- if an error occurspublic abstract void setInitialState(OhBufferedReader aBr) throws OhError
最終状態をファイルに保存するプログラムとつじつまがあうようにしてください。
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.
aBr
- a OhBufferedReader
value
OhError
- if an error occurspublic abstract boolean initialOutput() throws OhError
初期状態量を決めた直後に、_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.
boolean
value
OhError
- if an error occurspublic abstract long calculateTimeStep() throws OhError
各派生クラスでモデルに応じて _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.
long
value
OhError
- if an error occurspublic abstract boolean canYouCalculate() throws OhCannotGetDataError, OhError
まず、_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.
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic abstract boolean calculate() throws OhCannotGetDataError, OhError
各ユーザが独自の要素モデルを作成する際、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.
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic abstract boolean work() throws OhCannotGetDataError, OhError
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.
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic abstract void saveTerminalState(java.io.PrintWriter aPr)
最終状態を書き込む仕様は次のようにしてください。
(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.
aPr
- a PrintWriter
valuepublic boolean init(java.lang.String aObjName, int aObjNum, OhBufferedReader aBr) throws OhError
(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.
aObjName
- a String
valueaObjNum
- an int
valueaBr
- an OhBufferedReader
value
boolean
value
OhError
- if an error occurspublic boolean init(java.lang.String aObjName, int aObjNum, int aNumOfObjs, java.lang.String aDataStr) throws OhError
aObjName
- a String
valueaObjNum
- an int
valueaNumOfObjs
- an int
valueaDataStr
- a String
value
boolean
value
OhError
- if an error occurspublic boolean init(java.lang.String aObjName, int aObjNum, int aNumOfObjs) throws OhError
aObjName
- a String
valueaObjNum
- an int
valueaNumOfObjs
- an int
value
boolean
value
OhError
- if an error occurspublic boolean init(java.lang.String aObjName, int aObjNum, java.lang.String aDataStr) throws OhError
aObjName
- a String
valueaObjNum
- an int
valueaDataStr
- a String
value
boolean
value
OhError
- if an error occurspublic boolean init(java.lang.String aObjName, int aObjNum) throws OhError
OhObject
内の init
aObjName
- a String
valueaObjNum
- an int
value
boolean
value
OhError
- if an error occurspublic java.lang.Object getFromList(java.lang.String aClassName, java.lang.String aObjName, int aObjNum) throws OhError
このメソッドは、クラス名, オブジェクト名, オブジェクト番号を指定して、 _objectList から Object 型オブジェクトを取得します。
指定されたオブジェクトが登録されていない場合は null を返します。
_objectList が null の場合は、エラーメッセージを表示し、null を返します。
[ARGUMENT] ・aClassName - 取得するオブジェクトのクラス名 ・aObjName --- 取得するオブジェクトのオブジェクト名 ・aObjNum ---- 取得するオブジェクトのオブジェクト番号 [RETURN] ・Object ----- Object 型にキャストされた指定オブジェクト ・null ------- 指定オブジェクトを発見できない場合 _objectList が存在しない場合 [ACCIDENT] ・Object 型以外の変数が object_list に収録されている場合
Finds an object with class name 'aClassName', object name 'aObjName', and object number 'aObjNum' from "_objectList" and returns the object. When such an object could not be found from "_objectList", "null" will be returned.
aClassName
- a String
valueaObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurspublic java.lang.Object getFromList(java.lang.String aObjName, int aObjNum) throws OhError
aObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurspublic boolean register(java.lang.Object aObj) throws OhError
引数の Object 型オブジェクト "aObj" を _objectList に登録します。 同時に、このメソッドを呼び出したオブジェクト(this)が "aObj" の _owner となるように設定されます。
登録にあたり、次の場合はエラーメッセージを出力後 false を返します。
[ARGUMENT] ・aObj --- Object 型にキャストされた登録オブジェクト。 [RETURN] ・true --> 正常に登録された場合。 ・false -> aObj が null の場合。 object_list が NULL の場合。(配列化済み?) aObj と、 クラス名、 オブジェクト名、 オブジェクト番号が全て一致するオブジェクトが既に _objectList に登録されている場合。 aObj の _owner が設定済みの場合。(OhObject.setOwner()) [ACCIDENT] ・aObj に OhObject 型以外の変数が格納されている場合。 ・_objectList に OhObject 型以外の変数が収録されている場合。
Registers an object 'aObj' to the data member '_objectList'.
aObj
- an Object
value
boolean
value
OhError
- if an error occurspublic java.lang.Object[] makeObjectArray(int[] aNumOfObjs) throws OhError
_objectList が null を指している場合、エラーメッセージを表示します。
また、引数 aNumOfObjs[0] が 0 以上の場合は、既に配列を作成済みと判断し、 エラーメッセージを表示します。 配列化後、_numOfObjs[0] は 0 以上に設定されます。 従って、配列設定前には _numOfObjs[0] は 0 未満に初期化しておいて下さい。
_numberOfReceivePort, _numberOfSendPort は、コンストラクタで -1 に初期化されます。
[in] aNumOfObjs[0] - _objectList の要素数(_numberOfObjects) [RETURN] _objectList を配列化した Object 型配列
Creates an array of objects which are included in '_objectList' and stores it in '_aObjArray' and the number of elements in 'aNumOfObjs'.
aNumOfObjs
- an int[]
value
Object[]
value
OhError
- if an error occurspublic boolean canYouSetObjectArray(int aNumOfObjs) throws OhError
また、
・aNumOfObjs (arg) が負の場合。 ・_numberOfObjects が 0 以上の場合。(作成済み)の場合はエラーメッセージを出力後 false を返します。
[ARGUMENT] ・aNumOfObjs -> _objectArray に記憶するオブジェクト数。 [RETURN] ・true --> _objectArray が確保できた場合。 ・false -> aNumOfObjs が負の場合、または _numberOfObjects が 0 以上の場合。(作成済み)
Acquire the memory to store "aNumOfObjs" objects.
aNumOfObjs
- an int
value
boolean
value
OhError
- if an error occurspublic boolean register(java.lang.Object aObj, int aNum) throws OhError
Registers the object "aObj" with which the current object communicates directly to object_array[num].
aObj
- an Object
valueaNum
- an int
value
boolean
value
OhError
- if an error occurspublic boolean construct() throws OhError
まず、_objectList が null であることを確認します。 null でない場合、_objectList が使用中と判断してエラーメッセージを表示し、return します。
次に、以下の作業を実行します。
Makes "_receivePortArray" and "_sendPortArray".
boolean
value
OhError
- if an error occurspublic java.lang.Object getFromArray(java.lang.String aClassName, java.lang.String aObjName, int aObjNum, java.lang.Object[] aObjArray, int aNumOfObjs)
getReceivePort(), getSendPort(), getObject() で用いられる補助メソッドの役割を担う。
Finds an object with class name 'aClassName', object name 'aObjName', and object number 'aObjNum' from 'aObjArray' and returns the object.
aClassName
- a String
valueaObjName
- a String
valueaObjNum
- an int
valueaObjArray
- an Object[]
valueaNumOfObjs
- an int
value
Object
valuepublic java.lang.Object getFromArray(java.lang.String aObjName, int aObjNum, java.lang.Object[] aObjArray, int aNumOfObjs)
getReceivePort(), getSendPort(), getObject() で用いられる補助メソッドの役割を担う。
Finds an object with object name 'aObjName', and object number 'aObjNum' from 'aObjArray' and returns the object.
aObjName
- a String
valueaObjNum
- an int
valueaObjArray
- an Object[]
valueaNumOfObjs
- an int
value
Object
valuepublic java.lang.Object getReceivePort(java.lang.String aClassName, java.lang.String aObjName, int aObjNum) throws OhError
クラス名、オブジェクト名、オブジェクト番号を指定することにより、 _receivePortArray から受信端子を取得します。 指定されたオブジェクトが登録されていない場合は null を返します。
By appointing class name, object name, and object number, acquires a receiving port from "_receivePortArray".
When the appointed object is not registered, "null" is returned.
aClassName
- a String
valueaObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurspublic java.lang.Object getReceivePort(java.lang.String aClassName, java.lang.String aObjName) throws OhError
クラス名、オブジェクト名を指定することにより、 _receivePortArray から受信端子を取得します。 指定されたオブジェクトが登録されていない場合は null を返します。
By appointing class name and object name, acquires a receiving port from "_receivePortArray". At this time, the object number is set to 0.
When the appointed object is not registered, "null" is returned.
aClassName
- a String
valueaObjName
- a String
value
Object
value
OhError
- if an error occurspublic java.lang.Object getSendPort(java.lang.String aClassName, java.lang.String aObjName, int aObjNum) throws OhError
クラス名、オブジェクト名、オブジェクト番号を指定することにより、 _sendPortArray から送信端子を取得します。 指定されたオブジェクトが登録されていない場合は null を返します。
By appointing class name, object name, and object number, acquires a sending port from "_sendPortArray".
When the appointed object is not registered, "null" is returned.
aClassName
- a String
valueaObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurspublic java.lang.Object getSendPort(java.lang.String aClassName, java.lang.String aObjName) throws OhError
クラス名、オブジェクト名を指定することにより、 _sendPortArray から送信端子を取得します。 指定されたオブジェクトが登録されていない場合は null を返します。
By appointing class name and object name, acquires a sending port from "_sendPortArray". At this time, the object number set to 0.
When the appointed object is not registered, "null" is returned.
aClassName
- a String
valueaObjName
- a String
value
Object
value
OhError
- if an error occurspublic java.lang.Object getReceivePort(java.lang.String aObjName, int aObjNum) throws OhError
オブジェクト名、オブジェクト番号を指定することにより、 _receivePortArray から受信端子を取得します。 指定されたオブジェクトが登録されていない場合は null を返します。
By appointing object name and object number, acquires a receiving port from "_receivePortArray".
When the appointed object is not registered, "null" is returned.
aObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurspublic java.lang.Object getReceivePort(java.lang.String aObjName) throws OhError
オブジェクト名を指定することにより、 _receivePortArray から受信端子を取得します。 指定されたオブジェクトが登録されていない場合は null を返します。
By appointing object name, acquires a receiving port from "_receivePortArray". At this time, the object number is set to 0.
When the appointed object is not registered, "null" is returned.
aObjName
- a String
value
Object
value
OhError
- if an error occurspublic java.lang.Object getSendPort(java.lang.String aObjName, int aObjNum) throws OhError
オブジェクト名、オブジェクト番号を指定することにより、 _sendPortArray から送信端子を取得します。 指定されたオブジェクトが登録されていない場合は null を返します。
By appointing object name and object number, acquires a sending port from "_sendPortArray".
When the appointed object is not registered, "null" is returned.
aObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurspublic java.lang.Object getSendPort(java.lang.String aObjName) throws OhError
オブジェクト名を指定することにより、 _sendPortArray から送信端子を取得します。 指定されたオブジェクトが登録されていない場合は null を返します。
By appointing object name, acquires a sending port from "_sendPortArray". At this time, the object number is set to 0.
When the appointed object is not registered, "null" is returned.
aObjName
- a String
value
Object
value
OhError
- if an error occurspublic java.lang.Object getObject(java.lang.String aClassName, java.lang.String aObjName, int aObjNum) throws OhError
指定されたオブジェクトが登録されていない場合は null を返します。
acquires a object.
When the appointed object is not registered, "null" is returned.
aClassName
- a String
valueaObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurspublic java.lang.Object getObject(java.lang.String aClassName, java.lang.String aObjName) throws OhError
指定されたオブジェクトが登録されていない場合は null を返します。
acquires a object. At this time, the object number is set to 0.
When the appointed object is not registered, "null" is returned.
aClassName
- a String
valueaObjName
- a String
value
Object
value
OhError
- if an error occurspublic java.lang.Object getComponent(java.lang.String aClassName, java.lang.String aObjName, int aObjNum) throws OhError
クラス名、オブジェクト名、オブジェクト番号を指定して、_objectArray から構成要素を取得します。 OhElement クラスは最小単位である要素なので、構成要素は持っていません。 ここでは必ずエラー処理を行なうようにしています。 派生クラスである OhSubSystem, OhTotalSystem でオーバーライドされます。 この OhElement クラスを継承して新たにクラスを作るユーザが実装しなくてもいいように、 抽象メソッドにしていません。
Acquires a composition object.
aClassName
- a String
valueaObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurs
OhError
- if an error occurspublic java.lang.Object getComponent(java.lang.String aClassName, java.lang.String aObjName) throws OhError
クラス名、オブジェクト名を指定して、_objectArray から構成要素を取得します。 オブジェクト番号は 0 になります。 OhElement クラスは最小単位である要素なので、構成要素は持っていません。 ここでは必ずエラー処理を行なうようにしています。 派生クラスである OhSubSystem, OhTotalSystem でオーバーライドされます。 この OhElement クラスを継承して新たにクラスを作るユーザが実装しなくてもいいように、 抽象メソッドにしていません。
Acquires a composition object. At this time, the object number is set to 0.
aClassName
- a String
valueaObjName
- a String
value
Object
value
OhError
- if an error occurspublic java.lang.Object getComponent(java.lang.String aObjName, int aObjNum) throws OhError
オブジェクト名、オブジェクト番号を指定して、_objectArray から構成要素を取得します。 OhElement クラスは最小単位である要素なので、構成要素は持っていません。 ここでは必ずエラー処理を行なうようにしています。 派生クラスである OhSubSystem, OhTotalSystem でオーバーライドされます。 この OhElement クラスを継承して新たにクラスを作るユーザが実装しなくてもいいように、 抽象メソッドにしていません。
Acquires a composition object.
aObjName
- a String
valueaObjNum
- an int
value
Object
value
OhError
- if an error occurspublic java.lang.Object getComponent(java.lang.String aObjName) throws OhError
オブジェクト名を指定して、_objectArray から構成要素を取得します。 OhElement クラスは最小単位である要素なので、構成要素は持っていません。 ここでは必ずエラー処理を行なうようにしています。 派生クラスである OhSubSystem, OhTotalSystem でオーバーライドされます。 この OhElement クラスを継承して新たにクラスを作るユーザが実装しなくてもいいように、 抽象メソッドにしていません。
Acquires a composition object. At this time, the object number is set to 0.
aObjName
- a String
value
Object
value
OhError
- if an error occurspublic boolean canYouSwitch() throws OhError
具体的には、以下を実行します。
[RETURN] ・true --> 正常に実行できた場合。 ・false -> OhSendPort.canYouSwitch() で false を返す送信端子が存在する場合(既に OhSendPort.canYouSwitch() が実行されている場合)。
OhSendPort.canYouSwitch() is performed with all possession sending ports.
boolean
value
OhError
- if an error occurspublic boolean areYouReady() throws OhError
受信端子、送信端子がデータパックを送受信可能な状態であることを確認します。
全受信端子の OhReceivePort.areYouReady の戻り値、及び全送信端子の OhSendPort.areYouReady の 戻り値が true であることを確認します。 戻り値が false の端子が存在する場合は false を返し、存在しない場合は true を返します。
このメソッドの戻り値が true の場合、OhElement は計算を実行できます。
false の場合は、データパックを受信できない受信端子、 またはデータパックを送信できない送信端子が存在し、 この OhElement, 送信先の Element で計算を実行できません。
この場合、接続作業に誤りがあるか、OhSendPort に canYouSwitch() を実行していない可能性があります。
[RETURN] ・true --> 全端子の areYouReady の戻り値が true の場合。 ・false -> 戻り値が false の端子が存在する場合。
Checks before calculation work.
Checks to see sending ports and receiving ports are in the state which can send and receive the data packs.
boolean
value
OhError
- if an error occurspublic boolean canYouGetDataString(java.lang.String aDataStr) throws OhError
クラス OhElement の String 型の引数つき init() で呼び出されます。
Gets the data string.
aDataStr
- a String
value
boolean
value
OhError
- if an error occurspublic void clearDataString()
Clear the data string.
public void getParameter(OhBufferedReader aBr) throws OhError
Gets the parameter.
aBr
- an OhBufferedReader
value
OhError
- if an error occurspublic void getInitialState(OhBufferedReader aBr) throws OhError
Gets the initial state.
aBr
- an OhBufferedReader
value
OhError
- if an error occurspublic boolean canYouShareInfo()
This is a method for sharing information, such as a parameter, using direct communication.
boolean
valuepublic OperationFlag doShareInfo() throws OhError
doShareInfo() は、
canYouShareInfo() がまだなされていない場合、
This is the method which calls 'canYouShareInfo()'.
OperationFlag
value
OhError
- if an error occurspublic void saveSendPortStock(java.io.PrintWriter aPw)
OhSubSystem では再定義されます。
The data pack recorded on the data of all the sending ports connected to the element is written out to the file specified by stream 'aPw'. Work of inclusion is performed using method 'saveSendPortStock' of the same name of a sending port.
This method is re-defined by 'OhSubSystem'.
aPw
- a PrintWriter
valuepublic void restoreSendPortStock() throws OhError
The data character sequence '_dataString' is read and data is recorded on the sending port connected to the element.
OhError
- if an error occurspublic OhTimePoint getCurrentTime()
Returns '_currentTime'.
OhTimePoint
valuepublic long getTimeStep()
Returns '_timeStep'.
long
valuepublic OhTimePoint getNextTime()
OhTimePoint
valuepublic OhTimePoint getTerminalTime()
OhTimePoint
valuepublic OhTimePoint getMediumTermTargetTime()
Returns the medium term target time from '_owner'.
OhTimePoint
valuepublic OhTimePoint getFixedTime()
Returns '_fixedTime'.
OhTimePoint
valuepublic OhTimePoint getTargetTime()
Returns '_targetTime'.
OhTimePoint
valuepublic void setCur2Fix2Tar()
public boolean canYouRenewCurrentTime()
boolean
valuepublic void rewindCurrentTime() throws OhError
OhError
- if an error occurspublic void renewFixedTime() throws OhError
Updates '_fixedTime'.
OhError
- if an error occurspublic void initializeTargetTime() throws OhError
This method is not used by OhElement. It uses re-defining by OhSubSystem. The reason for having defined this method is that it is necessary to call this method on principle also to the OhElement type composition element.
OhError
public void renewTargetTime(long aT)
aT
- a long
value. Repeated calculation time interval.public long calculateIterationStep() throws OhError
Calculates repeated calculation target time.
long
value
OhError
public OhTimePoint getNecessaryTimeFrom(OhReceivePort aRp)
getNecessaryTimeFrom() から getNecessaryTimeTo() までのデータパックが 受信端子 aRp から受信されていなければ、要素は計算を開始することができません。
Returns the data record time of the data which 'OhElement' should receive from 'aRp' out of data required for next calculation.
'OhElement' cannot start calculation if the data pack from 'getNecessaryTimeFrom' to 'getNecessaryTimeTo' is not received from the receiving terminal 'aRp', 'OhElement' cannot start calculation.
aRp
- an OhReceivePort
value
OhTimePoint
valuepublic OhTimePoint getNecessaryTimeTo(OhReceivePort aRp)
getNecessaryTimeFrom() から getNecessaryTimeTo() までのデータパックが 受信端子 aRp から受信されていなければ、要素は計算を開始することができません。
Returns the data record time of the data which 'OhElement' should receive from 'aRp' out of data required for next calculation.
'OhElement' cannot start calculation if the data pack from 'getNecessaryTimeFrom' to 'getNecessaryTimeTo' is not received from the receiving terminal 'aRp', 'OhElement' cannot start calculation.
aRp
- an OhReceivePort
value
OhTimePoint
valuepublic boolean isInitialTime(OhTimePoint aTp) throws OhError
'_currentTime' and '_timeStep'of OhElement
are initialized to 'aTp' and 0,
and returns 'true'.
aTp
- an OhTimePoint
value
boolean
value
OhError
- if an error occurspublic boolean initialWork() throws OhError
初期時刻において、全データを取得します。
boolean
value
OhError
- if an error occurspublic OperationFlag doInitialWork() throws OhError
【初期作業がまだなされていない場合】
OperationFlag
value
OhError
- if an error occurspublic boolean canYouCalculate0() throws OhCannotGetDataError, OhError
getNecessaryTimeFrom(), getNecessaryTimeTo() で定義される時間の間の データが取得できれば計算可能と判断する。 これを選ぶのが自然です。 getNecessaryTimeFrom(), getNecessaryTimeTo() メソッドは、 ユーザが自由に再定義できますが、デフォルトでは getNecessaryTimeFrom() は _currentTime を返し、 getNecessaryTimeTo は _currentTime + _timeStep の値を返します。
データが取得不可能であると返事をしてきた受信端子に対して計算要求を出します。 具体的には、受信端子に calReq() メッセージを送ります。 たとえば、
public boolean canYouCalculate() { return canYouCalculate0(); }と定義すればよいです。
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic boolean canYouCalculate1() throws OhCannotGetDataError, OhError
getNecessaryTimeFrom() で定義されるデータが取得できれば計算可能と判断します。 (この場合は getNecessaryTimeTo() メソッドを定義する意味はありません。)
データが取得不可能であると返事をしてきた受信端子に対して計算要求を出します。 具体的には、受信端子に calReq() メッセージを送ります。
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic void setDataPackArray()
全ての所有送信端子に OhSendPort.setDataPackArray() を用い、 送信データパック配列を更新します。
これにより、古いデータパック配列は消去され、新しいデータパック配列が作成されます。
Sends data packs.
'OhSendPort setDataPackArray' is used for all possession sending ports, and sending data pack arrangement is updated. Thereby, old data pack arrangement is eliminated and new data pack arrangement is created.
But, nothing is carried out in fact.
public void reduceDataPackStock()
全ての所有受信端子に OhReceivePort.reduceDataPackStock() を用い、 受信元送信端子に計算終了報告を行ないます。
これにより、受信元送信端子で不要データパックが消去され、データパック配列が更新されます。
Deletion of an unnecessary datapacks.
public boolean printStatus()
boolean
valuepublic boolean recordStatus() throws OhError
boolean
value
OhError
- if an error occurspublic boolean work0() throws OhCannotGetDataError, OhError
_timeStep を得てから、calculate() を実行する。
'Work' which performs 'calculate()' after obtaining '_timeStep'.
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic boolean work1() throws OhCannotGetDataError, OhError
_timeStep は、calculate() の内部で計算される。
'_timeStep' is calculated inside 'calculate()'.
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic boolean work2() throws OhCannotGetDataError, OhError
For the element which carries out repeated calculation.
boolean
value
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic boolean doYouReachTargetTime()
This method judges whether repeated calculation reached '_targetTime'.
boolean
valuepublic boolean doYouConverge() throws OhError
Convergence of the repeated calculation between elements is judged. Please be sure to re-define by the element which performs repeated calculation. In the method, please return 'true' if it converges. When not giving a re-definition, an error message is sent, and it exits.
boolean
value
OhError
public void flushData() throws OhError
It is the method which carries out output of the data by repetitive target time, and processing of a data pack.
OhError
public void sendStockedData() throws OhError
It is the method which outputs the data which accumulated by repetitive target time. For example, please use 'OhSendDouble sendData(OhTimePoint aT, double aValue)'.
Please be sure to re-define by the element which performs repeated calculation. When not giving a re-definition, an error message is sent, and it exits.
OhError
public void calReq() throws OhCannotGetDataError, OhError
メソッド canYouCalculate() を実行した後で、 この要素への計算要請があったことを記録します。 この要素の work() でこの要請を考慮します。
このメソッドは、この要素の送信端子から呼ばれます。 部分系では、このメソッドが呼ばれることはありません。 中継端子は、計算要求を送信端子に転送するだけで、 中継端子の所有者である部分系には計算要求を送らないからです。
ここの定義が不適切である場合は、継承したクラスで再定義してください。
OhCannotGetDataError
- if an error occurs
OhError
- if an error occurspublic void printObjects(java.io.PrintWriter aPw, java.lang.String aHead, java.lang.String aTitle, java.lang.Object[] aPortArray, int aNumOfObjs)
Information output on possession objects.
aPw
- a PrintWriter
valueaHead
- a String
valueaTitle
- a String
valueaPortArray
- an Object[]
valueaNumOfObjs
- an int
valuepublic void printReceivePorts(java.io.PrintWriter aPw, java.lang.String aHead)
Information output on possession receiving ports.
public void printReceivePorts(java.io.PrintWriter aPw)
Information output on possession receiving ports.
public void printReceivePorts(java.lang.String aHead)
Information output on possession receiving ports.
public void printReceivePorts()
Information output on possession receiving ports.
public void printSendPorts(java.io.PrintWriter aPw, java.lang.String aHead)
Information output on possession sending ports.
public void printSendPorts(java.io.PrintWriter aPw)
Information output on possession sending ports.
public void printSendPorts(java.lang.String aHead)
Information output on possession sending ports.
public void printSendPorts()
Information output on possession sending ports.
public void printConnection(java.io.PrintWriter aPw, java.lang.String aHead)
Information output on connection.
public void printConnection(java.io.PrintWriter aPw)
Information output on connection. At this time, the header is " ".
public void printConnection(java.lang.String aHead)
Information output on connection.
public void printConnection()
Information output on connection.
public void terminalState(java.io.PrintWriter aPw)
aPw
- a PrintWriter
valuepublic static OhElement create(java.lang.String aClassName)
引数に、水文モデルの要素となるモデルを表すクラス名を与えると、 その要素モデルのオブジェクトを生成します。
aClassName
- a String
value
OhElement
value
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |