亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? doublelinereader.java

?? ptolemyModel嵌入式系統建模實例代碼
?? JAVA
字號:
/* An actor that outputs strings read from a text file or URL.

@Copyright (c) 2002-2003 The Regents of the University of California.
All rights reserved.

Permission is hereby granted, without written agreement and without
license or royalty fees, to use, copy, modify, and distribute this
software and its documentation for any purpose, provided that the
above copyright notice and the following two paragraphs appear in all
copies of this software.

IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
ENHANCEMENTS, OR MODIFICATIONS.

                                                PT_COPYRIGHT_VERSION 2
                                                COPYRIGHTENDKEY
@ProposedRating Green (eal@eecs.berkeley.edu)
@AcceptedRating Yellow (cxh@eecs.berkeley.edu)
*/

package ptolemy.actor.lib.io;

import ptolemy.actor.TypedIOPort;
import ptolemy.actor.lib.Source;
import ptolemy.data.BooleanToken;
import ptolemy.data.IntToken;
import ptolemy.data.DoubleToken;
import ptolemy.data.StringToken;
import ptolemy.data.Token;
import ptolemy.data.expr.Parameter;
import ptolemy.data.type.BaseType;
import ptolemy.kernel.CompositeEntity;
import ptolemy.kernel.attributes.FileAttribute;
import ptolemy.kernel.util.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URL;

//////////////////////////////////////////////////////////////////////////
//// DoubleLineReader
/**
This actor reads a file or URL, one line at a time, and outputs each line
as a string.  The file or URL is specified using any form acceptable
to FileAttribute. Before an end of file is reached, the <i>endOfFile</i>
output produces <i>false</i>.  In the iteration where the last line
of the file is read and produced on the <i>output</i> port, this actor
produces <i>true</i> on the <i>endOfFile</i> port. In that iteration,
postfire() returns false.  If the actor is iterated again, after the end
of file, then prefire() and postfire() will both return false, <i>output</i>
will produce the string "EOF", and <i>endOfFile</i> will produce <i>true</i>.
<p>
In some domains (such as SDF), returning false in postfire()
causes the model to cease executing.
In other domains (such as DE), this causes the director to avoid
further firings of this actor.  So usually, the actor will not be
invoked again after the end of file is reached.
<p>
This actor reads ahead in the file so that it can produce an output
<i>true</i> on <i>endOfFile</i> in the same iteration where it outputs
the last line.  It reads the first line in preinitialize(), and
subsequently reads a new line in each invocation of postfire().  The
line read is produced on the <i>output</i> in the next iteration
after it is read.
<p>
This actor can skip some lines at the beginning of the file or URL, with
the number specified by the <i>numberOfLinesToSkip</i> parameter. The
default value of this parameter is 0.
<p>
If you need to reset this line reader to start again at the beginning
of the file, the way to do this is to call initialize() during the run
of the model.  This can be done, for example, using a modal model
with a transition where reset is enabled.

@see FileAttribute
@author  Edward A. Lee, Yuhong Xiong
@version $Id: DoubleLineReader.java,v 1.12 2003/04/11 23:55:19 cxh Exp $
@since Ptolemy II 2.2
*/
public class DoubleLineReader extends Source {

    /** Construct an actor with the given container and name.
     *  @param container The container.
     *  @param name The name of this actor.
     *  @exception IllegalActionException If the actor cannot be contained
     *   by the proposed container.
     *  @exception NameDuplicationException If the container already has an
     *   actor with this name.
     */
    public DoubleLineReader(CompositeEntity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);

        output.setTypeEquals(BaseType.STRING);

        endOfFile = new TypedIOPort(this, "endOfFile", false, true);
        endOfFile.setTypeEquals(BaseType.BOOLEAN);

        fileOrURL = new FileAttribute(this, "fileOrURL");

        numberOfLinesToSkip = new Parameter(this, "numberOfLinesToSkip",
                new IntToken(0));
        numberOfLinesToSkip.setTypeEquals(BaseType.INT);

