Difference between revisions of "Extensions.File.ReadBytes"

From emotive
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:OTX '''ReadBytes'''}}Category:File == Classification == {{ClassificationActivity | ReadBytes | UPDATING... | Term | Extensions.File|OTX File extension...")
 
Line 1: Line 1:
 
{{DISPLAYTITLE:OTX '''ReadBytes'''}}[[Category:File]]
 
{{DISPLAYTITLE:OTX '''ReadBytes'''}}[[Category:File]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | ReadBytes | UPDATING... | [[Term]] | [[Extensions.File|OTX File extension]] | UPDATING... | UPDATING... | UPDATING... }}
+
{{ClassificationActivity | ReadBytes| Reads bytes from the specified file | [[Term]] | [[Extensions.File|OTX File extension]] | [[Extensions.File#Terms|File related Terms]]| [[Extensions.File.FileAccessException|FileAccessException]] <br/>[[Extensions.File.FileFormatException|FileFormatException]] <br/> [[Extensions.File.FileLockException|FileLockException]]<br/> [[Core.DataTypes.ComplexDataType.OutOfBoundsException|OutOfBoundsException]]| - |}}
  
 
== OTL Syntax ==
 
== OTL Syntax ==
UPDATING...<!--
 
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
DiagCom.CloseComChannel(ComChannelVariable);
+
ByteFieldTerm= File.ReadBytes(FileReadHandleTerm, IntegerTerm, IntegerTerm);
 
</syntaxhighlight>
 
</syntaxhighlight>
-->
 
  
 
== Description ==
 
== Description ==
UPDATING...<!--
+
The '''ReadBytes''' activity reads bytes from the file specified in the file handle and returns a [[Core.DataTypes.ComplexDataType.ByteField|ByteField]]. The first read or write activity on a file handle defines if an access shall be realized by line, bytes or file. Mixed access will lead to a [[Extensions.File.FileFormatException|'''FileFormatException''']]. If index + count > file size, a [[Core.DataTypes.ComplexDataType.ByteField|ByteField]] containing the remaining bytes shall be returned.
OTX CloseComChannel activity is used for the [[Diagnosis Runtime System]] to announce that an open communication channel that all relevant resources can be released and closed.
+
 
{{ComChannelMemoryUsageNote}}
+
{{TermReturnValue| [[Core.DataTypes.ComplexDataType.ByteField|ByteField]] | Returns the bytes from the specified file as a ByteField.}}
{{Important|Please note that the use of a shared '''ComChannel''' can bring the OTX runtime system in an undefined state and that is this case is not validated at design time!}}
 
-->
 
  
 
== Properties ==
 
== Properties ==
UPDATING...<!--
 
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie1| ComChannel | [[Extensions.DiagCom.ComChannel|ComChannel]] | [[Variable]] | - | [1] | Communication Channel (Control unit).}}
+
{{TableRowPropertie2| handle| [[Extensions.File.FileReadHandle|FileReadHandle]] | [[Term]] | - | [1..1] |The handle to the file that the related file object encapsulates.}}
 +
{{TableRowPropertie1| index| [[Core.DataTypes.SimpleDataType.Integer|Integer]] | [[Term]] | - | [0..1] |Index for reading. If index is omitted, start reading at index of the first unread byte.}}
 +
{{TableRowPropertie2| count|[[Core.DataTypes.SimpleDataType.Integer|Integer]] | [[Term]] | - | [0..1] |The number of bytes to read. If count is omitted, read until the end of the file.}}
 
|}
 
|}
-->
 
  
 
== OTL Examples ==
 
== OTL Examples ==
UPDATING...<!--
 
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
DiagCom.ComChannel myComCannel;
+
File.FileReadHandle FileReadHandle1;
 +
ByteField ByteField1;
  
myComCannel = DiagCom.GetComChannel("DiagnosticsCan_ECU_1", null, false);
+
/// Flow
  
// Code example using the variable myComChannel
+
FileReadHandle1 = File.OpenFileForRead("file:///D:/abc.txt", @Encoding:UTF-8);
// ...
+
ByteField1 = File.ReadBytes(FileReadHandle1);
DiagCom.CloseComChannel(myComCannel);</syntaxhighlight>
 
 
</syntaxhighlight>
 
</syntaxhighlight>
-->
 
  
 
== See also ==
 
== See also ==
UPDATING...
+
[[Extensions.File.CreateTempDirectory|CreateTempDirectory]]<br/>
 +
[[Extensions.File.GetFilePath|GetFilePath]]<br/>
 +
[[Extensions.File.GetFilesFromDirectory|GetFilesFromDirectory]]<br/>
 +
[[Extensions.File.GetFileSize|GetFileSize]]<br/>
 +
[[Extensions.File.IsDirectory|IsDirectory]]<br/>
 +
[[Extensions.File.IsEndOfFileReached|IsEndOfFileReached]]<br/>
 +
[[Extensions.File.IsFile|IsFile]]<br/>
 +
[[Extensions.File.OpenFileForRead|OpenFileForRead]]<br/>
 +
[[Extensions.File.OpenFileForWrite|OpenFileForWrite]]<br/>
 +
<!--[[Extensions.File.ReadBytes|ReadBytes]]<br/>-->
 +
[[Extensions.File.ReadFile|ReadFile]]<br/>
 +
[[Extensions.File.ReadLine|ReadLine]]

Revision as of 10:25, 27 September 2018

Classification

Name ReadBytes
Short Description Reads bytes from the specified file
Class Term
Extension OTX File extension
Group File related Terms
Exceptions FileAccessException
FileFormatException
FileLockException
OutOfBoundsException
Checker Rules -
Standard Compliant Yes

OTL Syntax

ByteFieldTerm= File.ReadBytes(FileReadHandleTerm, IntegerTerm, IntegerTerm);

Description

The ReadBytes activity reads bytes from the file specified in the file handle and returns a ByteField. The first read or write activity on a file handle defines if an access shall be realized by line, bytes or file. Mixed access will lead to a FileFormatException. If index + count > file size, a ByteField containing the remaining bytes shall be returned.

Return Value

The Term returns the value, see table below.

Icons Note.png In OTX, Terms are categorized according to its return data type!
Data Type Description
ByteField Returns the bytes from the specified file as a ByteField.

Properties

Name Data Type Class Default Cardinality Description
handle FileReadHandle Term - [1..1] The handle to the file that the related file object encapsulates.
index Integer Term - [0..1] Index for reading. If index is omitted, start reading at index of the first unread byte.
count Integer Term - [0..1] The number of bytes to read. If count is omitted, read until the end of the file.

OTL Examples

File.FileReadHandle FileReadHandle1;
ByteField ByteField1;

/// Flow

FileReadHandle1 = File.OpenFileForRead("file:///D:/abc.txt", @Encoding:UTF-8);
ByteField1 = File.ReadBytes(FileReadHandle1);

See also

CreateTempDirectory
GetFilePath
GetFilesFromDirectory
GetFileSize
IsDirectory
IsEndOfFileReached
IsFile
OpenFileForRead
OpenFileForWrite
ReadFile
ReadLine