两侧同时换到之前的修订记录 前一修订版 | |||
5.控件详解:19.文件流控件 [2020/12/15 11:47] tjcqiu |
5.控件详解:19.文件流控件 [2021/01/18 11:17] (当前版本) tjcqiu |
||
---|---|---|---|
行 1: | 行 1: | ||
<h1 style="white-space: normal; text-align: center;">文件流控件使用说明</h1><hr/><p style="white-space: normal;"><br/></p><table><tbody><tr class="firstRow"><td width="196" valign="middle" align="center" style="word-break: break-all;">名称</td><td width="134" valign="middle" align="center" style="word-break: break-all;">操作</td><td width="90" valign="middle" align="center" style="word-break: break-all;">版本</td><td width="133" valign="middle" align="center" style="word-break: break-all;">日期<br/></td><td valign="middle" colspan="1" rowspan="1" width="275" align="center" style="word-break: break-all;">说明</td><td valign="middle" colspan="1" rowspan="1" align="center" width="166" style="word-break: break-all;">编辑</td></tr><tr><td width="197" valign="middle" align="center" style="word-break: break-all;">《文件流控件使用说明》</td><td width="134" valign="middle" align="center" style="word-break: break-all;">创建中</td><td width="90" valign="middle" align="center" style="word-break: break-all;">V1.0</td><td width="133" valign="middle" align="center" style="word-break: break-all;">2019-01-17</td><td valign="middle" colspan="1" rowspan="1" width="275" align="center" style="word-break: break-all;">第一次编辑完成,正式发布。</td><td valign="middle" colspan="1" rowspan="1" align="center" width="166" style="word-break: break-all;">lyh</td></tr><tr><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;" width="31">《文件流控件使用说明》</td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;" width="133">修订</td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;">V1.1</td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;">2020-07-31</td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;"><span style="color: rgb(0, 0, 0);">补充本控件中所有属性详解</span></td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;">qjj</td></tr></tbody></table><p style="white-space: normal;"><br/></p><hr/><p style="white-space: normal; line-height: 1.75em;"><strong>【目录】<br/></strong></p><p style="white-space: normal; line-height: 1.75em;"><strong>一、<a href="#yi" target="_self">文件流控件-概述</a></strong></p><p style="white-space: normal; line-height: 1.75em;"><strong>二、<a href="#er" target="_self">文件流控件-简单使用</a></strong></p><p style="white-space: normal; line-height: 1.75em;"><strong>三、<a href="#san" target="_self">文件流控件-属性详解</a></strong></p><p style="white-space: normal; text-indent: 2em;">3.1、<a href="#sanyi" target="_self">控件属性描述</a></p><p style="white-space: normal; text-indent: 2em;">3.2、<a href="#saner" target="_self">控件属性编辑</a></p><p style="white-space: normal; text-indent: 2em;">  3.2.1、<a href="#saneryi" target="_self">编辑属性</a>   </p><p style="white-space: normal; text-indent: 2em;">  3.2.2、<a href="#sanerer" target="_self">读属性</a></p><p style="white-space: normal; text-indent: 2em;">  3.2.3、<a href="#sanersan" target="_self">写属性</a></p><p style="white-space: normal; text-indent: 2em;">3.3 、<a href="#sansan" target="_self">属性详解</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">    3.3.1、<a href="#sansanyi" target="_self">vscope属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">    3.3.2、<a href="#sansaner" target="_self">objname属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">    3.3.3、<a href="#sansansan" target="_self">id属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">    3.3.4、<a href="#sansansi" target="_self">type属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">      <span style="text-indent: 32px;">3.3.5、</span><a href="#sansanwu" target="_self">val属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">      <span style="text-indent: 32px;">3.3.6、</span><a href="#sansanliu" target="_self">qty属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">      <span style="text-indent: 32px;">3.3.</span>7、<a href="#sansanqi" target="_self">en属性</a></p><p style="white-space: normal; line-height: 1.5em; text-indent: 0em;"><strong style="white-space: normal;">四、<a href="#si" target="_self">文件流控件-方法说明</a></strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">4.1、<a href="#siyi" target="_self">open方法</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">4.2、<a href="#sier" target="_self">read方法</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">4.3、<a href="#sisan" target="_self">write方法</a></p><p style="white-space: normal; text-indent: 2em;"><span style="text-indent: 2em;">4.4、<a href="#sisi" target="_self">close方法</a></span><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="text-indent: 2em;">4.5、<a href="#siwu" target="_self">find方法</a></span></p><p style="text-indent: 0em; white-space: normal;"><strong>五、<a href="#wu" target="_self">文件流控件-使用详解</a></strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">5.1、<a href="#wuyi" target="_self">在页面上新建文件流控件</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">5.2、<a href="#wuer" target="_self">文件流控件实战使用</a><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">5.3、<a href="#wusan" target="_self">文件流控件使用过程中常见问题</a></p><hr/><h3 style="white-space: normal;"><a name="yi"></a>一、文件流控件-概述<br/></h3><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">1.1、文件流控件是串口屏诸多功能控件里面的其中一个。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">1.2、用于在串口屏上系统文件操作。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">1.3、在《USART HMI》软件左侧工具箱里面(如下图所示)。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">注:<span style="color: rgb(255, 0, 0);">仅X系列支持</span>。</p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200730/1596102352534626.png" title="1596102352534626.png" alt="图片3.png"/></p><hr/><h3 style="white-space: normal;"><a name="er"></a>二、文件流控件-简单使用<br/></h3><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">通过文件流控件实现自己的读写文件工程<span style="text-indent: 2em;">工程(如下图所示)。</span></p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200731/1596156607435266.png" title="1596156607435266.png" alt="图片2.png"/></p><p style="white-space: normal; text-indent: 2em;"><br/></p><p style="white-space: normal; text-indent: 2em;">事件下代码设计</p><p style="white-space: normal; text-indent: 2em;">页面事件</p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200731/1596156696506828.png" title="1596156696506828.png" alt="图片1.png"/></p><p style="white-space: normal; text-indent: 2em;"><br/></p><p style="white-space: normal; text-indent: 2em;">写入按钮</p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200731/1596156785407295.png" title="1596156785407295.png" alt="图片3.png" width="330" height="124"/></p><p style="white-space: normal; text-indent: 2em;"><br/></p><p style="white-space: normal; text-indent: 2em;">读取按钮</p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200731/1596156930891317.png" title="1596156930891317.png" alt="图片4.png"/></p><hr/><h3 style="white-space: normal;"><strong><a name="san"></a>三、文件流控件-属性详解</strong></h3><p style="white-space: normal; text-indent: 2em;">串口屏所有控件操作的实质都是对属性的修改。文件流控件具有的属性如下表所示。<strong><br/></strong></p><p style="white-space: normal; text-align: center;"><img src="/dokuwiki/ueditor/php/upload/image/20200819/1597799033101821.png" title="1597799033101821.png" alt="图片5.png"/></p><p style="white-space: normal; text-indent: 2em;"><strong><a name="sanyi"></a>3.1、控件属性描述</strong></p><p style="white-space: normal; text-indent: 2em;">    如下图所示,当鼠标选中对应属性时,会在属性窗口的最下方出现该属性的详细描述信息。</p><p style="white-space: normal; text-indent: 2em; text-align: center;"><img src="/dokuwiki/ueditor/php/upload/image/20200819/1597799153311980.png" title="1597799153311980.png" alt="图片5.png"/></p><p style="white-space: normal; text-indent: 2em;"><strong><a name="saner"></a>3.2、控件属性编辑</strong></p><p style="white-space: normal; text-indent: 2em;">   <a name="saneryi"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.2.1、编辑属性</span></p><p style="white-space: normal; text-indent: 2em;">  用户可以随时调整、编辑列表中的属性参数。</p><p style="white-space: normal; text-indent: 2em;">    注意:<span style="color: rgb(255, 0, 0);">type和id属性由开发环境指定,用户不可修改。可通过软件左上角置顶置底间接操作</span>。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sanerer"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.2.2、读属性</span></p><p style="white-space: normal; text-indent: 2em;">  如上图所示的控件属性列表,可以在设备运行中随时读取。</p><pre class="brush:cpp;toolbar:false">      sys0=fs0.id        //将文件流控件fs0的id号赋值给sys0变量 | <h1 style="white-space: normal; text-align: center;">文件流控件使用说明</h1><hr/><p style="white-space: normal;"><br/></p><table><tbody><tr class="firstRow"><td width="196" valign="middle" align="center" style="word-break: break-all;">名称</td><td width="134" valign="middle" align="center" style="word-break: break-all;">操作</td><td width="90" valign="middle" align="center" style="word-break: break-all;">版本</td><td width="133" valign="middle" align="center" style="word-break: break-all;">日期<br/></td><td valign="middle" colspan="1" rowspan="1" width="275" align="center" style="word-break: break-all;">说明</td><td valign="middle" colspan="1" rowspan="1" align="center" width="166" style="word-break: break-all;">编辑</td></tr><tr><td width="197" valign="middle" align="center" style="word-break: break-all;">《文件流控件使用说明》</td><td width="134" valign="middle" align="center" style="word-break: break-all;">创建中</td><td width="90" valign="middle" align="center" style="word-break: break-all;">V1.0</td><td width="133" valign="middle" align="center" style="word-break: break-all;">2019-01-17</td><td valign="middle" colspan="1" rowspan="1" width="275" align="center" style="word-break: break-all;">第一次编辑完成,正式发布。</td><td valign="middle" colspan="1" rowspan="1" align="center" width="166" style="word-break: break-all;">lyh</td></tr><tr><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;" width="31">《文件流控件使用说明》</td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;" width="133">修订</td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;">V1.1</td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;">2020-07-31</td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;"><span style="color: rgb(0, 0, 0);">补充本控件中所有属性详解</span></td><td valign="middle" colspan="1" rowspan="1" align="center" style="word-break: break-all;">qjj</td></tr></tbody></table><p style="white-space: normal;"><br/></p><hr/><p style="white-space: normal; line-height: 1.75em;"><strong>【目录】<br/></strong></p><p style="white-space: normal; line-height: 1.75em;"><strong>一、<a href="#yi" target="_self">文件流控件-概述</a></strong></p><p style="white-space: normal; line-height: 1.75em;"><strong>二、<a href="#er" target="_self">文件流控件-简单使用</a></strong></p><p style="white-space: normal; line-height: 1.75em;"><strong>三、<a href="#san" target="_self">文件流控件-属性详解</a></strong></p><p style="white-space: normal; text-indent: 2em;">3.1、<a href="#sanyi" target="_self">控件属性描述</a></p><p style="white-space: normal; text-indent: 2em;">3.2、<a href="#saner" target="_self">控件属性编辑</a></p><p style="white-space: normal; text-indent: 2em;">  3.2.1、<a href="#saneryi" target="_self">编辑属性</a>   </p><p style="white-space: normal; text-indent: 2em;">  3.2.2、<a href="#sanerer" target="_self">读属性</a></p><p style="white-space: normal; text-indent: 2em;">  3.2.3、<a href="#sanersan" target="_self">写属性</a></p><p style="white-space: normal; text-indent: 2em;">3.3 、<a href="#sansan" target="_self">属性详解</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">    3.3.1、<a href="#sansanyi" target="_self">vscope属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">    3.3.2、<a href="#sansaner" target="_self">objname属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">    3.3.3、<a href="#sansansan" target="_self">id属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">    3.3.4、<a href="#sansansi" target="_self">type属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">      <span style="text-indent: 32px;">3.3.5、</span><a href="#sansanwu" target="_self">val属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">      <span style="text-indent: 32px;">3.3.6、</span><a href="#sansanliu" target="_self">qty属性</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.5em;">      <span style="text-indent: 32px;">3.3.</span>7、<a href="#sansanqi" target="_self">en属性</a></p><p style="white-space: normal; line-height: 1.5em; text-indent: 0em;"><strong style="white-space: normal;">四、<a href="#si" target="_self">文件流控件-方法说明</a></strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">4.1、<a href="#siyi" target="_self">open方法</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">4.2、<a href="#sier" target="_self">read方法</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">4.3、<a href="#sisan" target="_self">write方法</a></p><p style="white-space: normal; text-indent: 2em;"><span style="text-indent: 2em;">4.4、<a href="#sisi" target="_self">close方法</a></span><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="text-indent: 2em;">4.5、<a href="#siwu" target="_self">find方法</a></span></p><p style="text-indent: 0em; white-space: normal;"><strong>五、<a href="#wu" target="_self">文件流控件-使用详解</a></strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">5.1、<a href="#wuyi" target="_self">在页面上新建文件流控件</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">5.2、<a href="#wuer" target="_self">文件流控件实战使用</a><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">5.3、<a href="#wusan" target="_self">文件流控件使用过程中常见问题</a></p><hr/><h3 style="white-space: normal;"><a name="yi"></a>一、文件流控件-概述<br/></h3><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">1.1、文件流控件是串口屏诸多功能控件里面的其中一个。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">1.2、用于在串口屏上系统文件操作。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">1.3、在《USART HMI》软件左侧工具箱里面(如下图所示)。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">注:<span style="color: rgb(255, 0, 0);">仅X系列支持</span>。</p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200730/1596102352534626.png" title="1596102352534626.png" alt="图片3.png"/></p><hr/><h3 style="white-space: normal;"><a name="er"></a>二、文件流控件-简单使用<br/></h3><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">通过文件流控件实现自己的读写文件工程<span style="text-indent: 2em;">工程(如下图所示)。</span></p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200731/1596156607435266.png" title="1596156607435266.png" alt="图片2.png"/></p><p style="white-space: normal; text-indent: 2em;"><br/></p><p style="white-space: normal; text-indent: 2em;">事件下代码设计</p><p style="white-space: normal; text-indent: 2em;">页面事件</p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200731/1596156696506828.png" title="1596156696506828.png" alt="图片1.png"/></p><p style="white-space: normal; text-indent: 2em;"><br/></p><p style="white-space: normal; text-indent: 2em;">写入按钮</p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200731/1596156785407295.png" title="1596156785407295.png" alt="图片3.png" width="330" height="124"/></p><p style="white-space: normal; text-indent: 2em;"><br/></p><p style="white-space: normal; text-indent: 2em;">读取按钮</p><p style="white-space: normal; text-indent: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20200731/1596156930891317.png" title="1596156930891317.png" alt="图片4.png"/></p><hr/><h3 style="white-space: normal;"><strong><a name="san"></a>三、文件流控件-属性详解</strong></h3><p style="white-space: normal; text-indent: 2em;">串口屏所有控件操作的实质都是对属性的修改。文件流控件具有的属性如下表所示。<strong><br/></strong></p><p style="white-space: normal; text-align: center;"><img src="/dokuwiki/ueditor/php/upload/image/20200819/1597799033101821.png" title="1597799033101821.png" alt="图片5.png"/></p><p style="white-space: normal; text-indent: 2em;"><strong><a name="sanyi"></a>3.1、控件属性描述</strong></p><p style="white-space: normal; text-indent: 2em;">    如下图所示,当鼠标选中对应属性时,会在属性窗口的最下方出现该属性的详细描述信息。</p><p style="white-space: normal; text-indent: 2em; text-align: center;"><img src="/dokuwiki/ueditor/php/upload/image/20200819/1597799153311980.png" title="1597799153311980.png" alt="图片5.png"/></p><p style="white-space: normal; text-indent: 2em;"><strong><a name="saner"></a>3.2、控件属性编辑</strong></p><p style="white-space: normal; text-indent: 2em;">   <a name="saneryi"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.2.1、编辑属性</span></p><p style="white-space: normal; text-indent: 2em;">  用户可以随时调整、编辑列表中的属性参数。</p><p style="white-space: normal; text-indent: 2em;">    注意:<span style="color: rgb(255, 0, 0);">type和id属性由开发环境指定,用户不可修改。可通过软件左上角置顶置底间接操作</span>。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sanerer"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.2.2、读属性</span></p><p style="white-space: normal; text-indent: 2em;">  如上图所示的控件属性列表,可以在设备运行中随时读取。</p><pre class="brush:cpp;toolbar:false">      sys0=fs0.id        //将文件流控件fs0的id号赋值给sys0变量 | ||
- |       prints  fs0.id,0       //将fs0的id号从串口发送出去。</pre><p style="white-space: normal; text-indent: 2em;">    注意:objname属性不可以读取。比如在事件代码中写"t0.txt=fs0.objname"编译将报错。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sanersan"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.2.3、写属性</span></p><p style="white-space: normal; text-indent: 2em;"><span style="text-indent: 2em;">  所有绿色控件可以在运行中实时修改。</span></p><p style="white-space: normal; text-indent: 2em;">    注意:<span style="color: rgb(255, 0, 0);">因产品系列不同,属性的写权限也不完全相同。比如X系列可以在运行该过程中修改x,y属性。但是T0,K0系列不能在运行过程中修改x,y属性</span>!</p><p style="white-space: normal; text-indent: 2em;"><strong><a name="sansan"></a>3.3 、属性详解</strong></p><p style="white-space: normal; text-indent: 2em;">   <a name="sansanyi"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.1、vscope属性</span></p><p style="white-space: normal; text-indent: 2em;">          vscope属性。控件内存占用属性。控件支持私有和全局属性。</p><p style="white-space: normal; text-indent: 2em;">         当设置为全局时,控件分配的内存在所有页面都可以访问。离开当前页面后,控件属性数据也不会丢失。缺点是,占用系统总内存。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansaner"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.2、objname属性</span></p><p style="white-space: normal; text-indent: 2em;">        objname属性。控件名称属性。该属性在运行中不能获取。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansansan"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.3、id属性</span></p><p style="white-space: normal; text-indent: 2em;">        id属性。控件id是每个控件在当前页面的唯一标识号。由系统分配,不可修改。可通过软件左上角置顶置底间接修改。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansansi"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.4、type属性</span></p><p style="white-space: normal; text-indent: 2em;">        type属性。控件类型属性。由系统分别固定数据,比如文件流控件属性为63。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansanwu"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.5、val属性</span></p><p style="white-space: normal; text-indent: 2em;">        val属性。此文件流当前数据指针(打开文件时恢复为0,读写操作过程中自动移动,支持手动设置)。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansanliu"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.6、qty属性</span></p><p style="white-space: normal; text-indent: 2em;">        qty属性。文件大小(运行中根据实际打开的文件自动更新,只可获取不可设置)。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansanqi"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.7、en属性</span></p><p style="white-space: normal; text-indent: 2em;">        en属性。文件打开状态(只可获取不可设置)。</p><p style="white-space: normal; text-indent: 2em;">            注:有文件被打开(open)的时候,en=1;没有文件打开的时候,en=0。<br/></p><p style="white-space: normal; text-indent: 2em;"><br/></p><h3 style="white-space: normal;"><a name="si"></a>四、文件流控件-方法说明</h3><p>       <span style="color: rgb(51, 51, 51); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; orphans: 4; text-indent: 28px; background-color: rgb(255, 255, 255);">该方法为文件流控件独有的,对于其他控件不生效。使用方式类似于指令。</span></p><p>       文件流包含相关方法软件存放位置<br/></p><p>       <img src="/dokuwiki/ueditor/php/upload/image/20200911/1599786102104373.png" title="1599786102104373.png" alt="图片1.png"/></p><p><br/></p><p><strong><strong style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px; white-space: normal; background-color: rgb(255, 255, 255);">        <a name="siyi"></a><span style="font-size: 16px;">4.1、open方法 打开文件</span></strong></strong></p><p><strong><strong style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px;"></span></strong></strong></p><p>       int open(string path)</p><p>       path 文件路径如“sd0/aa.txt” </p><p>       例:fs0.open("sd0/aa.txt") (打开sd0下aa.txt如果成功返回1 失败则返回0)</p><p>       <span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 <span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">文件打开读写操作完成后一定要记得关闭文件,同一个文件在打开后,关闭之前,是不能被另外一个文件流控件打开的</span></span>    <strong><strong style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px;"><br/></span></strong></strong></p><p>        <br/></p><p>       <a name="sier"></a><strong>4.2、read方法 从当前流读数据</strong></p><p>       int read(object att,int star,int lenth)</p><p>       att 变量名称</p><p>   att star 变量(<span style="color: rgb(255, 0, 0);">非文件地址</span>)的起始地址(一般为0)</p><p>       lenth 读入数据长度</p><p>       例:fs0.read(va2.txt,0,100) (va2.txt读取打开的文件从0读到100)  读取成功返回1,失败返回0</p><p><span style="color: rgb(255, 0, 0); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">        </span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 ①<span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">起始地址不为0时,若读取文本地址也应不为0,且相对应得地址有数据 否则导致读到文本为空</span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">。</span></span></p><p><span style="background-color: rgb(255, 255, 255); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4;">             ②<span style="background-color: rgb(255, 255, 255); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; color: rgb(255, 0, 0);">读取要注意控件属性(txt_maxl),读取数据长度超过范围,则无法显示读取的内容</span>。   </span></p><p><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">        例 有一个文件文本内容为“ABCDEF”  fs0.read(va2.txt,1,2)  va2.txt="12"  读到va2.txt=“1AB”。</span></p><p><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">            此时读到文件数据是出现1的后面。如果1后面有别的数据,那么他们对应的位置会被替换掉。 读取完,文件流指针(val)加上数据长度(2)。<br/></span></p><p><br/></p><p>      <a name="sisan"></a><strong>4.3、write方法 将数据写入当前流</strong><strong> </strong></p><p>      int write (object att,int star,int lenth)</p><p>      att 变量名称</p><p>  att star 变量(<span style="color: rgb(255, 0, 0);">非文件地址</span>)的起始地址(一般为0)</p><p>      lenth 写入数据长度</p><p>      例 fs0.write(va2.txt,0,100) (将va2.txt的字符内容写入当前打开的文件中) 写入成功返回1,失败返回0</p><p><strong><span style="color: rgb(255, 0, 0); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">       </span></strong><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 ①<span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">写入完,文件流指针(val)加上数据长度(lenth)</span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">。</span></span></p><p><strong>          </strong>②<span style="color: rgb(255, 0, 0);">star设置不为0时,写入变量的起始地址,不是文件的起始位置</span>。<strong><br/></strong></p><p>             例:t0.txt="123456"<br/></p><p>                    fs0.write(t0.txt,1,6)  此时写入"23456"加一个空格</p><p><br/></p><p><strong>      <a name="sisi"></a>4.4、close方法 关闭文件流</strong></p><p>      例:fs0.close() 成功返回1,失败返回0</p><p><span style="color: rgb(255, 0, 0); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">       </span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 <span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">文件打开读写操作完成后一定要记得关闭文件,同一个文件在打开后,关闭之前,是不能被另外一个文件流控件打开的</span></span><br/></p><p><br/></p><p>      <a name="siwu"></a><strong>4.5、find方法 查询文件</strong><br/></p><p>      int find(string key) 成功返回1,失败返回0</p><p>      key 关键字字符串变量/常量</p><p>      例:文件aa.txt内容为123</p><p>      fs0.open("sd0/aa.txt")</p><p>      s0.find("2")  (查找文件中的"2",此时fs0.val为1)</p><p style="text-indent: 0em; white-space: normal; line-height: 1.5em;"><span style="color: rgb(255, 0, 0); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">       </span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 <span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">从当前流的当前数据指针(val属性)位置开始查询关键字,如果查询成功,数据指针将会移动到关键字中第一个字符串:如果查询失败保持数据当前指针不变</span></span></p><p style="text-indent: 0em; white-space: normal; line-height: 1.5em;"><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);"><br/></span></p><h3 style="white-space: normal;"><a name="wu"></a>五、文件流控件-使用详解<br/></h3><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><a name="wuyi"></a><strong><span style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);">5.1</span></strong>、<strong>在页面上新建文件流控件</strong></p><table align="center"><tbody><tr class="firstRow"><td valign="top" style="border-color: rgb(255, 255, 255);"><p style="text-indent: 0em;"><img src="/dokuwiki/ueditor/php/upload/image/20200730/1596093709693930.png" title="1596093709693930.png" alt="图片1.png" width="466" height="270"/></p></td><td valign="top" style="border-color: rgb(255, 255, 255); word-break: break-all;"><img src="/dokuwiki/ueditor/php/upload/image/20200730/1596095140604510.png" title="1596095140604510.png" alt="图片2.png" width="498" height="264"/></td></tr><tr><td valign="middle" align="center" style="border-color: rgb(255, 255, 255); word-break: break-all;"><p style="text-indent: 0em;"><span style="color: rgb(127, 127, 127);">1、打开一个新的空白界面▲</span></p></td><td valign="middle" align="center" style="border-color: rgb(255, 255, 255); word-break: break-all;"><span style="color: rgb(127, 127, 127);">2、点击左侧<工具箱>里面的<文件流>按钮,当前页面左上角出现一个文件流▲</span></td></tr></tbody></table><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255); text-indent: 32px;">点击文件流控件,他就将会出现在</span><a href="http://wiki.tjc1688.com/doku.php?id=4.%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E8%AF%A6%E8%A7%A3:1.%E8%BD%AF%E4%BB%B6%E7%95%8C%E9%9D%A2%E6%A6%82%E6%8B%AC,bianliangchuangkou" target="_self">特殊控件窗口</a><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px; background-color: rgb(255, 255, 255);">。</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><a name="wuer"></a><strong style="text-indent: 32px; white-space: normal;"><span style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);">5.2</span></strong><span style="text-indent: 32px;">、</span><strong style="text-indent: 32px; white-space: normal;">文件流控件实战使用</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><strong>操作sd文件步骤:</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="text-indent: 2em;">1.通过</span><a href="#siyi" target="_self" style="text-indent: 2em;">open方法</a><span style="text-indent: 2em;">打开文件</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="text-indent: 2em;">注:如果没有该文件将会报文件操作失败(06 FF FF FF)。</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">2.接下来可以通过<a href="#sisan" target="_self">write方法</a>写入文件或者<a href="#sier" target="_self">read方法</a><span style="text-indent: 2em;">读取文件</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">3.操作完文件后使用<a href="#sisi" target="_self">close方法</a>关闭文件流</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><strong><br/></strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><strong>相关例程</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><strong style="text-indent: 32px; white-space: normal;"></strong></p><p style="padding: 0px; white-space: normal; line-height: 1.75em; text-indent: 2em;">①将<a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:17.%E6%9B%B2%E7%BA%BF_%E6%B3%A2%E5%BD%A2%E6%8E%A7%E4%BB%B6" target="_self">曲线/波形</a>控件的数据点写入sd卡文件中 <a href="http://tjcfile.iicp.net:885/USARTHMI/demo_prj/curve&File%20stream.rar" target="_self" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">点击下载</a></p><p style="padding: 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: normal; line-height: 1.75em; text-indent: 2em;"><br/></p><p style="padding: 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: normal; line-height: 1.75em; text-indent: 2em;"><span style="font-size: 16px;">素材说明:</span></p><p style="padding: 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: normal; line-height: 1.75em; text-indent: 2em;"><span style="font-size: 16px;">用<a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:15.%E5%AE%9A%E6%97%B6%E5%99%A8%E6%8E%A7%E4%BB%B6" target="_self">定时器</a>控件给<a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:17.%E6%9B%B2%E7%BA%BF_%E6%B3%A2%E5%BD%A2%E6%8E%A7%E4%BB%B6" target="_self">曲线/波形</a>控件添加数据点。</span></p><p style="padding: 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: normal; line-height: 1.75em; text-indent: 2em;"><span style="font-size: 16px;">将数据点通过文件流控件写入sd卡文件。</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><br/><strong style="text-indent: 32px; white-space: normal;"></strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">②通过文件浏览器以及文件流实现文件系统 <a href="http://tjcfile.iicp.net:885/USARTHMI/demo_prj/Filebrowser.zip" target="_self">点击下载</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">素材说明:</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">文件浏览器显示文件,文件夹。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">文件流打开,读取文件显示在相应控件上。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">相关方法 <a href="http://wiki.tjc1688.com/doku.php?id=0.%E8%8D%89%E7%A8%BF%E7%AE%B1:%E5%A4%8D%E5%88%B6%E5%A5%BD%E7%9A%84%E6%96%87%E6%9C%AC%E6%8E%A7%E4%BB%B6%E9%A1%B5%E9%9D%A21,siyi" target="_self">up</a>方法</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">相关指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,newfile" target="_self">newfile</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,newdir" target="_self">newdir</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,deldir" target="_self">deldir</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,redir" target="_self">redir</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,findfile" target="_self">findflie</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,finddir" target="_self">finddir</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,refile" target="_self">refile</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,redir" target="_self">redir</a>指令 这些指令实现文件系统对文件的基本操作。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px;">相关控件 <a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:30.%E5%A4%96%E9%83%A8%E5%9B%BE%E7%89%87%E6%8E%A7%E4%BB%B6" target="_self">外部图片控件</a> <a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:25.%E8%A7%86%E9%A2%91%E6%8E%A7%E4%BB%B6" target="_self">视频控件</a></span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px;"><br/></span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">注:<a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:25.%E8%A7%86%E9%A2%91%E6%8E%A7%E4%BB%B6" target="_self" style="text-decoration: underline; color: rgb(79, 129, 189);"><span style="color: rgb(79, 129, 189);">视频控件</span></a><span style="color: rgb(255, 0, 0);">属性from设置外部文件</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">  <span style="color: rgb(255, 0, 0);">电脑是有虚拟sd卡文件夹 可以在电脑模拟和调试好之后 再下载屏上仿真。(存放路径:菜单栏—文件—虚拟sd卡文件夹)</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><a name="wusan"></a><strong style="text-indent: 32px; white-space: normal;"><span style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);">5.3</span></strong><span style="text-indent: 32px;">、</span><strong style="text-indent: 32px; white-space: normal;">文件流控件使用过程中常见问题</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">①<strong>文件流read方法读取文件读出来为空。</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">可能原因:读取长度比文件大小还大导致读取失败。<br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">解决办法:读取长度不要超过文件大小即属性qty。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">②<strong style="text-indent: 32px; white-space: normal;">文件流find方法查找换行符"\r",读取文件它的下一个字符不正常。</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">可能原因:"\r"在屏幕里面存储的是0d 0a。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="text-indent: 32px;">解决办法:</span>fs0.val=fs0.val+2这样赋值就会正常。</p><p style="text-indent: 0em; white-space: normal; line-height: 1.75em; text-align: center;">END</p><p><br/></p><p><br/></p> | + |       prints  fs0.id,0       //将fs0的id号从串口发送出去。</pre><p style="white-space: normal; text-indent: 2em;">    注意:objname属性不可以读取。比如在事件代码中写"t0.txt=fs0.objname"编译将报错。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sanersan"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.2.3、写属性</span></p><p style="white-space: normal; text-indent: 2em;"><span style="text-indent: 2em;">  所有绿色控件可以在运行中实时修改。</span></p><p style="white-space: normal; text-indent: 2em;">    注意:<span style="color: rgb(255, 0, 0);">因产品系列不同,属性的写权限也不完全相同。比如X系列可以在运行该过程中修改x,y属性。但是T0,K0系列不能在运行过程中修改x,y属性</span>!</p><p style="white-space: normal; text-indent: 2em;"><strong><a name="sansan"></a>3.3 、属性详解</strong></p><p style="white-space: normal; text-indent: 2em;">   <a name="sansanyi"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.1、vscope属性</span></p><p style="white-space: normal; text-indent: 2em;">          vscope属性。控件内存占用属性。控件支持私有属性。<span style="text-indent: 2em;">  </span></p><p style="white-space: normal; text-indent: 2em;">   <a name="sansaner"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.2、objname属性</span></p><p style="white-space: normal; text-indent: 2em;">        objname属性。控件名称属性。该属性在运行中不能获取。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansansan"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.3、id属性</span></p><p style="white-space: normal; text-indent: 2em;">        id属性。控件id是每个控件在当前页面的唯一标识号。由系统分配,不可修改。可通过软件左上角置顶置底间接修改。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansansi"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.4、type属性</span></p><p style="white-space: normal; text-indent: 2em;">        type属性。控件类型属性。由系统分别固定数据,比如文件流控件属性为63。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansanwu"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.5、val属性</span></p><p style="white-space: normal; text-indent: 2em;">        val属性。此文件流当前数据指针(打开文件时恢复为0,读写操作过程中自动移动,支持手动设置)。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansanliu"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.6、qty属性</span></p><p style="white-space: normal; text-indent: 2em;">        qty属性。文件大小(运行中根据实际打开的文件自动更新,只可获取不可设置)。</p><p style="white-space: normal; text-indent: 2em;">   <a name="sansanqi"></a> <span style="border: 1px solid rgb(0, 0, 0);">3.3.7、en属性</span></p><p style="white-space: normal; text-indent: 2em;">        en属性。文件打开状态(只可获取不可设置)。</p><p style="white-space: normal; text-indent: 2em;">            注:有文件被打开(open)的时候,en=1;没有文件打开的时候,en=0。<br/></p><p style="white-space: normal; text-indent: 2em;"><br/></p><h3 style="white-space: normal;"><a name="si"></a>四、文件流控件-方法说明</h3><p>       <span style="color: rgb(51, 51, 51); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; orphans: 4; text-indent: 28px; background-color: rgb(255, 255, 255);">该方法为文件流控件独有的,对于其他控件不生效。使用方式类似于指令。</span></p><p>       文件流包含相关方法软件存放位置<br/></p><p>       <img src="/dokuwiki/ueditor/php/upload/image/20200911/1599786102104373.png" title="1599786102104373.png" alt="图片1.png"/></p><p><br/></p><p><strong><strong style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px; white-space: normal; background-color: rgb(255, 255, 255);">        <a name="siyi"></a><span style="font-size: 16px;">4.1、open方法 打开文件</span></strong></strong></p><p><strong><strong style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px;"></span></strong></strong></p><p>       int open(string path)</p><p>       path 文件路径如“sd0/aa.txt” </p><p>       例:fs0.open("sd0/aa.txt") (打开sd0下aa.txt如果成功返回1 失败则返回0)</p><p>       <span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 <span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">文件打开读写操作完成后一定要记得关闭文件,同一个文件在打开后,关闭之前,是不能被另外一个文件流控件打开的</span></span>    <strong><strong style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px;"><br/></span></strong></strong></p><p>        <br/></p><p>       <a name="sier"></a><strong>4.2、read方法 从当前流读数据</strong></p><p>       int read(object att,int star,int lenth)</p><p>       att 变量名称</p><p>   att star 变量(<span style="color: rgb(255, 0, 0);">非文件地址</span>)的起始地址(一般为0)</p><p>       lenth 读入数据长度</p><p>       例:fs0.read(va2.txt,0,100) (va2.txt读取打开的文件从0读到100)  读取成功返回1,失败返回0</p><p><span style="color: rgb(255, 0, 0); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">        </span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 ①<span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">起始地址不为0时,若读取文本地址也应不为0,且相对应得地址有数据 否则导致读到文本为空</span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">。</span></span></p><p><span style="background-color: rgb(255, 255, 255); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4;">             ②<span style="background-color: rgb(255, 255, 255); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; color: rgb(255, 0, 0);">读取要注意控件属性(txt_maxl),读取数据长度超过范围,则无法显示读取的内容</span>。   </span></p><p><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">        例 有一个文件文本内容为“ABCDEF”  fs0.read(va2.txt,1,2)  va2.txt="12"  读到va2.txt=“1AB”。</span></p><p><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">            此时读到文件数据是出现1的后面。如果1后面有别的数据,那么他们对应的位置会被替换掉。 读取完,文件流指针(val)加上数据长度(2)。<br/></span></p><p><br/></p><p>      <a name="sisan"></a><strong>4.3、write方法 将数据写入当前流</strong><strong> </strong></p><p>      int write (object att,int star,int lenth)</p><p>      att 变量名称</p><p>  att star 变量(<span style="color: rgb(255, 0, 0);">非文件地址</span>)的起始地址(一般为0)</p><p>      lenth 写入数据长度</p><p>      例 fs0.write(va2.txt,0,100) (将va2.txt的字符内容写入当前打开的文件中) 写入成功返回1,失败返回0</p><p><strong><span style="color: rgb(255, 0, 0); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">       </span></strong><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 ①<span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">写入完,文件流指针(val)加上数据长度(lenth)</span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">。</span></span></p><p><strong>          </strong>②<span style="color: rgb(255, 0, 0);">star设置不为0时,写入变量的起始地址,不是文件的起始位置</span>。<strong><br/></strong></p><p>             例:t0.txt="123456"<br/></p><p>                    fs0.write(t0.txt,1,6)  此时写入"23456"加一个空格</p><p><br/></p><p><strong>      <a name="sisi"></a>4.4、close方法 关闭文件流</strong></p><p>      例:fs0.close() 成功返回1,失败返回0</p><p><span style="color: rgb(255, 0, 0); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">       </span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 <span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">文件打开读写操作完成后一定要记得关闭文件,同一个文件在打开后,关闭之前,是不能被另外一个文件流控件打开的</span></span><br/></p><p><br/></p><p>      <a name="siwu"></a><strong>4.5、find方法 查询文件</strong><br/></p><p>      int find(string key) 成功返回1,失败返回0</p><p>      key 关键字字符串变量/常量</p><p>      例:文件aa.txt内容为123</p><p>      fs0.open("sd0/aa.txt")</p><p>      s0.find("2")  (查找文件中的"2",此时fs0.val为1)</p><p style="text-indent: 0em; white-space: normal; line-height: 1.5em;"><span style="color: rgb(255, 0, 0); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">       </span><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);">注 <span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);">从当前流的当前数据指针(val属性)位置开始查询关键字,如果查询成功,数据指针将会移动到关键字中第一个字符串:如果查询失败保持数据当前指针不变</span></span></p><p style="text-indent: 0em; white-space: normal; line-height: 1.5em;"><span style="font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; orphans: 4; background-color: rgb(255, 255, 255);"><br/></span></p><h3 style="white-space: normal;"><a name="wu"></a>五、文件流控件-使用详解<br/></h3><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><a name="wuyi"></a><strong><span style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);">5.1</span></strong>、<strong>在页面上新建文件流控件</strong></p><table align="center"><tbody><tr class="firstRow"><td valign="top" style="border-color: rgb(255, 255, 255);"><p style="text-indent: 0em;"><img src="/dokuwiki/ueditor/php/upload/image/20200730/1596093709693930.png" title="1596093709693930.png" alt="图片1.png" width="466" height="270"/></p></td><td valign="top" style="border-color: rgb(255, 255, 255); word-break: break-all;"><img src="/dokuwiki/ueditor/php/upload/image/20200730/1596095140604510.png" title="1596095140604510.png" alt="图片2.png" width="498" height="264"/></td></tr><tr><td valign="middle" align="center" style="border-color: rgb(255, 255, 255); word-break: break-all;"><p style="text-indent: 0em;"><span style="color: rgb(127, 127, 127);">1、打开一个新的空白界面▲</span></p></td><td valign="middle" align="center" style="border-color: rgb(255, 255, 255); word-break: break-all;"><span style="color: rgb(127, 127, 127);">2、点击左侧<工具箱>里面的<文件流>按钮,当前页面左上角出现一个文件流▲</span></td></tr></tbody></table><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255); text-indent: 32px;">点击文件流控件,他就将会出现在</span><a href="http://wiki.tjc1688.com/doku.php?id=4.%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E8%AF%A6%E8%A7%A3:1.%E8%BD%AF%E4%BB%B6%E7%95%8C%E9%9D%A2%E6%A6%82%E6%8B%AC,bianliangchuangkou" target="_self">特殊控件窗口</a><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px; background-color: rgb(255, 255, 255);">。</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><a name="wuer"></a><strong style="text-indent: 32px; white-space: normal;"><span style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);">5.2</span></strong><span style="text-indent: 32px;">、</span><strong style="text-indent: 32px; white-space: normal;">文件流控件实战使用</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><strong>操作sd文件步骤:</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="text-indent: 2em;">1.通过</span><a href="#siyi" target="_self" style="text-indent: 2em;">open方法</a><span style="text-indent: 2em;">打开文件</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="text-indent: 2em;">注:如果没有该文件将会报文件操作失败(06 FF FF FF)。</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">2.接下来可以通过<a href="#sisan" target="_self">write方法</a>写入文件或者<a href="#sier" target="_self">read方法</a><span style="text-indent: 2em;">读取文件</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">3.操作完文件后使用<a href="#sisi" target="_self">close方法</a>关闭文件流</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><strong><br/></strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><strong>相关例程</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><strong style="text-indent: 32px; white-space: normal;"></strong></p><p style="padding: 0px; white-space: normal; line-height: 1.75em; text-indent: 2em;">①将<a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:17.%E6%9B%B2%E7%BA%BF_%E6%B3%A2%E5%BD%A2%E6%8E%A7%E4%BB%B6" target="_self">曲线/波形</a>控件的数据点写入sd卡文件中 <a href="http://tjcfile.iicp.net:885/USARTHMI/demo_prj/curve&File%20stream.rar" target="_self" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">点击下载</a></p><p style="padding: 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: normal; line-height: 1.75em; text-indent: 2em;"><br/></p><p style="padding: 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: normal; line-height: 1.75em; text-indent: 2em;"><span style="font-size: 16px;">素材说明:</span></p><p style="padding: 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: normal; line-height: 1.75em; text-indent: 2em;"><span style="font-size: 16px;">用<a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:15.%E5%AE%9A%E6%97%B6%E5%99%A8%E6%8E%A7%E4%BB%B6" target="_self">定时器</a>控件给<a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:17.%E6%9B%B2%E7%BA%BF_%E6%B3%A2%E5%BD%A2%E6%8E%A7%E4%BB%B6" target="_self">曲线/波形</a>控件添加数据点。</span></p><p style="padding: 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: normal; line-height: 1.75em; text-indent: 2em;"><span style="font-size: 16px;">将数据点通过文件流控件写入sd卡文件。</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><br/><strong style="text-indent: 32px; white-space: normal;"></strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">②通过文件浏览器以及文件流实现文件系统 <a href="http://tjcfile.iicp.net:885/USARTHMI/demo_prj/Filebrowser.zip" target="_self">点击下载</a></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">素材说明:</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">文件浏览器显示文件,文件夹。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">文件流打开,读取文件显示在相应控件上。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">相关方法 <a href="http://wiki.tjc1688.com/doku.php?id=0.%E8%8D%89%E7%A8%BF%E7%AE%B1:%E5%A4%8D%E5%88%B6%E5%A5%BD%E7%9A%84%E6%96%87%E6%9C%AC%E6%8E%A7%E4%BB%B6%E9%A1%B5%E9%9D%A21,siyi" target="_self">up</a>方法</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">相关指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,newfile" target="_self">newfile</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,newdir" target="_self">newdir</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,deldir" target="_self">deldir</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,redir" target="_self">redir</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,findfile" target="_self">findflie</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,finddir" target="_self">finddir</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,refile" target="_self">refile</a>指令 <a href="http://wiki.tjc1688.com/doku.php?id=6.%E6%8C%87%E4%BB%A4%E9%9B%86:1.%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4%E9%9B%86,redir" target="_self">redir</a>指令 这些指令实现文件系统对文件的基本操作。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px;">相关控件 <a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:30.%E5%A4%96%E9%83%A8%E5%9B%BE%E7%89%87%E6%8E%A7%E4%BB%B6" target="_self">外部图片控件</a> <a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:25.%E8%A7%86%E9%A2%91%E6%8E%A7%E4%BB%B6" target="_self">视频控件</a></span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; text-indent: 28px;"><br/></span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">注:<a href="http://wiki.tjc1688.com/doku.php?id=5.%E6%8E%A7%E4%BB%B6%E8%AF%A6%E8%A7%A3:25.%E8%A7%86%E9%A2%91%E6%8E%A7%E4%BB%B6" target="_self" style="text-decoration: underline; color: rgb(79, 129, 189);"><span style="color: rgb(79, 129, 189);">视频控件</span></a><span style="color: rgb(255, 0, 0);">属性from设置外部文件</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">  <span style="color: rgb(255, 0, 0);">电脑是有虚拟sd卡文件夹 可以在电脑模拟和调试好之后 再下载屏上仿真。(存放路径:菜单栏—文件—虚拟sd卡文件夹)</span></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><a name="wusan"></a><strong style="text-indent: 32px; white-space: normal;"><span style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);">5.3</span></strong><span style="text-indent: 32px;">、</span><strong style="text-indent: 32px; white-space: normal;">文件流控件使用过程中常见问题</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">①<strong>文件流read方法读取文件读出来为空。</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">可能原因:读取长度比文件大小还大导致读取失败。<br/></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">解决办法:读取长度不要超过文件大小即属性qty。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">②<strong style="text-indent: 32px; white-space: normal;">文件流find方法查找换行符"\r",读取文件它的下一个字符不正常。</strong></p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;">可能原因:"\r"在屏幕里面存储的是0d 0a。</p><p style="white-space: normal; text-indent: 2em; line-height: 1.75em;"><span style="text-indent: 32px;">解决办法:</span>fs0.val=fs0.val+2这样赋值就会正常。</p><p style="text-indent: 0em; white-space: normal; line-height: 1.75em; text-align: center;">END</p><p><br/></p><p><br/></p> |