        _attachText("_iconDescription", "<svg>\n"
                + "<rect x=\"-25\" y=\"-20\" "
                + "width=\"50\" height=\"40\" "
                + "style=\"fill:white\"/>\n"
                + "<polygon points=\"-15,-10 -12,-10 -8,-14 -1,-14 3,-10"
                + " 15,-10 15,10, -15,10\" "
                + "style=\"fill:red\"/>\n"
                + "</svg>\n");
    }

    ///////////////////////////////////////////////////////////////////
    ////                     ports and parameters                  ////

    /** An output port that produces <i>false</i> until the end of file
     *  is reached, at which point it produces <i>true</i>. The type
     *  is boolean.
     */
    public TypedIOPort endOfFile;

    /** The file name or URL from which to read.  This is a string with
     *  any form accepted by FileAttribute.
     *  @see FileAttribute
     */
    public FileAttribute fileOrURL;

    /** The number of lines to skip at the beginning of the file or URL.
     *  This parameter contains an IntToken, initially with value 0.
     *  The value of this parameter must be non-negative.
     */
    public Parameter numberOfLinesToSkip;

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    /** If the specified attribute is <i>fileOrURL</i> and there is an
     *  open file being read, then close that file and open the new one;
     *  if the attribute is <i>numberOfLinesToSkip</i> and its value is
     *  negative, then throw an exception.  In the case of <i>fileOrURL</i>,
     *  do nothing if the file name is the same as the previous value of
     *  this attribute.
     *  @param attribute The attribute that has changed.
     *  @exception IllegalActionException If the specified attribute
     *   is <i>fileOrURL</i> and the file cannot be opened, or the previously
     *   opened file cannot be closed; or if the attribute is
     *   <i>numberOfLinesToSkip</i> and its value is negative.
     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == fileOrURL) {
            // NOTE: We do not want to close the file if the file
            // has not in fact changed.  We check this by just comparing
            // name, which is not perfect...
            if (_previousFileOrURL != null
                    && !fileOrURL.getExpression().equals(_previousFileOrURL)) {
                _previousFileOrURL = fileOrURL.getExpression();
                fileOrURL.close();
                // Ignore if the fileOrUL is blank.
                if (fileOrURL.getExpression().trim().equals("")) {
                    _reader = null;
                } else {
                    _reader = fileOrURL.openForReading();
                }
                _reachedEOF = false;
            }
        } else if (attribute == numberOfLinesToSkip) {
            int linesToSkip =
                ((IntToken)numberOfLinesToSkip.getToken()).intValue();
            if (linesToSkip < 0) {
                throw new IllegalActionException(this, "The number of lines "
                        + "to skip cannot be negative.");
            }
        } else {
            super.attributeChanged(attribute);
        }
    }

    /** Clone the actor into the specified workspace.
     *  @return A new actor.
     *  @exception CloneNotSupportedException If a derived class contains
     *   an attribute that cannot be cloned.
     */
    public Object clone(Workspace workspace)
            throws CloneNotSupportedException {
        DoubleLineReader newObject = (DoubleLineReader)super.clone(workspace);
        newObject._currentLine = null;
        newObject._reachedEOF = false;
        newObject._reader = null;
        return newObject;
    }

    /** Output the data read in the preinitialize() or in the previous
     *  invocation of postfire(), if there is any.
     *  @exception IllegalActionException If there's no director.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        if (_currentLine != null) {
            output.broadcast(new DoubleToken(_currentLine));
        }
    }

    /** If this is called after prefire() has been called but before
     *  wrapup() has been called, then close any
     *  open file re-open it, skip the number of lines given by the
     *  <i>numberOfLinesToSkip</i> parameter, and read the first line to
     *  be produced in the next invocation of prefire(). This occurs if
     *  this actor is re-initialized during a run of the model.
     *  @exception IllegalActionException If the file or URL cannot be
     *   opened, or if the lines to be skipped and the first line to be
     *   sent out in the fire() method cannot be read.
     */
    public void initialize() throws IllegalActionException {
        super.initialize();
        if (_firedSinceWrapup) {
            // It would be better if there were a way to reset the
            // input stream, but apparently there is not, short of
            // closing it and reopening it.
            fileOrURL.close();
            _reader = null;
            _openAndReadFirstLine();
        }
    }

    /** Read the next line from the file. If there is no next line,
     *  return false.  Otherwise, return whatever the superclass returns.
     *  @exception IllegalActionException If there is a problem reading
     *   the file.
     */
    public boolean postfire() throws IllegalActionException {
        if (_reader == null) {
            return false;
        }
        try {
            _currentLine = _reader.readDouble();//讀取浮點數
            if (_currentLine == null) {
                // In case the return value gets ignored by the domain:
                _currentLine = 0.0;
                _reachedEOF = true;
                endOfFile.broadcast(BooleanToken.TRUE);
                return false;
            }
            endOfFile.broadcast(BooleanToken.FALSE);
            return super.postfire();
        } catch (IOException ex) {
            throw new IllegalActionException(this, ex, "Postfire failed");
        }
    }

    /** Return false if there is no more data available in the file.
     *  Otherwise, return whatever the superclass returns.
     *  @exception IllegalActionException If the superclass throws it.
     */
    public boolean prefire() throws IllegalActionException {
        _firedSinceWrapup = true;
        if (_reachedEOF) return false;
        else return super.prefire();
    }

    /** Open the file or URL, skip the number of lines specified by the
     *  <i>numberOfLinesToSkip</i> parameter, and read the first line to
     *  be sent out in the fire() method.
     *  This is done in preinitialize() so
     *  that derived classes can extract information from the file
     *  that affects information used in type resolution or scheduling.
     *  @exception IllegalActionException If the file or URL cannot be
     *   opened, or if the lines to be skipped and the first line to be
     *   sent out in the fire() method cannot be read.
     */
    public void preinitialize() throws IllegalActionException {
        super.preinitialize();
        _openAndReadFirstLine();
    }

    /** Close the reader if there is one.
     *  @exception IllegalActionException If an IO error occurs.
     */
    public void wrapup() throws IllegalActionException {
        fileOrURL.close();
        _reader = null;
        _firedSinceWrapup = false;
    }

    ///////////////////////////////////////////////////////////////////
    ////                         protected members                 ////

    /** Cache of most recently read data. */
    protected Double _currentLine;

    /** The current reader for the input file. */
    protected BufferedReader _reader;

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////

    /** Open the file and read the first line.
     */
    private void _openAndReadFirstLine() throws IllegalActionException {
        _reader = fileOrURL.openForReading();
        _reachedEOF = false;
        try {
            // Read (numberOfLinesToSkip + 1) lines
            int numberOfLines =
                ((IntToken)numberOfLinesToSkip.getToken()).intValue();
            for (int i = 0; i <= numberOfLines; i++) {
                _currentLine = _reader.readDouble();
                if (_currentLine == null) {
                    throw new IllegalActionException(this, "The file does not "
                            + "have enough lines.");
                }
            }
        } catch (IOException ex) {
            throw new IllegalActionException(this, ex,
                    "Preinitialize failed.");
        }
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private members                   ////

    /** Indicator that the fire() method has been called, but wrapup
     *  has not.  That is, we are in the middle of a run.
     */
    private boolean _firedSinceWrapup = false;

    /** Previous value of fileOrURL parameter. */
    private String _previousFileOrURL;

    /** Indicator that we have reached the end of file. */
    private boolean _reachedEOF = false;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品一区二区三区视频播放 | 国产69精品久久99不卡| 久久久久久一级片| 在线免费观看日韩欧美| 国产在线视频不卡二| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 欧美精选在线播放| 成人动漫av在线| 久久国产精品72免费观看| 亚洲色图欧洲色图婷婷| 精品理论电影在线| 欧美日韩亚洲综合一区| 成人黄色一级视频| 国内外成人在线| 全部av―极品视觉盛宴亚洲| 亚洲麻豆国产自偷在线| 久久综合九色综合欧美98| 欧美日韩精品免费观看视频 | 91精品蜜臀在线一区尤物| 成人av免费网站| 国产伦精一区二区三区| 日韩激情av在线| 亚洲一二三四区不卡| 国产精品污网站| 久久综合99re88久久爱| 欧美一级片在线看| 欧美影院一区二区| 99久久99精品久久久久久| 国产成人综合亚洲网站| 国产在线精品一区二区三区不卡| 视频一区视频二区中文字幕| 亚洲一卡二卡三卡四卡无卡久久| 亚洲美女在线一区| 国产精品美女久久久久av爽李琼 | 三级成人在线视频| 一区二区三区成人| 亚洲欧美偷拍卡通变态| 亚洲色欲色欲www| 亚洲你懂的在线视频| 1区2区3区精品视频| 国产精品家庭影院| 国产精品沙发午睡系列990531| 久久精品一区二区三区不卡牛牛 | 亚洲va欧美va人人爽| 亚洲精品国产高清久久伦理二区| 亚洲男人天堂av网| 一区二区三区在线观看动漫| 一区二区三区毛片| 亚洲成人动漫在线免费观看| 日韩精品久久理论片| 日韩—二三区免费观看av| 免费观看久久久4p| 精品一区免费av| 国产成人小视频| 成人av在线观| 91福利在线播放| 欧美日韩国产另类一区| 日韩欧美国产综合| 久久精品综合网| 日韩码欧中文字| 亚洲午夜视频在线| 另类小说一区二区三区| 国产一区免费电影| 成人免费视频caoporn| 日本国产一区二区| 91精品国产入口在线| 久久一区二区三区四区| 国产精品久久久久久一区二区三区| 日韩伦理av电影| 午夜精品视频在线观看| 麻豆91免费看| 大陆成人av片| 欧美欧美午夜aⅴ在线观看| 欧美一级日韩不卡播放免费| 国产清纯美女被跳蛋高潮一区二区久久w| 国产精品短视频| 日韩国产在线一| 国产不卡免费视频| 在线观看国产91| 亚洲精品一区二区三区蜜桃下载| 欧美国产国产综合| 亚洲成人av一区二区三区| 国产一区二区三区免费看| 91在线视频观看| 日韩一区二区三区在线观看 | 久久久久久电影| 日韩毛片视频在线看| 欧美a级理论片| av一本久道久久综合久久鬼色| 欧美日韩免费观看一区三区| 久久综合成人精品亚洲另类欧美| 亚洲人成人一区二区在线观看| 日产国产高清一区二区三区| 99久久久免费精品国产一区二区| 在线不卡中文字幕| 国产精品另类一区| 免费观看日韩av| 色婷婷av一区二区三区大白胸| 26uuu色噜噜精品一区二区| 亚洲黄色片在线观看| 狠狠色综合色综合网络| 欧美三级日韩三级| 中文字幕不卡一区| 精品综合免费视频观看| 在线亚洲精品福利网址导航| 国产偷国产偷亚洲高清人白洁| 亚洲第一二三四区| 9i在线看片成人免费| 久久亚洲免费视频| 性欧美疯狂xxxxbbbb| 99国产精品国产精品毛片| 日韩免费视频一区| 午夜精品免费在线| 一本一本大道香蕉久在线精品 | 在线视频国内一区二区| 国产精品入口麻豆原神| 欧美aaaaaa午夜精品| 欧美日韩国产一区二区三区地区| 亚洲欧美在线另类| 国产成人激情av| 欧美精品一区二区精品网| 丝袜美腿亚洲综合| 欧美日韩视频第一区| 亚洲影院免费观看| 91丨porny丨蝌蚪视频| 欧美激情在线看| 国产福利精品一区二区| 精品日韩一区二区| 久久国产夜色精品鲁鲁99| 欧美电影一区二区| 性久久久久久久久久久久| 欧美亚洲综合在线| 亚洲h精品动漫在线观看| 在线观看91视频| 亚洲一区二区三区四区在线观看 | 成人国产精品视频| 国产人伦精品一区二区| 国产伦精品一区二区三区视频青涩 | 色综合久久综合| 亚洲理论在线观看| 色哟哟在线观看一区二区三区| 国产精品国产三级国产普通话蜜臀 | 日韩精品国产欧美| 欧美一卡二卡在线| 奇米影视一区二区三区| 日韩免费看的电影| 激情综合亚洲精品| 久久久久久免费| 丁香婷婷综合网| 国产精品福利一区| 在线观看亚洲一区| 偷窥少妇高潮呻吟av久久免费| 欧美精品自拍偷拍动漫精品| 免费成人在线网站| 欧美精品一区男女天堂| 国产精品一二三四区| 欧美激情一区二区在线| www.一区二区| 亚洲一级二级三级| 欧美一级久久久| 国产在线麻豆精品观看| 国产精品五月天| 欧美性猛片xxxx免费看久爱| 日韩av一区二区三区四区| 精品免费一区二区三区| 国产v综合v亚洲欧| 一区二区三区日韩欧美精品| 欧美日韩成人综合| 国产精品一区三区| 亚洲乱码国产乱码精品精的特点 | 国产欧美视频一区二区三区| 懂色中文一区二区在线播放| 伊人一区二区三区| 欧美一区二区视频网站| 国产成人在线色| 一区二区三区在线观看动漫| 欧美不卡在线视频| av不卡免费在线观看| 日本不卡高清视频| 日本一区二区三区高清不卡| 欧美色图一区二区三区| 狠狠色丁香婷综合久久| 亚洲视频综合在线| 日韩免费福利电影在线观看| 99免费精品在线观看| 男人操女人的视频在线观看欧美 | 美女视频第一区二区三区免费观看网站 | 欧美男女性生活在线直播观看| 久久99国产精品尤物| 一区二区三区四区在线播放| 亚洲精品一区二区三区福利| 91麻豆.com| 欧美成人女星排行榜| 成人午夜视频在线观看| 国产精品久久久久桃色tv| 欧美亚洲日本一区| 国产盗摄一区二区| 性感美女极品91精品| 国产精品久久久久久户外露出| 欧美一区二区女人|