From 0b496b1ab406a5889818555286f38f0ebe731b93 Mon Sep 17 00:00:00 2001
From: Tim Stadtmann <tim.stadtmann@rwth-aachen.de>
Date: Fri, 20 Jan 2017 17:38:42 +0100
Subject: [PATCH] Implement new CommandLayer structure

The former Command-class is split up in several subclasses; implemented
new outputStart()-method exemplarily, the rest is WIP.
---
 source/CommunicationInterface.m    |  136 +-
 source/{Command.m => DataStream.m} | 2154 +++++++++++++---------------
 source/Packet.m                    |   45 +
 source/PacketType.m                |    9 +
 source/Program.m                   |  155 ++
 5 files changed, 1246 insertions(+), 1253 deletions(-)
 rename source/{Command.m => DataStream.m} (52%)
 create mode 100644 source/Packet.m
 create mode 100644 source/PacketType.m
 create mode 100644 source/Program.m

diff --git a/source/CommunicationInterface.m b/source/CommunicationInterface.m
index c110071..3f59603 100755
--- a/source/CommunicationInterface.m
+++ b/source/CommunicationInterface.m
@@ -126,6 +126,8 @@ classdef CommunicationInterface < handle
     properties (Hidden, Access = 'private')
         % Connection handle
         conn; 
+        
+        currentData = Packet();
     end
     
     methods
@@ -231,6 +233,12 @@ classdef CommunicationInterface < handle
             brick.debug = p.Results.debug;
         end
         
+        function sendStream(brick) 
+            brick.currentData.addHeader();
+            brick.conn.write(brick.currentData.msg);
+            brick.currentData.clear();
+        end
+        
         function send(brick, cmd)
             % Brick.send Send data to the brick
             %
@@ -287,7 +295,7 @@ classdef CommunicationInterface < handle
             
             % Check if reply is corrupt or error byte is set
             try
-                reply = Command(rmsg);
+                reply = Packet(rmsg);
             catch ME
                 corrupt = 1;
                 if ~isempty(strfind(ME.identifier, 'CorruptPacket'))
@@ -311,7 +319,7 @@ classdef CommunicationInterface < handle
                     while corrupt && retries
                         rmsg = brick.conn.read();
                         try
-                            reply = Command(rmsg);
+                            reply = Packet(rmsg);
                             corrupt = 0;
                         catch
                             retries = retries-1;
@@ -353,7 +361,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           voltage = b.uiReadVbatt()
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,4,0);
             cmd.opUI_READ_GET_VBATT(0);
             cmd.addLength();
@@ -375,7 +383,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           level = b.uiReadLbatt()
           
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,1,0);
             cmd.opUI_READ_GET_LBATT(0);
             cmd.addLength();
@@ -402,7 +410,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.soundTest()
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,1,0);
             cmd.opSOUND_TEST(0);
             cmd.addLength();
@@ -423,7 +431,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.soundReady()
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,0,0);
             cmd.opSOUND_READY();
             cmd.addLength();
@@ -446,7 +454,7 @@ classdef CommunicationInterface < handle
             % Example:: 
             %           b.soundPlayTone(5,400,500)
 
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opSOUND_TONE(volume,frequency,duration);
             cmd.addLength();
@@ -462,7 +470,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.soundStopTone()
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opSOUND_BREAK;
             cmd.addLength();
@@ -505,7 +513,7 @@ classdef CommunicationInterface < handle
             %           types = b.inputDeviceList();
             %
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,5,0);
             cmd.opINPUT_DEVICE_LIST(4,0,4);
             cmd.addLength();
@@ -531,7 +539,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           name = b.inputDeviceGetName(0,SensorPort.Sensor1)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,12,0);
             cmd.opINPUT_DEVICE_GET_NAME(layer,no,12,0);
             cmd.addLength();
@@ -559,7 +567,7 @@ classdef CommunicationInterface < handle
             %
             % Example::
             %          [type,mode] = b.inputDeviceTypeMode(0,SensorPort.Sensor1)
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,2,0);
             cmd.opINPUT_DEVICE_GET_TYPEMODE(layer,no,0,1);
             cmd.addLength();
@@ -574,7 +582,7 @@ classdef CommunicationInterface < handle
         % Implemented @ MMI
         function inputDeviceSetTypeMode(brick,oldType,oldMode,newType,newMode)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,0,0);
             cmd.opINPUT_DEVICE_SET_TYPEMODE(oldType,oldMode,newType,newMode);
             cmd.addLength();
@@ -599,7 +607,7 @@ classdef CommunicationInterface < handle
             %           mode = b.inputDeviceGetModeName(0,SensorPort.Sensor1,Device.Bumps)
             %               -> mode = BUMPS afterwards, if touch sensor is connected.
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,12,0);
             cmd.opINPUT_DEVICE_GET_MODENAME(layer,no,mode,12,0);
             cmd.addLength();
@@ -629,7 +637,7 @@ classdef CommunicationInterface < handle
             %           conn = b.inputDeviceGetConnection(0,SensorPort.Sensor1)
             %               -> conn = Device.CONN_NONE (if no sensor is detected at Port1)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,1,0);
             cmd.opINPUT_DEVICE_GET_CONNECTION(layer,no,0);
             cmd.addLength();
@@ -656,7 +664,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           [min,max] = brick.inputDeviceGetMinMax(0,SensorPort.Sensor1);
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,8,0);
             cmd.opINPUT_DEVICE_GET_MINMAX(layer,no,0,4);
             cmd.addLength();
@@ -688,7 +696,7 @@ classdef CommunicationInterface < handle
             % Example::
             %       changes = brick.inputDeviceGetChanges(0,SensorPort.Sensor1)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,4,0);
             cmd.opINPUT_DEVICE_GET_CHANGES(layer,no,0);
             cmd.addLength();
@@ -724,7 +732,7 @@ classdef CommunicationInterface < handle
             % Example::
             %       changes = brick.inputDeviceGetFormat(0,SensorPort.Sensor1)            
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,4,0);
             cmd.opINPUT_DEVICE_GET_FORMAT(layer,no,0,1,2,3);
             cmd.addLength();
@@ -754,7 +762,7 @@ classdef CommunicationInterface < handle
             % Example::
             %       changes = brick.inputDeviceGetBumps(0,SensorPort.Sensor1)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,4,0);
             cmd.opINPUT_DEVICE_GET_BUMPS(layer,no,0);
             cmd.addLength();
@@ -784,7 +792,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           name = b.inputDeviceSymbol(0,SensorPort.Sensor1)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,5,0);
             cmd.opINPUT_DEVICE_GET_SYMBOL(layer,no,5,0);
             cmd.addLength();
@@ -810,7 +818,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           name = b.inputDeviceClrChanges(0,SensorPort.Sensor1)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opINPUT_DEVICE_CLR_CHANGES(layer,no);
             cmd.addLength();
@@ -829,7 +837,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           name = b.inputDeviceClrAll(0)
             
-            cmd = Command();
+            cmd = Packet();
 %             cmd.addHeaderDirectReply(42,5,0);
             cmd.addHeaderDirect(42,0,0);
             cmd.opINPUT_DEVICE_CLR_ALL(layer);
@@ -852,7 +860,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.inputReady(0,SensorPort.Sensor1)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,0,0);
             cmd.opINPUT_READY(layer,no);
             cmd.addLength();
@@ -877,7 +885,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           state = b.inputTest(0,SensorPort.Sensor1)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,1,0);
             cmd.opINPUT_TEST(layer,no,0);
             cmd.addLength();
@@ -911,7 +919,7 @@ classdef CommunicationInterface < handle
             %                 -> returns seemingly pointless values (as
             %                 expected)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,1,0);
             cmd.opINPUT_READ(layer,no,0,mode,0);
             cmd.addLength();
@@ -941,7 +949,7 @@ classdef CommunicationInterface < handle
             %            reading = b.inputReadSI(0,SensorPort.Sensor1,Device.USDistCM)
             %            reading = b.inputReadSI(0,SensorPort.Sensor1,Device.Pushed)
            
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,4,0);
             cmd.opINPUT_READSI(layer,no,0,mode,0);
             cmd.addLength();
@@ -971,7 +979,7 @@ classdef CommunicationInterface < handle
             %            reading = b.inputReadSI(0,SensorPort.Sensor1,Device.USDistCM)
             %            reading = b.inputReadSI(0,SensorPort.Sensor1,Device.Pushed)
            
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,4,0);
             cmd.opINPUT_READSI(layer,no,type,mode,0);
             cmd.addLength();
@@ -998,7 +1006,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputStop(0,MotorBitfield.MotorA,BrakeMode.Brake)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_STOP(layer,nos,brake)
             cmd.addLength();
@@ -1017,7 +1025,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputStopAll(0)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_STOP(0,15,BrakeMode.Brake);
             cmd.addLength();
@@ -1038,7 +1046,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputPower(0,MotorBitfield.MotorA,50)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_POWER(layer,nos,power);
             cmd.addLength();
@@ -1059,7 +1067,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputSpeed(0,MotorBitfield.MotorA,50)            
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_SPEED(layer,nos,speed);
             cmd.addLength();
@@ -1079,11 +1087,15 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputStart(0,MotorBitfield.MotorA)
           
-            cmd = Command();
-            cmd.addHeaderDirect(42,0,0);
-            cmd.opOUTPUT_START(layer,nos);
-            cmd.addLength();
-            brick.send(cmd);
+%             cmd = Packet();
+%             cmd.addHeaderDirect(42,0,0);
+%             cmd.opOUTPUT_START(layer,nos);
+%             cmd.addLength();
+%             brick.send(cmd);
+            brick.currentData.opOUTPUT_START(layer, nos);
+            if brick.autoSend
+                brick.sendStream(); 
+            end
         end 
         
         function state = outputTest(brick,layer,nos)
@@ -1100,7 +1112,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           state = b.outputTest(0,MotorBitfield.MotorA)
           
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,1,0);
             cmd.opOUTPUT_TEST(layer,nos,0);
             cmd.addLength();
@@ -1125,7 +1137,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputReady(0,MotorBitfield.MotorA)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,0,0);
             cmd.opOUTPUT_READY(layer,nos);
             cmd.addLength();
@@ -1151,7 +1163,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputPolarity(0, MotorBitfield.MotorA, -1);
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_POLARITY(layer,nos,pol);
             cmd.addLength();
@@ -1178,7 +1190,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputStepPower(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_STEP_POWER(layer,nos,power,step1,step2,step3,brake);
             cmd.addLength();
@@ -1205,7 +1217,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputTimePower(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_TIME_POWER(layer,nos,power,step1,step2,step3,brake);
             cmd.addLength();
@@ -1231,7 +1243,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputStepSpeed(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_STEP_SPEED(layer,nos,speed,step1,step2,step3,brake);
             cmd.addLength();
@@ -1258,7 +1270,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputTimeSpeed(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_TIME_SPEED(layer,nos,speed,step1,step2,step3,brake);
             cmd.addLength();
@@ -1295,7 +1307,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputStepSync(0,MotorBitfield.MotorA+MotorBitfield.MotorB,50,50,360,BrakeMode.Coast)           
            
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_STEP_SYNC(layer,nos,power,turn,step,brake);
             cmd.addLength();
@@ -1331,7 +1343,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.outputTimeSync(0,MotorBitfield.MotorA+MotorBitfield.MotorB,50,50,360,BrakeMode.Coast)   
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_TIME_SYNC(layer,nos,power,turn,time,brake);
             cmd.addLength();
@@ -1351,7 +1363,7 @@ classdef CommunicationInterface < handle
             % Example::
             %            b.outputClrCount(0,MotorBitfield.MotorA)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_CLR_COUNT(layer,nos);
             cmd.addLength();
@@ -1372,7 +1384,7 @@ classdef CommunicationInterface < handle
             % Example::
             %             b.outputReset(0,MotorBitfield.MotorA)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opOUTPUT_RESET(layer,nos);
             cmd.addLength();
@@ -1396,7 +1408,7 @@ classdef CommunicationInterface < handle
             %           tacho = b.outputGetCount(0,MotorPort.MotorA)
 
 
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,4,0);
             cmd.opOUTPUT_GET_COUNT(layer,no,0);
             cmd.addLength();
@@ -1432,7 +1444,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           [speed,tacho] = b.outputRead(0,MotorPort.MotorA)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,5,0); 
             cmd.opOUTPUT_READ(layer,no,0,4); %%
             cmd.addLength();
@@ -1480,7 +1492,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           state = b.comTest(1, '0');
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,1,0);
             cmd.opCOM_TEST(hardware,name,0);
             cmd.addLength();
@@ -1506,7 +1518,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.comReady(2, '0');
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,0,0);
             cmd.opCOM_READY(hardware,name);
             cmd.addLength();
@@ -1523,7 +1535,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           name = b.comGetBrickName()
           
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,10,0);
             cmd.opCOMGET_GET_BRICKNAME(10,0);
             cmd.addLength();
@@ -1542,7 +1554,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.comSetBrickName('EV3')
           
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opCOMSET_SET_BRICKNAME(name);
             cmd.addLength();
@@ -1557,7 +1569,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           mac = b.comGetMACAddress()
           
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,36,0);
             cmd.opCOMGET_NETWORK(3,36,0,8,20);
             cmd.addLength();
@@ -1576,7 +1588,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           mac = b.comGetBTID()
           
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirectReply(42,12,0);
             cmd.opCOMGET_ID(2,12,0);
             cmd.addLength();
@@ -1605,7 +1617,7 @@ classdef CommunicationInterface < handle
             %           b.mailBoxWrite('T500','abc','numeric',4.24)
             %           b.mailBoxWrite('T500','abc','text','hello!')
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderDirect(42,0,0);
             cmd.opMAILBOX_WRITE(brickname,boxname,type,msg);
             cmd.addLength();
@@ -1632,7 +1644,7 @@ classdef CommunicationInterface < handle
             input = fread(fid,inf,'uint8=>uint8');
             fclose(fid); 
             % begin upload
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderSystemReply(10);
             cmd.BEGIN_DOWNLOAD(length(input),dest);
             cmd.addLength();
@@ -1670,7 +1682,7 @@ classdef CommunicationInterface < handle
             %           b.fileDownload('../apps/tst/tst.rbf','prg.rbf',59)
             
             % begin download
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderSystemReply(12);
             cmd.BEGIN_UPLOAD(maxlength,dest);
             cmd.addLength();
@@ -1703,7 +1715,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.listFiles('/home/root/lms2012/',100)
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderSystemReply(13);
             cmd.LIST_FILES(maxlength,pathname);
             cmd.addLength();
@@ -1725,7 +1737,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.createDir('/home/root/lms2012/newdir')
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderSystemReply(14);
             cmd.CREATE_DIR(pathname);
             cmd.addLength();
@@ -1746,7 +1758,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.deleteFile('/home/root/lms2012/newdir')
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderSystemReply(15);
             cmd.DELETE_FILE(pathname);
             cmd.addLength();
@@ -1769,7 +1781,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.writeMailBox('abc','text','hello!')
             
-            cmd = Command();
+            cmd = Packet();
             cmd.addHeaderSystem(16);
             cmd.WRITEMAILBOX(title,type,msg);
             cmd.addLength();
@@ -1822,7 +1834,7 @@ classdef CommunicationInterface < handle
             % Example::
             %           b.threeToneByteCode('threetone')
             
-            cmd = Command();
+            cmd = Packet();
             % program header
             cmd.PROGRAMHeader(0,1,0);                   % VersionInfo,NumberOfObjects,GlobalBytes
             cmd.VMTHREADHeader(0,0);                    % OffsetToInstructions,LocalBytes
diff --git a/source/Command.m b/source/DataStream.m
similarity index 52%
rename from source/Command.m
rename to source/DataStream.m
index bf20f96..0d53a90 100755
--- a/source/Command.m
+++ b/source/DataStream.m
@@ -1,7 +1,7 @@
 % EV3 command construction
 %
 % Methods::
-% Command                   Constructor, creates an empty command object
+% DataStream                   Constructor, creates an empty command object
 % delete                    Destructor, clears the command object
 %
 % addHeaderSystem           Adds a system header to the command object
@@ -146,14 +146,13 @@
 % description of the commands.
 %
 % Example::
-%                   cmd = Command();
-%                   cmd.addHeaderDirect(42,0,0);
-%                   cmd.opSOUND_TONE(volume,frequency,duration);
-%                   cmd.addLength();
+%                   dataStream = DataStream();
+%                   dataStream.addHeaderDirect(42,0,0);
+%                   dataStream.opSOUND_TONE(volume,frequency,duration);
+%                   dataStream.addLength();
 
 
-classdef Command < handle
-
+classdef (Abstract) DataStream < handle
     % Communications format (c_com.h):
     % /*
     %       System Command Bytes:
@@ -284,30 +283,35 @@ classdef Command < handle
     properties
         msg
     end
-
+    
+    methods (Abstract)
+        addHeader(data, varargin); 
+        addLength(data);
+    end
+    
     methods
-        function cmd = Command(varargin)
-            % Command.cmd Create an empty command
+        function dataStream = DataStream(varargin)
+            % DataStream.dataStream Create an empty DataStream
             %
-            % c = Command() is an object that represents an EV3 command
-            % c = Command([...]) is an object that represents an EV3 reply
+            % c = DataStream() is an object that represents an EV3 DataStream
+            % c = DataStream([...]) is an object that represents an EV3 reply
             %
             % Example::
-            %           c = Command();
+            %           c = DataStream();
             
             if nargin > 0  % Packet is a reply
                 try
-                    cmd.msg = uint8(varargin{1});
+                    dataStream.msg = uint8(varargin{1});
                 catch ME
                     id = [ID(), ':', 'InvalidParameter'];
-                    msg = 'Failed to create reply-packet with Command-class.';
+                    msg = 'Failed to create reply-packet with DataStream-class.';
                     baseException = MException(id, msg);
                     baseException = addCause(baseException, ME);
                     throw(baseException);
                 end
                 
                 % If corrupt, throw error
-                corrupt = cmd.isValidReply();
+                corrupt = dataStream.isValidReply();
                 if corrupt < 1
                     msg = 'Invalid reply packet';
                     id = [ID(), ':', 'CorruptPacket'];
@@ -325,44 +329,36 @@ classdef Command < handle
                     ME = addCause(ME, cause);
                     throw(ME);
                 end
-            else  % Packet is a command
-                cmd.msg = uint8([]);
+            else  % Packet is a DataStream
+                dataStream.msg = uint8([]);
             end
         end
-            
-        function delete(cmd)
-            % Command.delete Clear command
-            %
-            % delete(c) clears the command
-            
-            cmd.msg = '';
-        end
         
-        function errorDetected = checkForError(cmd)
-            % Command.checkForError Check command for error
+        function errorDetected = checkForError(dataStream)
+            % DataStream.checkForError Check DataStream for error
             %
             % error = checkForError() returns 1 if error byte in received
             % package is set and 0 if not.)
             % 
-            % Note:: - If 5th byte is set to 0x04 (direct command) or 0x05 
-            %        (system command) an error has occurred. 
+            % Note:: - If 5th byte is set to 0x04 (direct DataStream) or 0x05 
+            %        (system DataStream) an error has occurred. 
             %        (found in EV3 Communication Developer Kit.pdf)
-            %        - Only valid if cmd is a reply packet, of course.
+            %        - Only valid if dataStream is a reply packet, of course.
             
             % 5th byte in reply is used for error detection
             replyTypeOffset = 5; 
             errorDetected = 0;
             
-            if cmd.msg(replyTypeOffset) == 4 || cmd.msg(replyTypeOffset) == 5
+            if dataStream.msg(replyTypeOffset) == 4 || dataStream.msg(replyTypeOffset) == 5
                errorDetected = 1; 
             end
         end
         
-        function state = isValidReply(cmd)
-            % Command.isValidReply Check if reply-packet is valid
+        function state = isValidReply(dataStream)
+            % DataStream.isValidReply Check if reply-packet is valid
             %
-            % state = cmd.isValidReply checks cmd against reply-packet-format and returns
-            %                          whether if cmd is valid (that is, does not fit the 
+            % state = dataStream.isValidReply checks dataStream against reply-packet-format and returns
+            %                          whether if dataStream is valid (that is, does not fit the 
             %                          format).
             % Notes:
             %  - state = 1, if reply is not corrupted (at least not in a way that can be
@@ -378,285 +374,205 @@ classdef Command < handle
             
             % Minimum length of a reply packet is 5, for a packet without response buffer
             minLength = 5;
-            if length(cmd.msg) < minLength
+            if length(dataStream.msg) < minLength
                 state = 0; 
                 return
             end
             
             % Note: The two things that can be checked without context are the length and the 
-            %       command type, the remainder varies from packet to packet. 
-            pLength = double(typecast(cmd.msg(1:2),'uint16')) + 2;
-            pCmdType = cmd.msg(5);
+            %       DataStream type, the remainder varies from packet to packet. 
+            pLength = double(typecast(dataStream.msg(1:2),'uint16')) + 2;
+            pCmdType = dataStream.msg(5);
             
-            if pLength ~= length(cmd.msg)
+            if pLength ~= length(dataStream.msg)
                 state = -1;
             elseif pCmdType ~= 2 && pCmdType ~=4
                 state = -2;
             end
         end
         
-        function addHeaderSystem(cmd,counter)
-            % Command.addHeaderSystem Add a system header with no reply
-            %
-            % Commad.addHeaderSystem(counter) adds a system command header
-            % with no reply (0x81).
-            %
-            % Notes::
-            % - counter is a decimal number used as a message counter
-            %
-            % Example::
-            %            cmd.addHeaderSystem(42)
-            
-           cmd.msg = [cmd.msg typecast(uint16(counter), 'uint8'), uint8(129)];
-        end
-        
-        function addHeaderSystemReply(cmd,counter)
-            % Command.addHeaderSystemReply Add a system header with reply
-            %
-            % Command.addHeaderSystemReply(counter) adds a system command 
-            % header with reply (0x01).
-            %
-            % Notes::
-            % - counter is a decimal number used as a message counter
-            %
-            % Example::
-            %            cmd.addHeaderSystemReply(42)
-            
-           cmd.msg = [cmd.msg typecast(uint16(counter), 'uint8'), uint8(1)];
-        end
-        
-        function addHeaderDirect(cmd,counter,nGV,nLV)
-            % Command.addHeaderDirect Add a direct header with no reply
+        function addSystemDataStream(dataStream,v)
+            % DataStream.addSystemDataStream Add a system DataStream
             %
-            % Command.addHeaderDirect(counter,GV,LV) Adds a direct command 
-            % header with no reply (0x80).
+            % DataStream.addSystemDataStream(v) adds a system DataStream to the
+            % DataStream object.
             %
             % Notes::
-            % - counter is a decimal number used as a message counter
-            % - nGV is the number of 1 byte global variables needed.
-            % - nLV is the number of 1 byte local variables needed.
-            % - If you needed a global float variable or 2 uint16s then GV = 4.
-            % - If you needed a local uint16 variable then LV = 2.
-            %
-            % Example::
-            %            cmd.addHeaderDirect(42,0,0)
-            
-           cmd.msg = [cmd.msg typecast(uint16(counter), 'uint8'), uint8(128), typecast(bitor(bitshift(uint16(nLV),10),uint16(nGV)), 'uint8')];
-        end
-        
-        function addHeaderDirectReply(cmd,counter,nGV,nLV)
-            % Command.addHeaderDirectReply Add a direct header with reply
-            %
-            % Command.addHeaderDirect(counter,nGV,nLV) Adds a direct command 
-            % header with reply (0x00).
-            %
-            % Notes::
-            % - counter is a decimal number used as a message counter
-            % - nGV is the number of 1 byte global variables needed.
-            % - nLV is the number of 1 byte local variables needed.
-            % - If you needed a global float varible then nGV = 4.
-            % - If you needed a local uint16 variable then nLV = 2.
-            % 
-            % Example::
-            %            cmd.addHeaderDirectReply(42,0,0)
-            
-           cmd.msg = [cmd.msg typecast( uint16(counter), 'uint8'), uint8(0), typecast( bitor(bitshift(uint16(nLV),10),uint16(nGV)), 'uint8')];
-        end
-        
-        function addLength(cmd)
-            % Command.addLength Add command length
-            %
-            % Command.addLength() adds the command message length to the 
-            % start of command object message.
+            % - v is the system DataStreams which can be found in c_com.h
             % 
             % Example::
-            %            cmd.addLength()
+            %            dataStream.addSystemDataStream(SystemDataStreams.BeginDownload)
             
-           cmd.msg = [typecast( uint16(length(cmd.msg)), 'uint8') cmd.msg]; 
+           dataStream.msg = [dataStream.msg uint8(v)]; 
         end
         
-        function addSystemCommand(cmd,v)
-            % Command.addSystemCommand Add a system command
+        function addDirectDataStream(dataStream,v)
+            % DataStream.addDirectDataStream Add a direct DataStream
             %
-            % Command.addSystemCommand(v) adds a system command to the
-            % command object.
+            % DataStream.addDirectDataStream(v) adds a direct DataStream to the
+            % DataStream object.
             %
             % Notes::
-            % - v is the system commands which can be found in c_com.h
-            % 
-            % Example::
-            %            cmd.addSystemCommand(SystemCommands.BeginDownload)
-            
-           cmd.msg = [cmd.msg uint8(v)]; 
-        end
-        
-        function addDirectCommand(cmd,v)
-            % Command.addDirectCommand Add a direct command
-            %
-            % Command.addDirectCommand(v) adds a direct command to the
-            % command object.
-            %
-            % Notes::
-            % - v is the direct commands opcode can be found in ByteCodes.m
+            % - v is the direct DataStreams opcode can be found in ByteCodes.m
             %
             % Example::
-            %            cmd.addDirectCommand(SoundSubCodes.Tone)
+            %            dataStream.addDirectDataStream(SoundSubCodes.Tone)
             
-           cmd.msg = [cmd.msg uint8(v)]; 
+           dataStream.msg = [dataStream.msg uint8(v)]; 
         end
         
-        function clear(cmd)
-            % Command.clear Clear command
+        function clear(dataStream)
+            % DataStream.clear Clear DataStream
             %
             % Commad.clear clears the message
             %
             % Example::
-            %           cmd.clear()
+            %           dataStream.clear()
 
-            cmd.msg = '';
+            dataStream.msg = '';
         end
         
-        function s = char(cmd)
+        function s = char(dataStream)
             s = '';
-            for i=1:length(cmd.msg)
-                s = [s sprintf(' %d', cmd.msg(i))];
+            for i=1:length(dataStream.msg)
+                s = [s sprintf(' %d', dataStream.msg(i))];
             end
         end
         
-        function s = hex(cmd)
+        function s = hex(dataStream)
             s = '';
-            for i=1:length(cmd.msg)
-                s = [s sprintf(' %x', cmd.msg(i))];
+            for i=1:length(dataStream.msg)
+                s = [s sprintf(' %x', dataStream.msg(i))];
             end
         end
         
-        function display(cmd)
-            % Command.display Display the command message (decimal)
+        function display(dataStream)
+            % DataStream.display Display the DataStream message (decimal)
             %
-            % Command.display() prints the command message to the MATLAB
-            % command window in decimal format.
+            % DataStream.display() prints the DataStream message to the MATLAB
+            % DataStream window in decimal format.
             %
             % Example::
-            %           cmd.display()
+            %           dataStream.display()
             
             loose = strcmp( get(0, 'FormatSpacing'), 'loose');
             if loose
                 disp(' ');
             end
             disp([inputname(1), ' = '])
-            disp( char(cmd) );
+            disp( char(dataStream) );
         end 
         
-        function displayHex(cmd)
-            % Command.displayHex Display the command message (hex)
+        function displayHex(dataStream)
+            % DataStream.displayHex Display the DataStream message (hex)
             %
-            % Command.displayHex() prints the command message to the MATLAB
-            % command window in hexadecimal format.
+            % DataStream.displayHex() prints the DataStream message to the MATLAB
+            % DataStream window in hexadecimal format.
             %
             % Example::
-            %           cmd.displayHex()
+            %           dataStream.displayHex()
             
             loose = strcmp( get(0, 'FormatSpacing'), 'loose');
             if loose
                 disp(' ');
             end
             disp([inputname(1), ' = '])
-            disp( hex(cmd) );
+            disp( hex(dataStream) );
         end 
         
-        function LC0(cmd,v)
-            % Command.LC0 Add a local constant 0 
+        function LC0(dataStream,v)
+            % DataStream.LC0 Add a local constant 0 
             %
-            % Command.LC0(v) adds a local constant 0 to the command object.
+            % DataStream.LC0(v) adds a local constant 0 to the DataStream object.
             %
             % Notes::
-            % - v is the numerical value for the LC0 command
+            % - v is the numerical value for the LC0 DataStream
             % - Local constant 0 is defined as ((v & PRIMPAR_VALUE) | PRIMPAR_SHORT |
             %   PRIMPAR_CONST) (which equals v)
             % - LC0 has a range from -32 to 31 since PRIMPAR_VALUE = 3F
             % 
             % Examples::
-            %           cmd.LC0(10) --> cmd.msg = (cmd.msg 10)
+            %           dataStream.LC0(10) --> dataStream.msg = (dataStream.msg 10)
             
-            cmd.msg = [cmd.msg bitor(bitand(typecast(int8(v),'uint8'),uint8(Primitives.pvalue)),bitor(uint8(Primitives.pshort),uint8(Primitives.pconst)))]; 
+            dataStream.msg = [dataStream.msg bitor(bitand(typecast(int8(v),'uint8'),uint8(Primitives.pvalue)),bitor(uint8(Primitives.pshort),uint8(Primitives.pconst)))]; 
         end
         
-        function LC1(cmd,v)
-            % Command.LC1 Add a local constant 1
+        function LC1(dataStream,v)
+            % DataStream.LC1 Add a local constant 1
             %
-            % Command.LC1(v) adds a local constant 1 to the command object.
+            % DataStream.LC1(v) adds a local constant 1 to the DataStream object.
             %
             % Notes::  
             % - LC1(v) is defined as (PRIMPAR_LONG  | PRIMPAR_CONST | PRIMPAR_1_BYTE),(v & 0xFF)
             % - LC1 has a range from -127 to 128    
-            % - v is the numerical value for the LC1 command
+            % - v is the numerical value for the LC1 DataStream
             % - resulting part of msg will be 2 bytes long:
             %   -> byte 1 = indicator(129) that 1 byte will follow 
             %   -> byte 2 = v
             % 
             % Examples::
-            %           cmd.LC1(100) --> cmd.msg = (cmd.msg 129 10)
+            %           dataStream.LC1(100) --> dataStream.msg = (dataStream.msg 129 10)
             
-            cmd.msg = [cmd.msg bitor(bitor(uint8(Primitives.plong),uint8(Primitives.pconst)),(uint8(Primitives.p1_byte))), bitand(typecast(int8(v),'uint8'),255)];
+            dataStream.msg = [dataStream.msg bitor(bitor(uint8(Primitives.plong),uint8(Primitives.pconst)),(uint8(Primitives.p1_byte))), bitand(typecast(int8(v),'uint8'),255)];
         end
         
-        function LC2(cmd,v)
-            % Command.LC2 Add a local constant 2 
+        function LC2(dataStream,v)
+            % DataStream.LC2 Add a local constant 2 
             %
-            % Command.LC2(v) adds a local constant 2 to the command object.
+            % DataStream.LC2(v) adds a local constant 2 to the DataStream object.
             %
             % Notes::
             % - Local constant 2 is defined as (PRIMPAR_LONG  | PRIMPAR_CONST | PRIMPAR_2_BYTES),(v & 0xFF),((v >> 8) & 0xFF)
             % - LC2 has a range from -32768 to 32767
-            % - v is the numerical value for the LC2 command
+            % - v is the numerical value for the LC2 DataStream
             % - resulting part of msg will be 3 bytes long:
             %   -> byte 1   = indicator(130) that 2 bytes will follow 
             %   -> byte 2-3 = v
             %
             % Examples::
-            %           cmd.LC2(1000) --> cmd.msg = (cmd.msg 130 232 3)
+            %           dataStream.LC2(1000) --> dataStream.msg = (dataStream.msg 130 232 3)
                         
-            cmd.msg = [cmd.msg bitor(bitor(uint8(Primitives.plong),uint8(Primitives.pconst)),(uint8(Primitives.p2_byte))), typecast(int16(v), 'uint8')];
+            dataStream.msg = [dataStream.msg bitor(bitor(uint8(Primitives.plong),uint8(Primitives.pconst)),(uint8(Primitives.p2_byte))), typecast(int16(v), 'uint8')];
         end
         
-        function LC4(cmd,v)
-            % Command.LC4 Add a local constant 4
+        function LC4(dataStream,v)
+            % DataStream.LC4 Add a local constant 4
             %
-            % Command.LC4(v) adds a local constant 4 to the command object.
+            % DataStream.LC4(v) adds a local constant 4 to the DataStream object.
             %
             % Notes::
             % - Local constant 4 is defined as(PRIMPAR_LONG  | PRIMPAR_CONST | PRIMPAR_4_BYTES),((ULONG)v & 0xFF),(((ULONG)v >> (ULONG)8) & 0xFF),(((ULONG)v >> (ULONG)16) & 0xFF),(((ULONG)v >> (ULONG)24) & 0xFF)
             % - LC4 has a range from -2,147,483,648 to 2,147,483,647
-            % - v is the numerical value for the LC4 command
+            % - v is the numerical value for the LC4 DataStream
             % - resulting part of msg will be 5 bytes long:
             %   -> byte 1   = indicator(131) that 4 bytes will follow 
             %   -> byte 2-5 = v 
             %
             % Examples::
-            %           cmd.LC4(10000) --> = (cmd.msg 131 16 39 0 0)
+            %           dataStream.LC4(10000) --> = (dataStream.msg 131 16 39 0 0)
             
-            cmd.msg = [cmd.msg bitor(bitor(uint8(Primitives.plong),uint8(Primitives.pconst)),(uint8(Primitives.p4_byte))), typecast(int32(v), 'uint8')];
+            dataStream.msg = [dataStream.msg bitor(bitor(uint8(Primitives.plong),uint8(Primitives.pconst)),(uint8(Primitives.p4_byte))), typecast(int32(v), 'uint8')];
         end
         
-        function LV0(cmd,i)
-            % Command.LV0 Add a local variable 0
+        function LV0(dataStream,i)
+            % DataStream.LV0 Add a local variable 0
             % 
-            % Command.LV0(i) adds a local variable 0 to the command object.
+            % DataStream.LV0(i) adds a local variable 0 to the DataStream object.
             %
             % Notes::
             % - Local variable 0 is defined as ((i & PRIMPAR_INDEX) | PRIMPAR_SHORT | PRIMPAR_VARIABEL | PRIMPAR_LOCAL)
             % - i is the number of 1 byte local variables needed.
             % 
             % Example::
-            %           cmd.LV0(1)
+            %           dataStream.LV0(1)
             
-            cmd.msg = [cmd.msg bitor(bitor(bitor(bitand(uint8(i),Primitives.pindex),Primitives.pshort),Primitives.pvariabel),Primitives.plocal)];
+            dataStream.msg = [dataStream.msg bitor(bitor(bitor(bitand(uint8(i),Primitives.pindex),Primitives.pshort),Primitives.pvariabel),Primitives.plocal)];
         end
         
-        function GV0(cmd,i)
-            % Command.GV0 Add a global variable 0
+        function GV0(dataStream,i)
+            % DataStream.GV0 Add a global variable 0
             %
-            % Command.GV0(i) adds a global variable 0 to the command
+            % DataStream.GV0(i) adds a global variable 0 to the DataStream
             % object.
             % 
             % Notes::
@@ -664,92 +580,92 @@ classdef Command < handle
             % - i is the address in response buffer of reply packet where returned data should
             %   be stored
             % - the response buffer starts at byte 5 and ends at byte 5+nGV
-            % - nGV defined in addHeaderDirectReply, used when creating command in Brick.m
+            % - nGV defined in addHeaderDirectReply, used when creating DataStream in Brick.m
             % 
             % Example::
-            %            cmd.GV0(0)--> Starting at byte 5, first n (see addHeaderDirectReply) bytes 
+            %            dataStream.GV0(0)--> Starting at byte 5, first n (see addHeaderDirectReply) bytes 
             %                          in response buffer of reply packet are reserved for returning data
             %                          (n=1 for DATA8, n=4 for DATAF, etc.). 
             %                          Note: If nGV>n, remaining packet filled with either zeros or 
             %                                seemingly pointless data...
-            % cmd.GV0(0);cmd.GV0(1)--> first byte in response buffer for DATA8, next nGV-1 bytes
+            % dataStream.GV0(0);dataStream.GV0(1)--> first byte in response buffer for DATA8, next nGV-1 bytes
             %                          for something else (e.g. DATA32, if nGV>=5)
             
-            cmd.msg = [cmd.msg bitor(bitor(bitor(bitand(uint8(i),Primitives.pindex),Primitives.pshort),Primitives.pvariabel),Primitives.pglobal)];
+            dataStream.msg = [dataStream.msg bitor(bitor(bitor(bitand(uint8(i),Primitives.pindex),Primitives.pshort),Primitives.pvariabel),Primitives.pglobal)];
         end
         
         % Implemented @ MMI
         % WIP
-        function GV1(cmd,i)
+        function GV1(dataStream,i)
             % (PRIMPAR_LONG  | PRIMPAR_VARIABEL | PRIMPAR_GLOBAL | PRIMPAR_1_BYTE),(i & 0xFF)
-            cmd.msg = [cmd.msg bitor(bitor(bitor(Primitives.pglobal,Primitives.p1_byte),Primitives.pvariabel),Primitives.plong) bitand(i,255)];
+            dataStream.msg = [dataStream.msg bitor(bitor(bitor(Primitives.pglobal,Primitives.p1_byte),Primitives.pvariabel),Primitives.plong) bitand(i,255)];
         end
         
         % Implemented @ MMI
         % WIP       
-        function GV2(cmd,i)
+        function GV2(dataStream,i)
            % (PRIMPAR_LONG  | PRIMPAR_VARIABEL | PRIMPAR_GLOBAL | PRIMPAR_2_BYTES),(i & 0xFF),((i >> 8) & 0xFF) 
-           cmd.msg = [cmd.msg bitor(bitor(bitor(Primitives.pglobal,Primitives.p2_byte),Primitives.pvariabel),Primitives.plong) bitand(i,255) bitand(bitshift(i,-8),255)];
+           dataStream.msg = [dataStream.msg bitor(bitor(bitor(Primitives.pglobal,Primitives.p2_byte),Primitives.pvariabel),Primitives.plong) bitand(i,255) bitand(bitshift(i,-8),255)];
         end
         
         % Implemented @ MMI
         % WIP
-        function GV4(cmd,i)
+        function GV4(dataStream,i)
             % (PRIMPAR_LONG  | PRIMPAR_VARIABEL | PRIMPAR_GLOBAL | PRIMPAR_4_BYTES),(i & 0xFF),((i >> 8) & 0xFF),((i >> 16) & 0xFF),((i >> 24) & 0xFF)
-            cmd.msg = [cmd.msg bitor(bitor(bitor(Primitives.pglobal,Primitives.p4_byte),Primitives.pvariabel),Primitives.plong) bitand(i,255) bitand(bitshift(i,-8),255) bitand(bitshift(i,-16),255) bitand(bitshift(i,-24),255)];
+            dataStream.msg = [dataStream.msg bitor(bitor(bitor(Primitives.pglobal,Primitives.p4_byte),Primitives.pvariabel),Primitives.plong) bitand(i,255) bitand(bitshift(i,-8),255) bitand(bitshift(i,-16),255) bitand(bitshift(i,-24),255)];
         end    
         
-        function LCS(cmd)
-            % Command.LCS Add a local constant string
+        function LCS(dataStream)
+            % DataStream.LCS Add a local constant string
             %
-            % Command.LCS() adds a local constant string to the command
+            % DataStream.LCS() adds a local constant string to the DataStream
             % object.
             %
             % Notes::
             % - Local constant string is defined as (PRIMPAR_LONG | PRIMPAR_STRING)
             %
             % Example::
-            %           cmd.LCS()
+            %           dataStream.LCS()
             
-            cmd.msg = [cmd.msg bitor(Primitives.plong,Primitives.pstring)];
+            dataStream.msg = [dataStream.msg bitor(Primitives.plong,Primitives.pstring)];
         end
         
-        function addValue(cmd,v)
-            % Command.addValue add a numerical value
+        function addByteCode(dataStream,v)
+            % DataStream.addValue add a numerical value
             %
-            % Command.addValue adds a numerical value to the command
+            % DataStream.addValue adds a numerical value to the DataStream
             % object.
             %
             % Notes::
             % - v is the numerical value to be added with range -128 to 127
             %
             % Example::
-            %           cmd.addValue(10)
+            %           dataStream.addValue(10)
             
-            cmd.msg = [cmd.msg uint8(v)];
+            dataStream.msg = [dataStream.msg uint8(v)];
         end
         
-        function addArray(cmd,txt)
-            % Command.addArray add a numerical array
+        function addArray(dataStream,txt)
+            % DataStream.addArray add a numerical array
             %
-            % Command.addArray(txt) adds a numerical array to the command
+            % DataStream.addArray(txt) adds a numerical array to the DataStream
             % object.
             %
             % Notes::
             % - txt is the numerical array to be added
             % 
             % Example::
-            %           cmd.addArray([1,2,3,4,5])
+            %           dataStream.addArray([1,2,3,4,5])
             
             for i=1:length(txt)
-               cmd.addValue(txt(i)); 
+               dataStream.addValue(txt(i)); 
             end   
         end
         
-        function addString(cmd,txt)
-            % Command.addString add a string
+        function addString(dataStream,txt)
+            % DataStream.addString add a string
             %
-            % Commad.addString(txt) adds a string to the command object.
+            % Commad.addString(txt) adds a string to the DataStream object.
             %
             % Notes::
             % - txt is the string to be added
@@ -758,19 +674,19 @@ classdef Command < handle
             % - on most occasions addLCSString should be used
             %
             % Example::
-            %           cmd.addString('hello')
+            %           dataStream.addString('hello')
             
             for i=1:length(txt)
-               cmd.addValue(txt(i)); 
+               dataStream.addValue(txt(i)); 
             end
-            cmd.addValue(0);    
+            dataStream.addValue(0);    
         end
         
-        function addLCSString(cmd,txt)
-            % Command.addLCSString add a string with the LCS type
+        function addLCSString(dataStream,txt)
+            % DataStream.addLCSString add a string with the LCS type
             %
-            % Command.addLCSString(txt) adds a string to the command object
-            % with the LCS command as well.
+            % DataStream.addLCSString(txt) adds a string to the DataStream object
+            % with the LCS DataStream as well.
             %
             % Notes::
             % - txt is the string to be added
@@ -778,19 +694,19 @@ classdef Command < handle
             % string.
             %
             % Example::
-            %           cmd.addLCSString('hello')
+            %           dataStream.addLCSString('hello')
             
-            cmd.LCS;
+            dataStream.LCS;
             for i=1:length(txt)
-               cmd.addValue(txt(i)); 
+               dataStream.addValue(txt(i)); 
             end
-            cmd.addValue(0);    
+            dataStream.addValue(0);    
         end
         
-        function LONGToBytes(cmd,x)
-            % Command.LONGToBytes add a LONGToBytes
+        function LONGToBytes(dataStream,x)
+            % DataStream.LONGToBytes add a LONGToBytes
             %
-            % Command.LONGToBytes(x) adds a LONGToBytes to the command
+            % DataStream.LONGToBytes(x) adds a LONGToBytes to the DataStream
             % object.
             %
             % Notes::
@@ -798,15 +714,15 @@ classdef Command < handle
             % - LONGToBytes is defined as(UBYTE)((_x) & 0xFF),(UBYTE)((_x >> 8) & 0xFF),(UBYTE)((_x >> 16) & 0xFF),(UBYTE)((_x >> 24) & 0xFF)
             %
             % Example::
-            %           cmd.LONGToBytes(1)
+            %           dataStream.LONGToBytes(1)
             
-            cmd.msg = [cmd.msg typecast(uint32(x), 'uint8')];
+            dataStream.msg = [dataStream.msg typecast(uint32(x), 'uint8')];
         end
         
-        function WORDToBytes(cmd,x)
-            % Command.WORDToBytes add a WORDToBytes
+        function WORDToBytes(dataStream,x)
+            % DataStream.WORDToBytes add a WORDToBytes
             %
-            % Command.WORDToBytes(x) adds a WORDToBytes to the command
+            % DataStream.WORDToBytes(x) adds a WORDToBytes to the DataStream
             % object.
             %
             % Notes::
@@ -814,15 +730,15 @@ classdef Command < handle
             % - WORDToBytes is defined as (UBYTE)((_x) & 0xFF),(UBYTE)((_x >> 8) & 0xFF)
             %
             % Example::
-            %           cmd.WORDToBytes(1)
+            %           dataStream.WORDToBytes(1)
             
-            cmd.msg = [cmd.msg typecast(uint16(x), 'uint8')];
+            dataStream.msg = [dataStream.msg typecast(uint16(x), 'uint8')];
         end
         
-        function BYTEToBytes(cmd,x)
-            % Command.BYTEToBytes add a BYTEToBytes
+        function BYTEToBytes(dataStream,x)
+            % DataStream.BYTEToBytes add a BYTEToBytes
             %
-            % Command.BYTEToBytes(x) adds a BYTEToBytes to the command
+            % DataStream.BYTEToBytes(x) adds a BYTEToBytes to the DataStream
             % object.
             %
             % Notes::
@@ -830,263 +746,119 @@ classdef Command < handle
             % - BYTEToBytes is defined as (UBYTE)((_x) & 0xFF)
             %
             % Example::
-            %           cmd.BYTEToBytes(1)
+            %           dataStream.BYTEToBytes(1)
             
-            cmd.msg = [cmd.msg uint8(x)];
+            dataStream.msg = [dataStream.msg uint8(x)];
         end
         
-        function PROGRAMHeader(cmd,VersionInfo,NumberOfObjects,GlobalBytes)
-            % Command.PROGRAMHeader add a PROGRAMHeader
-            %
-            % Command.PROGRAMHeader(VersionInfo,NumberOfObjects,GlobalBytes) 
-            % adds a PROGRAMHeader to the command object.
+        function GenerateByteCode(dataStream, fileName)
+            % DataStream.GenerateByteCode Generate byte code
             %
-            % Notes::
-            % - VersionInfo is not used in the current byte implementation
-            % (hardcoded to 1.04)
-            % - NumberOfObjects is the number of objects used
-            % - GlobalBytes is the number of global bytes
-            % - PROGRAMHEADER is defined as 'L','E','G','O',LONGToBytes(0),WORDToBytes((UWORD)(BYTECODE_VERSION * 100.0)),WORDToBytes(NumberOfObjects),LONGToBytes(GlobalBytes)
-            %
-            % Example::
-            %           cmd.PROGRAMHeader(0,1,0)
-            
-            BYTECODE_VERSION = 1.04;
-            cmd.msg = [cmd.msg,uint8('L'),uint8('E'),uint8('G'),uint8('O')] ;
-            cmd.LONGToBytes(0);
-            cmd.WORDToBytes(BYTECODE_VERSION*100);
-            cmd.WORDToBytes(NumberOfObjects);
-            cmd.LONGToBytes(GlobalBytes);
-        end
-        
-        function addFileSize(cmd)
-            % Command.addFileSize Add file size
-            % 
-            % Command.addFileSize() adds the file size to the command
-            % object.
-            %
-            % Notes::
-            % - With bytecode compiling using "Old header", the file size is 
-            % inserted at byte number 5 which corresponds to the two bytes 
-            % after 'L','E','G','O'
-            %
-            % Example::
-            %            cmd.addFileSize
-            
-            cmd.msg(5:6) = typecast(uint16(length(cmd.msg)),'uint8');            
-        end
-        
-        function VMTHREADHeader(cmd,OffsetToInstructions,LocalBytes)
-            % Command.VMTHREADHeader Add a VMTHREADHeader
-            %
-            % Command.VMTHREADHeader(OffsetToInstructions,LocalBytes)
-            % adds a VMTHREADHeader to the command object.
-            %
-            % Notes::
-            % - OffsetToInstructions is the offset to the instructions
-            % - LocalBytes is the number of local bytes
-            % - VMTHREADHeader is defined as LONGToBytes(OffsetToInstructions),0,0,0,0,LONGToBytes(LocalBytes)
-            %
-            % Example::
-            %           cmd.VMTHREADHeader(0,1)
-            
-            cmd.LONGToBytes(OffsetToInstructions);
-            cmd.msg = [cmd.msg uint8(0),uint8(0),uint8(0),uint8(0)];
-            cmd.LONGToBytes(LocalBytes) ;
-        end
-        
-        function SUBCALLHeader(cmd,OffsetToInstructions,LocalBytes)
-            % Command.SUBCALLHeader Add a SUBCALLHeader
-            %
-            % Command.SUBCALLHeader(OffsetToInstructions,LocalBytes)
-            % adds a SUBCALLHeader to the command object.
-            %
-            % Notes::
-            % - OffsetToInstructions is the offset to the instructions
-            % - LocalBytes is the number of local bytes
-            % - SUBCALLHeader is defined as LONGToBytes(OffsetToInstructions),0,0,1,0,LONGToBytes(LocalBytes)
-            %
-            % Example::
-            %           cmd.SUBCALLHeader(0,1)
-            
-            cmd.LONGToBytes(OffsetToInstructions);
-            cmd.msg = [cmd.msg uint8(0),uint8(0),uint8(1),uint8(0)];
-            cmd.LONGToBytes(LocalBytes) ;
-        end
-        
-        function BLOCKHeader(cmd,OffsetToInstructions,OwnerObjectId,TriggerCount)
-            % Command.BLOCKHeader
-            %
-            % Command.BLOCKHeader(OffsetToInstructions,OwnerObjectId,TriggerCount)
-            % adds a BLOCKHeader to the command object.
-            %
-            % Notes::
-            % - OffsetToInstructions is the offset to the instructions
-            % - OwnerObjectId is the owner object id
-            % - TriggerCount is the trigger count
-            % - BLOCKHeader is defined as LONGToBytes(OffsetToInstructions),WORDToBytes(OwnerObjectId),WORDToBytes(TriggerCount),LONGToBytes(0)
-            %
-            % Example::
-            %           cmd.BLOCKHeader(0,0,0)
-            
-            cmd.LONGToBytes(OffsetToInstructions);
-            cmd.WORDToBytes(OwnerObjectId);
-            cmd.WORDToBytes(TriggerCount)
-            cmd.LONGToBytes(0);
-        end  
-        
-        function GenerateByteCode(cmd, fileName)
-            % Command.GenerateByteCode Generate byte code
-            %
-            % Command.GenerateByteCode(fileName) prints the byte code in
-            % the command object to a file. This file can then be uplodaded
+            % DataStream.GenerateByteCode(fileName) prints the byte code in
+            % the DataStream object to a file. This file can then be uplodaded
             % and executed directly on the brick.
             % 
             % Example::
-            %           cmd.GenerateByteCode('tst.rbf')
+            %           dataStream.GenerateByteCode('tst.rbf')
 
             fid = fopen([fileName '.rbf'], 'w');
-            fwrite(fid,cmd.msg,'uint8');
+            fwrite(fid,dataStream.msg,'uint8');
             fclose(fid);
-            fprintf('Wrote %d bytes to %s.rbf\n',length(cmd.msg),fileName);
-        end
-        
-        function opNOP(cmd)
-            % Command.opNOP Add a opNOP 
-            %
-            % Command.opNOP() adds a opNOP opcode to the command object.
-            %
-            % Example::
-            %           cmd.opNOP()
-           
-            cmd.addDirectCommand(ByteCodes.Nop);            
-        end
-        
-        function opOBJECT_END(cmd)
-            % Command.opOBJECT_END Add a opOBJECT_END
-            % 
-            % Command.opOBJECT_END() adds a opOBJECT_END opcode to the
-            % command object. 
-            %
-            % Notes::
-            % - opOBJECT_END
-            %
-            % Example::            
-            %           cmd.opOBJECT_END()
-           
-            cmd.addDirectCommand(ByteCodes.ObjectEnd);
-        end
-        
-        function opJR(cmd,offset)
-            % Command.opJR Add a opJR
-            %
-            % Command.opJR(offset) adds a opJR opcode to the command
-            % object.
-            %
-            % Notes::
-            % - offset is the number of command to jump where the sign
-            % indicates the jump direction
-            % - opJR,LC0(offset)
-            %
-            % Example::
-            %           cmd.opJR(-10)
-
-            cmd.addDirectCommand(ByteCodes.Jr);
-            cmd.LC0(offset);
+            fprintf('Wrote %d bytes to %s.rbf\n',length(dataStream.msg),fileName);
         end
         
-        function opUI_FLUSH(cmd)
-            % Command.opUI_FLUSH Add a opUI_FLUSH
+        function opUI_FLUSH(dataStream)
+            % DataStream.opUI_FLUSH Add a opUI_FLUSH
             %
-            % Command.opUI_FLUSH() adds a opUI_FLUSH opcode to the command
+            % DataStream.opUI_FLUSH() adds a opUI_FLUSH opcode to the DataStream
             % object.
             %
             % Notes::
             % opUI_FLUSH
             %
             % Example::
-            %           cmd.opUI_FLUSH()
+            %           dataStream.opUI_FLUSH()
             
-            cmd.addDirectCommand(ByteCodes.UIFlush);
+            dataStream.addDirectDataStream(ByteCodes.UIFlush);
         end
         
-        function opUI_READ_GET_VBATT(cmd,value)
-            % Command.opUI_READ_GET_VBATT Add a opUI_READ_GET_VBATT
+        function opUI_READ_GET_VBATT(dataStream,value)
+            % DataStream.opUI_READ_GET_VBATT Add a opUI_READ_GET_VBATT
             %
-            % Command.opUI_READ_GET_VBATT adds a opUI opcode with a 
-            % READ_GET_VBATT subcode to the command object.
+            % DataStream.opUI_READ_GET_VBATT adds a opUI opcode with a 
+            % READ_GET_VBATT subcode to the DataStream object.
             %
             % Notes::
             % - value is the address in response buffer where value (DATA32) should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opUI_READ,LC0(1),GV0(value)
             %
             % Example::
-            %           cmd.opUI_READ_GET_VBATT(0)
+            %           dataStream.opUI_READ_GET_VBATT(0)
             
-            cmd.addDirectCommand(ByteCodes.UIRead);
-            cmd.LC0(UIReadSubCodes.GetVbatt);
-            cmd.GV0(value);
+            dataStream.addDirectDataStream(ByteCodes.UIRead);
+            dataStream.LC0(UIReadSubCodes.GetVbatt);
+            dataStream.GV0(value);
         end
         
-        function opUI_READ_GET_LBATT(cmd,value)
-            % Command.opUI_READ_GET_LBATT Add a opUI_READ_GET_LBATT
+        function opUI_READ_GET_LBATT(dataStream,value)
+            % DataStream.opUI_READ_GET_LBATT Add a opUI_READ_GET_LBATT
             %
-            % Command.opUI_READ_GET_LBATT adds a opUI opcode with a
-            % READ_GET_LBATT subcode to the command object.
+            % DataStream.opUI_READ_GET_LBATT adds a opUI opcode with a
+            % READ_GET_LBATT subcode to the DataStream object.
             %
             % Notes::
             % - value is the address in response buffer where value (DATA8) should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opUI_READ,LC0(18),GV0(value)
             %
             % Example::
-            %           cmd.opUI_READ_GET_LBATT(0)
+            %           dataStream.opUI_READ_GET_LBATT(0)
 
-            cmd.addDirectCommand(ByteCodes.UIRead);
-            cmd.LC0(UIReadSubCodes.GetLbatt);
-            cmd.GV0(value);
+            dataStream.addDirectDataStream(ByteCodes.UIRead);
+            dataStream.LC0(UIReadSubCodes.GetLbatt);
+            dataStream.GV0(value);
         end
         
-        function opUI_WRITE_PUT_STRING(cmd,txt)
-            % Command.opUI_WRITE_PUT_STRING Add a opUI_WRITE_PUT_STRING
+        function opUI_WRITE_PUT_STRING(dataStream,txt)
+            % DataStream.opUI_WRITE_PUT_STRING Add a opUI_WRITE_PUT_STRING
             %
-            % Command.opUI_WRITE_PUT_STRING adds a opUR_WRITE opcode with a
-            % WRITE_PUT_STRING subcode to the command object.
+            % DataStream.opUI_WRITE_PUT_STRING adds a opUR_WRITE opcode with a
+            % WRITE_PUT_STRING subcode to the DataStream object.
             %
             % Notes::
             % - txt is the string to be added
             % - opUI_WRITE,LC0(8),LCS,'A','B' ... ,0
             %
             % Example::
-            %           cmd.opUI_WRITE_PUT_STRING('hello')
+            %           dataStream.opUI_WRITE_PUT_STRING('hello')
             
-            cmd.addDirectCommand(ByteCodes.UIWrite);
-            cmd.LC0(UIWriteSubCodes.PutString);
-            cmd.addLCSString(txt);
+            dataStream.addDirectDataStream(ByteCodes.UIWrite);
+            dataStream.LC0(UIWriteSubCodes.PutString);
+            dataStream.addLCSString(txt);
         end
         
-        function opUI_WRITE_INIT_RUN(cmd)
-            % Command.opUI_WRITE_INIT_RUN Add a opUI_WRITE_INIT_RUN
+        function opUI_WRITE_INIT_RUN(dataStream)
+            % DataStream.opUI_WRITE_INIT_RUN Add a opUI_WRITE_INIT_RUN
             %
-            % Command.opUI_WRITE_INIT_RUN adds a opUI_WRITE opcode with a
-            % INIT_RUN subcode to the command object.
+            % DataStream.opUI_WRITE_INIT_RUN adds a opUI_WRITE opcode with a
+            % INIT_RUN subcode to the DataStream object.
             %
             % Notes::
             % - opUI_WRITE,LC0(25)
             %
             % Example::
-            %           cmd.opUI_WRITE_INIT_RUN()
+            %           dataStream.opUI_WRITE_INIT_RUN()
             
-            cmd.addDirectCommand(ByteCodes.UIWrite);
-            cmd.LC0(UIWriteSubCodes.InitRun);
+            dataStream.addDirectDataStream(ByteCodes.UIWrite);
+            dataStream.LC0(UIWriteSubCodes.InitRun);
         end
         
-        function opUI_WRITE_LED(cmd,pattern)
-            % Command.opUI_WRITE_LED Add a opUI_WRITE_LED
+        function opUI_WRITE_LED(dataStream,pattern)
+            % DataStream.opUI_WRITE_LED Add a opUI_WRITE_LED
             %
-            % Command.opUI_WRITE_LED(pattern) adds a opUI_WRITE opcode with
-            % a WRITE_LED subcode to the command object.
+            % DataStream.opUI_WRITE_LED(pattern) adds a opUI_WRITE opcode with
+            % a WRITE_LED subcode to the DataStream object.
             %
             % Notes::
             % - pattern is the LED pattern from Device.LedBlack to
@@ -1094,50 +866,50 @@ classdef Command < handle
             % - opUI_WRITE,LC0(27),LC0(pattern)
             %
             % Example::
-            %           cmd.opUI_WRITE_LED(Device.LedBlack)
+            %           dataStream.opUI_WRITE_LED(Device.LedBlack)
             
-            cmd.addDirectCommand(ByteCodes.UIWrite);
-            cmd.LC0(UIWriteSubCodes.Led);
-            cmd.LC0(pattern);            
+            dataStream.addDirectDataStream(ByteCodes.UIWrite);
+            dataStream.LC0(UIWriteSubCodes.Led);
+            dataStream.LC0(pattern);            
         end
         
-        function opUI_DRAW_UPDATE(cmd)
-            % Command.opUI_DRAW_UPDATE Add a opUI_DRAW_UPDATE
+        function opUI_DRAW_UPDATE(dataStream)
+            % DataStream.opUI_DRAW_UPDATE Add a opUI_DRAW_UPDATE
             %
-            % Command.opUI_DRAW_UPDATE() adds a opUI_DRAW opcode with a
-            % DRAW_UPDATE subcode to the command object.
+            % DataStream.opUI_DRAW_UPDATE() adds a opUI_DRAW opcode with a
+            % DRAW_UPDATE subcode to the DataStream object.
             %
             % Notes::
             % - opUI_DRAW,LC0(0)
             %
             % Examples::
-            %           cmd.opUI_DRAW_UPDATE()
+            %           dataStream.opUI_DRAW_UPDATE()
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Update);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Update);
         end
         
-        function opUI_DRAW_CLEAN(cmd)
-            % Command.opUI_DRAW_CLEAN Add a opUI_DRAW_CLEAN
+        function opUI_DRAW_CLEAN(dataStream)
+            % DataStream.opUI_DRAW_CLEAN Add a opUI_DRAW_CLEAN
             %
-            % Command.opUI_DRAW_CLEAN() adds a UI_DRAW opcode with a CLEAN
-            % subcode to the command object.
+            % DataStream.opUI_DRAW_CLEAN() adds a UI_DRAW opcode with a CLEAN
+            % subcode to the DataStream object.
             %
             % Notes::
             % - opUI_DRAW,LC0(1)
             % 
             % Example::
-            %           cmd.opUI_DRAW_CLEAN()
+            %           dataStream.opUI_DRAW_CLEAN()
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Clean);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Clean);
         end
         
-        function opUI_DRAW_PIXEL(cmd,color,x,y)
-            % Command.opUI_DRAW_PIXEL Add a opUI_DRAW_PIXEL
+        function opUI_DRAW_PIXEL(dataStream,color,x,y)
+            % DataStream.opUI_DRAW_PIXEL Add a opUI_DRAW_PIXEL
             %
-            % command.opUI_DRAW_PIXEL(color,x,y) adds a UI_DRAW opcode with
-            % a PIXEL subcode to the command object.
+            % DataStream.opUI_DRAW_PIXEL(color,x,y) adds a UI_DRAW opcode with
+            % a PIXEL subcode to the DataStream object.
             %
             % Notes::
             % - color is the pixel color (either foregrond or background)
@@ -1146,20 +918,20 @@ classdef Command < handle
             % - opUI_DRAW,LC0(2),LC0(color),LC2(x),LC2(y)
             %
             % Example::
-            %           cmd.opUI_DRAW_PIXEL(vmCodes.vmFGColor,0,0)
+            %           dataStream.opUI_DRAW_PIXEL(vmCodes.vmFGColor,0,0)
 
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Pixel);
-            cmd.LC0(color);
-            cmd.LC2(x);
-            cmd.LC2(y)
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Pixel);
+            dataStream.LC0(color);
+            dataStream.LC2(x);
+            dataStream.LC2(y)
         end
         
-        function opUI_DRAW_LINE(cmd,color,x0,y0,x1,y1)
-            % Command.opUI_DRAW_LINE Add a opUI_DRAW_LINE
+        function opUI_DRAW_LINE(dataStream,color,x0,y0,x1,y1)
+            % DataStream.opUI_DRAW_LINE Add a opUI_DRAW_LINE
             %
-            % Command.opUI_DRAW_LINE(color,x0,y0,x1,y1) adds a UI_DRAW
-            % opcode with a LINE subcode to the command object.
+            % DataStream.opUI_DRAW_LINE(color,x0,y0,x1,y1) adds a UI_DRAW
+            % opcode with a LINE subcode to the DataStream object.
             %
             % Notes::
             % - color is the pixel color (either foregrond or background)
@@ -1168,22 +940,22 @@ classdef Command < handle
             % - opUI_DRAW,LC0(3),LC0(color),LC2(x0),LC2(y0),LC2(x1),LC2(y1)
             %
             % Example::
-            %           cmd.opUI_DRAW_LINE(vmCodes.vmFGColor,0,0,1,1)
+            %           dataStream.opUI_DRAW_LINE(vmCodes.vmFGColor,0,0,1,1)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Line);
-            cmd.LC0(color);
-            cmd.LC2(x0);
-            cmd.LC2(y0);
-            cmd.LC2(x1);
-            cmd.LC2(y1);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Line);
+            dataStream.LC0(color);
+            dataStream.LC2(x0);
+            dataStream.LC2(y0);
+            dataStream.LC2(x1);
+            dataStream.LC2(y1);
         end
         
-        function opUI_DRAW_CIRCLE(cmd,color,x0,y0,r)
-            % Command.opUI_DRAW_CIRCLE Add a opUI_DRAW_CIRCLE
+        function opUI_DRAW_CIRCLE(dataStream,color,x0,y0,r)
+            % DataStream.opUI_DRAW_CIRCLE Add a opUI_DRAW_CIRCLE
             %
-            % Command.opUI_DRAW_CIRCLE(color,x0,y0,r) adds a UI_DRAW opcode
-            % with a CIRCLE subcode to the object command.
+            % DataStream.opUI_DRAW_CIRCLE(color,x0,y0,r) adds a UI_DRAW opcode
+            % with a CIRCLE subcode to the object DataStream.
             %
             % Notes::
             % - color is the pixel color (either foregrond or background)
@@ -1193,21 +965,21 @@ classdef Command < handle
             % - opUI_DRAW,LC0(4),LC0(color),LC2(x0),LC2(y0),LC2(r)
             %
             % Example::
-            %           cmd.opUI_DRAW_CIRCLE(vmCodes.vmFGColor,0,0,5)
+            %           dataStream.opUI_DRAW_CIRCLE(vmCodes.vmFGColor,0,0,5)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Circle);
-            cmd.LC0(color);
-            cmd.LC2(x0);
-            cmd.LC2(y0);
-            cmd.LC2(r);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Circle);
+            dataStream.LC0(color);
+            dataStream.LC2(x0);
+            dataStream.LC2(y0);
+            dataStream.LC2(r);
         end           
         
-        function opUI_DRAW_TEXT(cmd,color,x,y,txt)
-            % Command.opUI_DRAW_TEXT Add a opUI_DRAW_TEXT
+        function opUI_DRAW_TEXT(dataStream,color,x,y,txt)
+            % DataStream.opUI_DRAW_TEXT Add a opUI_DRAW_TEXT
             %
-            % Command.opUI_DRAW_TEXT(color,x,y,txt) adds a UI_DRAW opcode
-            % with a TEXT subcode to the command object.
+            % DataStream.opUI_DRAW_TEXT(color,x,y,txt) adds a UI_DRAW opcode
+            % with a TEXT subcode to the DataStream object.
             %
             % Notes::
             % - color is the pixel color (either foregrond or background)
@@ -1217,21 +989,21 @@ classdef Command < handle
             % - opUI_DRAW,LC0(5),LC0(color),LC2(x),LC2(y),LCS,'A','B' ...,0
             %
             % Example::
-            %           cmd.opUI_DRAW_TEXT(vmCodes.vmFGColor,0,0,'hello')
+            %           dataStream.opUI_DRAW_TEXT(vmCodes.vmFGColor,0,0,'hello')
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Text);
-            cmd.LC0(color);
-            cmd.LC2(x);
-            cmd.LC2(y);
-            cmd.addLCSString(txt);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Text);
+            dataStream.LC0(color);
+            dataStream.LC2(x);
+            dataStream.LC2(y);
+            dataStream.addLCSString(txt);
         end
         
-        function opUI_DRAW_VALUE(cmd,color,x,y,index,figures,decimals)
-            % Command.opUI_DRAW_VALUE Add a opUI_DRAW_VALUE
+        function opUI_DRAW_VALUE(dataStream,color,x,y,index,figures,decimals)
+            % DataStream.opUI_DRAW_VALUE Add a opUI_DRAW_VALUE
             %
-            % Command.opUI_DRAW_VALUE(color,x,y,index,figures,decimals)
-            % adds a UI_DRAW opcode with a VALUE subcode to the command
+            % DataStream.opUI_DRAW_VALUE(color,x,y,index,figures,decimals)
+            % adds a UI_DRAW opcode with a VALUE subcode to the DataStream
             % object.
             % Notes::
             % - color is the pixel color (either foregrond or background)
@@ -1243,24 +1015,24 @@ classdef Command < handle
             % - opUI_DRAW,LC0(8),LC0(color),LC2(x),LC2(y),GV0(index),LC0(figures),LC0(decimals)
             %
             % Example::
-            %           cmd.opUI_DRAW_VALUE(vmCodes.vmFGColor,0,0,0,3,2)
+            %           dataStream.opUI_DRAW_VALUE(vmCodes.vmFGColor,0,0,0,3,2)
             %
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Value);
-            cmd.LC0(color);
-            cmd.LC2(x);
-            cmd.LC2(y);
-            cmd.GV0(index);
-            cmd.LC0(figures);
-            cmd.LC0(decimals);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Value);
+            dataStream.LC0(color);
+            dataStream.LC2(x);
+            dataStream.LC2(y);
+            dataStream.GV0(index);
+            dataStream.LC0(figures);
+            dataStream.LC0(decimals);
         end
         
-        function opUI_DRAW_FILLRECT(cmd,color,x0,y0,x1,y1)
-            % Command.opUI_DRAW_FILLRECT Add a opUI_DRAW_FILLRECT
+        function opUI_DRAW_FILLRECT(dataStream,color,x0,y0,x1,y1)
+            % DataStream.opUI_DRAW_FILLRECT Add a opUI_DRAW_FILLRECT
             %
-            % Command.opUI_DRAW_FILLRECT(color,x0,y0,x1,y1) adds a
-            % opUI_DRAW opcode with a FILLRECT subcode to the command
+            % DataStream.opUI_DRAW_FILLRECT(color,x0,y0,x1,y1) adds a
+            % opUI_DRAW opcode with a FILLRECT subcode to the DataStream
             % object.
             %
             % Notes::
@@ -1270,22 +1042,22 @@ classdef Command < handle
             % - opUI_DRAW,LC0(9),LC0(color),LC2(x0),LC2(y0),LC2(x1),LC2(y1)
             %
             % Example::
-            %           cmd.opUI_DRAW_FILLRECT(vmCodes.vmFGColor,0,0,10,10)
+            %           dataStream.opUI_DRAW_FILLRECT(vmCodes.vmFGColor,0,0,10,10)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Fillrect);
-            cmd.LC0(color);
-            cmd.LC2(x0);
-            cmd.LC2(y0);
-            cmd.LC2(x1);
-            cmd.LC2(y1);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Fillrect);
+            dataStream.LC0(color);
+            dataStream.LC2(x0);
+            dataStream.LC2(y0);
+            dataStream.LC2(x1);
+            dataStream.LC2(y1);
         end
         
-        function opUI_DRAW_RECT(cmd,color,x0,y0,x1,y1)
-            % Command.opUI_DRAW_RECT Add a opUI_DRAW_RECT
+        function opUI_DRAW_RECT(dataStream,color,x0,y0,x1,y1)
+            % DataStream.opUI_DRAW_RECT Add a opUI_DRAW_RECT
             %
-            % Command.opUI_DRAW_RECT(color,x0,y0,x1,y1) adds a
-            % opUI_DRAW opcode with a RECT subcode to the command
+            % DataStream.opUI_DRAW_RECT(color,x0,y0,x1,y1) adds a
+            % opUI_DRAW opcode with a RECT subcode to the DataStream
             % object.
             %
             % Notes::
@@ -1295,22 +1067,22 @@ classdef Command < handle
             % - opUI_DRAW,LC0(10),LC0(color),LC2(x0),LC2(y0),LC2(x1),LC2(y1)
             %
             % Example::
-            %           cmd.opUI_DRAW_RECT(vmCodes.vmFGColor,0,0,10,10)
+            %           dataStream.opUI_DRAW_RECT(vmCodes.vmFGColor,0,0,10,10)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Rect);
-            cmd.LC0(color);
-            cmd.LC2(x0);
-            cmd.LC2(y0);
-            cmd.LC2(x1);
-            cmd.LC2(y1);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Rect);
+            dataStream.LC0(color);
+            dataStream.LC2(x0);
+            dataStream.LC2(y0);
+            dataStream.LC2(x1);
+            dataStream.LC2(y1);
         end
         
-        function opUI_DRAW_INVERSERECT(cmd,x0,y0,x1,y1)
-            % Command.opUI_DRAW_INVERSERECT Add a opUI_DRAW_INVERSERECT
+        function opUI_DRAW_INVERSERECT(dataStream,x0,y0,x1,y1)
+            % DataStream.opUI_DRAW_INVERSERECT Add a opUI_DRAW_INVERSERECT
             %
-            % Command.opUI_DRAW_INVERSERECT(x0,y0,x1,y1) adds a opUI_DRAW
-            % opcode with a INVERSERECT subcode to the command object.
+            % DataStream.opUI_DRAW_INVERSERECT(x0,y0,x1,y1) adds a opUI_DRAW
+            % opcode with a INVERSERECT subcode to the DataStream object.
             %
             % Notes::
             % - x0,y0 is the point coordinate of the top left corner
@@ -1318,57 +1090,57 @@ classdef Command < handle
             % - opUI_DRAW,LC0(16),LC2(x0),LC2(y0),LC2(x1),LC2(y1)
             %
             % Examples::
-            %           cmd.opUI_DRAW_INVERSERECT(0,0,10,10)
+            %           dataStream.opUI_DRAW_INVERSERECT(0,0,10,10)
 
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Inverserect);
-            cmd.LC2(x0);
-            cmd.LC2(y0);
-            cmd.LC2(x1);
-            cmd.LC2(y1);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Inverserect);
+            dataStream.LC2(x0);
+            dataStream.LC2(y0);
+            dataStream.LC2(x1);
+            dataStream.LC2(y1);
         end
         
-        function opUI_DRAW_SELECT_FONT(cmd,type)
-            % Command.opUI_DRAW_SELECT_FONT Add a opUI_DRAW_SELECT_FONT
+        function opUI_DRAW_SELECT_FONT(dataStream,type)
+            % DataStream.opUI_DRAW_SELECT_FONT Add a opUI_DRAW_SELECT_FONT
             %
-            % Command.opUI_DRAW_SELECT_FONT(type) adds a opUI_DRAW opcode
-            % with a SELECT_FONT subcode to the command object.
+            % DataStream.opUI_DRAW_SELECT_FONT(type) adds a opUI_DRAW opcode
+            % with a SELECT_FONT subcode to the DataStream object.
             %
             % Notes::
             % - type is the font type [0..2] 
             % - opUI_DRAW,LC0(17),LC0(type)
             %
             % Examples::
-            %           cmd.opUI_DRAW_SELECT_FONT(1)
+            %           dataStream.opUI_DRAW_SELECT_FONT(1)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.SelectFont);
-            cmd.LC0(type);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.SelectFont);
+            dataStream.LC0(type);
         end
         
-        function opUI_DRAW_TOPLINE(cmd,enable)
-            % Command.opUI_DRAW_TOPLINE Add a opUI_DRAW_TOPLINE
+        function opUI_DRAW_TOPLINE(dataStream,enable)
+            % DataStream.opUI_DRAW_TOPLINE Add a opUI_DRAW_TOPLINE
             %
-            % Command.opUI_DRAW_TOPLINE(enable) adds a opUI_DRAW opcode
-            % with a TOPLINE subcode to the command object.
+            % DataStream.opUI_DRAW_TOPLINE(enable) adds a opUI_DRAW opcode
+            % with a TOPLINE subcode to the DataStream object.
             %
             % Notes::
             % - enable is the top status line flag, 0 = disable, 1 = enable
             % - opUI_DRAW,LC0(18),LC0(enable)
             %
             % Example::
-            %           cmd.opUI_DRAW_TOPLINE(1)
+            %           dataStream.opUI_DRAW_TOPLINE(1)
          
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Topline);
-            cmd.LC0(enable);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Topline);
+            dataStream.LC0(enable);
         end
         
-        function opUI_DRAW_FILLWINDOW(cmd, color, y0, y1)
-            % Command.opUI_DRAW_FILLWINDOW Add a opUI_DRAW_FILLWINDOW
+        function opUI_DRAW_FILLWINDOW(dataStream, color, y0, y1)
+            % DataStream.opUI_DRAW_FILLWINDOW Add a opUI_DRAW_FILLWINDOW
             %
-            % Command.opUI_DRAW_FILLWINDOW adds a UI_DRAW opcode with a
-            % FILLWINDOW subcode to the command object.
+            % DataStream.opUI_DRAW_FILLWINDOW adds a UI_DRAW opcode with a
+            % FILLWINDOW subcode to the DataStream object.
             %
             % Notes::
             % - color is the pixel color (either foregrond or background)
@@ -1377,20 +1149,20 @@ classdef Command < handle
             % - opUI_DRAW,LC0(19),LC0(color),LC2(y0),LC2(y1)
             %
             % Example::
-            %           cmd.opUI_DRAW_FILLWINDOW(vmCodes.vmFGColor,0,10)
+            %           dataStream.opUI_DRAW_FILLWINDOW(vmCodes.vmFGColor,0,10)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Fillwindow);
-            cmd.LC0(color);
-            cmd.LC2(y0);
-            cmd.LC2(y1);            
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Fillwindow);
+            dataStream.LC0(color);
+            dataStream.LC2(y0);
+            dataStream.LC2(y1);            
         end
         
-        function opUI_DRAW_FILLCIRCLE(cmd,color,x0,y0,r)
-            % Command.opUI_DRAW_FILLCIRCLE Add a opUI_DRAW_FILLCIRCLE
+        function opUI_DRAW_FILLCIRCLE(dataStream,color,x0,y0,r)
+            % DataStream.opUI_DRAW_FILLCIRCLE Add a opUI_DRAW_FILLCIRCLE
             %
-            % Command.opUI_DRAW_FILLCIRCLE(color,x0,y0,r) adds a UI_DRAW
-            % opcode with a FILLCIRCLE subcode to the command object.
+            % DataStream.opUI_DRAW_FILLCIRCLE(color,x0,y0,r) adds a UI_DRAW
+            % opcode with a FILLCIRCLE subcode to the DataStream object.
             %
             % Notes::
             % - color is the pixel color (either foreground or background)
@@ -1400,57 +1172,57 @@ classdef Command < handle
             % - opUI_DRAW,LC0(24),LC0(color),LC2(x0),LC2(y0),LC2(r)
             %
             % Example::
-            %           cmd.opUI_DRAW_FILLCIRCLE(vmCodes.vmFGColor,10,10,5)
+            %           dataStream.opUI_DRAW_FILLCIRCLE(vmCodes.vmFGColor,10,10,5)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Fillcircle);
-            cmd.LC0(color);
-            cmd.LC2(x0);
-            cmd.LC2(y0);
-            cmd.LC2(r);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Fillcircle);
+            dataStream.LC0(color);
+            dataStream.LC2(x0);
+            dataStream.LC2(y0);
+            dataStream.LC2(r);
         end
         
-        function opUI_DRAW_STORE(cmd,no)
-            % Command.opUI_DRAW_STORE Add a opUI_DRAW_STORE
+        function opUI_DRAW_STORE(dataStream,no)
+            % DataStream.opUI_DRAW_STORE Add a opUI_DRAW_STORE
             %
-            % Command.opUI_DRAW_STORE(no) adds a UI_DRAW opcode with a
-            % STORE subcode to the command object. 
+            % DataStream.opUI_DRAW_STORE(no) adds a UI_DRAW opcode with a
+            % STORE subcode to the DataStream object. 
             %
             % Notes::
             % - no is the level number to store the UI screen
             % - opUI_DRAW,LC0(25),LC0(no)
             %
             % Example::
-            %           cmd.opUI_DRAW_STORE(1)
+            %           dataStream.opUI_DRAW_STORE(1)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Store);
-            cmd.LC0(no);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Store);
+            dataStream.LC0(no);
         end
         
-        function opUI_DRAW_RESTORE(cmd,no)
-            % Command.opUI_DRAW_RESTORE Add a opUI_DRAW_RESTORE
+        function opUI_DRAW_RESTORE(dataStream,no)
+            % DataStream.opUI_DRAW_RESTORE Add a opUI_DRAW_RESTORE
             %
-            % Command.opUI_DRAW_RESTORE(no) adds a UI_DRAW opcode with a
-            % RESTORE subcode to the command object. 
+            % DataStream.opUI_DRAW_RESTORE(no) adds a UI_DRAW opcode with a
+            % RESTORE subcode to the DataStream object. 
             %
             % Notes::
             % - no is the level number to store the UI screen (0 is saved screen before run)
             % - opUI_DRAW,LC0(26),LC0(no)
             %
             % Example::
-            %           cmd.opUI_DRAW_RESTORE(1)
+            %           dataStream.opUI_DRAW_RESTORE(1)
             
-            cmd.addDirectCommand(ByteCodes.UIDraw);
-            cmd.LC0(UIDrawSubCodes.Restore);
-            cmd.LC0(no);
+            dataStream.addDirectDataStream(ByteCodes.UIDraw);
+            dataStream.LC0(UIDrawSubCodes.Restore);
+            dataStream.LC0(no);
         end
         
-        function opTIMER_WAIT(cmd,time,timer)
-            % Command.opTIMER_WAIT Add a opTIMER_WAIT
+        function opTIMER_WAIT(dataStream,time,timer)
+            % DataStream.opTIMER_WAIT Add a opTIMER_WAIT
             %
-            % Command.opTIMER_WAIT(time,timer) adds a opTIMER opcode with a
-            % WAIT subcode to the command object.
+            % DataStream.opTIMER_WAIT(time,timer) adds a opTIMER opcode with a
+            % WAIT subcode to the DataStream object.
             %
             % Notes::
             % - time is the time is wait in ms
@@ -1458,68 +1230,68 @@ classdef Command < handle
             % - opTIMER_WAIT,LC2(time),LV0(timer)
             %
             % Example::
-            %           cmd.opTIMER_WAIT(1000,0)
+            %           dataStream.opTIMER_WAIT(1000,0)
             
-            cmd.addDirectCommand(ByteCodes.TimerWait);
-            cmd.LC2(time);
-            cmd.LV0(timer);
+            dataStream.addDirectDataStream(ByteCodes.TimerWait);
+            dataStream.LC2(time);
+            dataStream.LV0(timer);
         end
         
-        function opTIMER_READY(cmd,timer)
-            % Command.opTIMER_READY Add a opTIMER_READY
+        function opTIMER_READY(dataStream,timer)
+            % DataStream.opTIMER_READY Add a opTIMER_READY
             %
-            % Command.opTIMER_READY(timer) adds a opTIMER opcode with a
-            % READY subcode to the command object.
+            % DataStream.opTIMER_READY(timer) adds a opTIMER opcode with a
+            % READY subcode to the DataStream object.
             %
             % Notes::
             % - timer is the local variable used for timing
             % - opTIMER_READY,LV0(timer)
             %
             % Example::
-            %           cmd.opTIMER_READY(0)
+            %           dataStream.opTIMER_READY(0)
             
-            cmd.addDirectCommand(ByteCodes.TimerReady);
-            cmd.LV0(timer);
+            dataStream.addDirectDataStream(ByteCodes.TimerReady);
+            dataStream.LV0(timer);
         end
         
-        function opTIMER_READ(cmd,time)
-            % Command.opTIMER_READ Add a opTIMER_READ
+        function opTIMER_READ(dataStream,time)
+            % DataStream.opTIMER_READ Add a opTIMER_READ
             %
-            % Command.opTIMER_READ(time) adds a opTIMER opcode with a READ
-            % subcode to the command object.
+            % DataStream.opTIMER_READ(time) adds a opTIMER opcode with a READ
+            % subcode to the DataStream object.
             %
             % Notes::
             % - time is the timer to be read in ms
             % - opTIMER_READ,LV0(time)
             %
             % Example::
-            %           cmd.opTIMER_READ(0)
+            %           dataStream.opTIMER_READ(0)
             
-            cmd.addDirectCommand(ByteCodes.TimerRead);
-            cmd.LV0(time);
+            dataStream.addDirectDataStream(ByteCodes.TimerRead);
+            dataStream.LV0(time);
         end
         
-        function opSOUND_BREAK(cmd)
-            % Command.opSOUND_BREAK Add a opSOUND_BREAK
+        function opSOUND_BREAK(dataStream)
+            % DataStream.opSOUND_BREAK Add a opSOUND_BREAK
             %
-            % Command.opSOUND_BREAK() adds a opSOUND opcode with a BREAK
-            % subcode to the command object.
+            % DataStream.opSOUND_BREAK() adds a opSOUND opcode with a BREAK
+            % subcode to the DataStream object.
             %
             % Notes::
             % - opSOUND,LC0(0)
             %
             % Example::
-            %           cmd.opSOUND_BREAK()
+            %           dataStream.opSOUND_BREAK()
             
-            cmd.addDirectCommand(ByteCodes.Sound);
-            cmd.LC0(SoundSubCodes.Break);
+            dataStream.addDirectDataStream(ByteCodes.Sound);
+            dataStream.LC0(SoundSubCodes.Break);
         end
         
-        function opSOUND_TONE(cmd,volume,frequency,duration)
-            % Command.opSOUND_TONE Add a opSOUND_TONE
+        function opSOUND_TONE(dataStream,volume,frequency,duration)
+            % DataStream.opSOUND_TONE Add a opSOUND_TONE
             %
-            % Command.opSOUND_TONE(volume,frequency,duration) adds a
-            % opSOUND opcode with a TONE subcode to the command object.
+            % DataStream.opSOUND_TONE(volume,frequency,duration) adds a
+            % opSOUND opcode with a TONE subcode to the DataStream object.
             %
             % Notes::
             % - volume is the tone volume from 0 to 100
@@ -1528,40 +1300,40 @@ classdef Command < handle
             % - opSOUND,LC0(1),LC1(volume),LC2(frequency),LC2(duration)
             %
             % Example::
-            %           cmd.opSOUND_TONE(5,1000,500)
+            %           dataStream.opSOUND_TONE(5,1000,500)
             
-            cmd.addDirectCommand(ByteCodes.Sound);
-            cmd.LC0(SoundSubCodes.Tone);
-            cmd.LC1(volume);
-            cmd.LC2(frequency);
-            cmd.LC2(duration);
+            dataStream.addDirectDataStream(ByteCodes.Sound);
+            dataStream.LC0(SoundSubCodes.Tone);
+            dataStream.LC1(volume);
+            dataStream.LC2(frequency);
+            dataStream.LC2(duration);
         end
         
-        function opSOUND_PLAY(cmd,volume,name)
-            % Command.opSOUND_PLAY Add a opSOUND_PLAY
+        function opSOUND_PLAY(dataStream,volume,name)
+            % DataStream.opSOUND_PLAY Add a opSOUND_PLAY
             %
-            % Command.opSOUND_PLAY(volume,name) adds a opSOUND opcode with
-            % a PLAY subcode the command object.
+            % DataStream.opSOUND_PLAY(volume,name) adds a opSOUND opcode with
+            % a PLAY subcode the DataStream object.
             %
             % Example::
-            %           cmd.opSOUND_PLAY(5,'test.rsf')
+            %           dataStream.opSOUND_PLAY(5,'test.rsf')
             %
             % Notes::
             % - volume is the volume to play the file at
             % - name is the name of the file to play
             % - opSOUND,LC0(2),LC0(volume),LCS,'A','B' ... '0'
             
-            cmd.addDirectCommand(ByteCodes.Sound);
-            cmd.LC0(SoundSubCodes.Play);
-            cmd.LC0(volume);
-            cmd.addLCSString(name);
+            dataStream.addDirectDataStream(ByteCodes.Sound);
+            dataStream.LC0(SoundSubCodes.Play);
+            dataStream.LC0(volume);
+            dataStream.addLCSString(name);
         end
         
-        function opSOUND_REPEAT(cmd,volume,name)
-            % Command.opSOUND_REPEAT Add a opSOUND_REPEAT
+        function opSOUND_REPEAT(dataStream,volume,name)
+            % DataStream.opSOUND_REPEAT Add a opSOUND_REPEAT
             %
-            % Command.opSOUND_REPEAT(volume,name) adds a opSOUND opcode
-            % with a REPEAT subcode to the command object.
+            % DataStream.opSOUND_REPEAT(volume,name) adds a opSOUND opcode
+            % with a REPEAT subcode to the DataStream object.
             %
             % Notes::
             % - volume is the volume to repeat the file at
@@ -1569,52 +1341,52 @@ classdef Command < handle
             % - opSOUND,LC0(2),LC0(volume),LCS,'A','B' ... '0'
             %
             % Example::
-            %           cmd.opSOUND_REPEAT(1,'test.rsf')
+            %           dataStream.opSOUND_REPEAT(1,'test.rsf')
             
-            cmd.addDirectCommand(ByteCodes.Sound);
-            cmd.addDirectCommand(SoundSubCodes.Repeat);
-            cmd.LC0(volume);
-            cmd.addLCSString(name);
+            dataStream.addDirectDataStream(ByteCodes.Sound);
+            dataStream.addDirectDataStream(SoundSubCodes.Repeat);
+            dataStream.LC0(volume);
+            dataStream.addLCSString(name);
         end
         
-        function opSOUND_TEST(cmd,busy)
-            % Command.opSOUND_TEST Add a opSOUND_TEST
+        function opSOUND_TEST(dataStream,busy)
+            % DataStream.opSOUND_TEST Add a opSOUND_TEST
             %
-            % Command.opSOUND_TEST(busy) adds a opSOUND_TEST to the command
+            % DataStream.opSOUND_TEST(busy) adds a opSOUND_TEST to the DataStream
             % object. 
             %
             % Notes::
             % - busy is the address in response buffer where the busy flag (DATA8) should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opSOUND_TEST,GV0(busy)
             %
             % Example::
-            %           cmd.opSOUND_TEST(0)
+            %           dataStream.opSOUND_TEST(0)
             
-            cmd.addDirectCommand(ByteCodes.SoundTest);
-            cmd.GV0(busy);
+            dataStream.addDirectDataStream(ByteCodes.SoundTest);
+            dataStream.GV0(busy);
         end
         
-        function opSOUND_READY(cmd)
+        function opSOUND_READY(dataStream)
             % Commad.opSOUND_READY Add a opSOUND_READY
             %
-            % Command.opSOUND_READY() adds a opSOUND_READY opcode to the 
-            % command object.
+            % DataStream.opSOUND_READY() adds a opSOUND_READY opcode to the 
+            % DataStream object.
             %
             % Example::
-            %           cmd.opSOUND_READY()
+            %           dataStream.opSOUND_READY()
             %
             % Notes::
             % - opSOUND_READY
             
-            cmd.addDirectCommand(ByteCodes.SoundReady);           
+            dataStream.addDirectDataStream(ByteCodes.SoundReady);           
         end
         
-        function opINPUT_DEVICE_LIST(cmd,length,array,changed)
-            % Command.opINPUT_DEVICE_LIST Add a opINPUT_DEVICE_LIST
+        function opINPUT_DEVICE_LIST(dataStream,length,array,changed)
+            % DataStream.opINPUT_DEVICE_LIST Add a opINPUT_DEVICE_LIST
             %
-            % Command.opINPUT_DEVICE_LIST(length,array,changed) adds a
-            % opINPUT_DEVICE_LIST opcode to the command object.
+            % DataStream.opINPUT_DEVICE_LIST(length,array,changed) adds a
+            % opINPUT_DEVICE_LIST opcode to the DataStream object.
             %
             % Notes::
             % - length is maximum number of device types (norm 32)
@@ -1623,99 +1395,99 @@ classdef Command < handle
             % - opINPUT_DEVICE_LIST,LC0(length),GV0(array),GV0(changed)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_LIST(32,0,4)
+            %           dataStream.opINPUT_DEVICE_LIST(32,0,4)
             
-            cmd.addDirectCommand(ByteCodes.InputDeviceList);
-            cmd.LC0(length);
-            cmd.GV0(array);
-            cmd.GV0(changed);
+            dataStream.addDirectDataStream(ByteCodes.InputDeviceList);
+            dataStream.LC0(length);
+            dataStream.GV0(array);
+            dataStream.GV0(changed);
         end
         
-        function opINPUT_DEVICE_GET_TYPEMODE(cmd,layer,no,type,mode)
-            % Command.opINPUT_DEVICE_GET_TYPEMODE Add a opINPUT_DEVICE_GET_TYPEMODE
+        function opINPUT_DEVICE_GET_TYPEMODE(dataStream,layer,no,type,mode)
+            % DataStream.opINPUT_DEVICE_GET_TYPEMODE Add a opINPUT_DEVICE_GET_TYPEMODE
             %
-            % Command.opINPUT_DEVICE_GET_TYPEMODE(layer,no,type,mode) adds
+            % DataStream.opINPUT_DEVICE_GET_TYPEMODE(layer,no,type,mode) adds
             % a opINPUT_DEVICE opcode with a GET_TYPEMODE subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is the output port number from [0..3] or sensor port number minus 1
             % - type is the address in response buffer where type (DATA8) should be stored
             % - mode is the address in response buffer where mode (DATA8) should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opINPUT_DEVICE,LC0(5),LC0(layer),LC0(no),GV0(type),GV0(mode)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_TYPEMODE(0,SensorPort.Sensor1,0,1)
+            %           dataStream.opINPUT_DEVICE_GET_TYPEMODE(0,SensorPort.Sensor1,0,1)
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetTypeMode);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(type);
-            cmd.GV0(mode);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetTypeMode);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(type);
+            dataStream.GV0(mode);
         end
         
-        function opINPUT_DEVICE_SET_TYPEMODE(cmd,oldType,oldMode,newType,newMode)
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.SetTypeMode);
-            cmd.LC0(oldType);
-            cmd.LC0(oldMode);
-            cmd.LC0(newType);
-            cmd.LC0(newMode);
+        function opINPUT_DEVICE_SET_TYPEMODE(dataStream,oldType,oldMode,newType,newMode)
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.SetTypeMode);
+            dataStream.LC0(oldType);
+            dataStream.LC0(oldMode);
+            dataStream.LC0(newType);
+            dataStream.LC0(newMode);
         end
         
-        function opINPUT_DEVICE_GET_SYMBOL(cmd,layer,no,length,destination)
-            % Command.opINPUT_DEVICE_GET_SYMBOL Add a opINPUT_DEVICE_GET_SYMBOL
+        function opINPUT_DEVICE_GET_SYMBOL(dataStream,layer,no,length,destination)
+            % DataStream.opINPUT_DEVICE_GET_SYMBOL Add a opINPUT_DEVICE_GET_SYMBOL
             %
-            % Command.opINPUT_DEVICE_GET_SYMBOL(layer,no,length,destination)
+            % DataStream.opINPUT_DEVICE_GET_SYMBOL(layer,no,length,destination)
             % adds a opINPUT_DEVICE opcode with a GET_SYMBOL subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is the output port number from [0..3] or sensor port number minus 1
             % - length is the maximal length of string returned (-1 no check)
             % - destination is the address in response buffer where string should begin
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opINPUT_DEVICE,LC0(6),LC0(layer),LC0(no),LC0(length),GV0(destination)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_SYMBOL(0,SensorPort.Sensor1,5,0)
+            %           dataStream.opINPUT_DEVICE_GET_SYMBOL(0,SensorPort.Sensor1,5,0)
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetSymbol);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.LC0(length);
-            cmd.GV0(destination);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetSymbol);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.LC0(length);
+            dataStream.GV0(destination);
         end
         
-        function opINPUT_DEVICE_CLR_ALL(cmd,layer)
-            % Command.opINPUT_DEVICE_CLR_ALL Add a opINPUT_DEVICE_CLR_ALL
+        function opINPUT_DEVICE_CLR_ALL(dataStream,layer)
+            % DataStream.opINPUT_DEVICE_CLR_ALL Add a opINPUT_DEVICE_CLR_ALL
             %
-            % Command.opINPUT_DEVICE_CLR_ALL(layer) adds a opINPUT_DEVICE
-            % opcode with a CLR_ALL subcode to the command object.
+            % DataStream.opINPUT_DEVICE_CLR_ALL(layer) adds a opINPUT_DEVICE
+            % opcode with a CLR_ALL subcode to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_CLR_ALL(0)
+            %           dataStream.opINPUT_DEVICE_CLR_ALL(0)
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.ClrAll);
-            cmd.LC0(layer);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.ClrAll);
+            dataStream.LC0(layer);
         end 
         
         % Implemented @ MMI
-        function opINPUT_DEVICE_CLR_CHANGES(cmd,layer,no)
-            % Command.opINPUT_DEVICE_CLR_CHANGES Add a opINPUT_DEVICE_CLR_CHANGES
+        function opINPUT_DEVICE_CLR_CHANGES(dataStream,layer,no)
+            % DataStream.opINPUT_DEVICE_CLR_CHANGES Add a opINPUT_DEVICE_CLR_CHANGES
             %
-            % Command.opINPUT_DEVICE_CLR_CHANGES(layer,no)
+            % DataStream.opINPUT_DEVICE_CLR_CHANGES(layer,no)
             % adds a opINPUT_DEVICE opcode with a CLR_CHANGES subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -1723,47 +1495,47 @@ classdef Command < handle
             % - opINPUT_DEVICE,LC0(26),LC0(layer),LC0(no)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_CLR_CHANGES(0,SensorPort.Sensor1)
+            %           dataStream.opINPUT_DEVICE_CLR_CHANGES(0,SensorPort.Sensor1)
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.ClrChanges);
-            cmd.LC0(layer);
-            cmd.LC0(no);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.ClrChanges);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
         end        
         
-        function opINPUT_DEVICE_GET_NAME(cmd,layer,no,length,destination)
-            % Command.opINPUT_DEVICE_GET_NAME Add a opINPUT_DEVICE_GET_NAME
+        function opINPUT_DEVICE_GET_NAME(dataStream,layer,no,length,destination)
+            % DataStream.opINPUT_DEVICE_GET_NAME Add a opINPUT_DEVICE_GET_NAME
             %
-            % Command.opINPUT_DEVICE_GET_NAME(layer,no,length,destination)
+            % DataStream.opINPUT_DEVICE_GET_NAME(layer,no,length,destination)
             % adds a opINPUT_DEVICE opcode with a GET_NAME subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is the output port number from [0..3] or sensor port number minus 1
             % - length is the maximal length of string returned (-1 no check)
             % - destination is the address in response buffer where string should begin
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opINPUT_DEVICE,LC0(21),LC0(layer),LC0(no),LC0(length),GV0(destination)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_NAME(0,SensorPort.Sensor1,12,0)
+            %           dataStream.opINPUT_DEVICE_GET_NAME(0,SensorPort.Sensor1,12,0)
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetName);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.LC0(length);
-            cmd.GV0(destination);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetName);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.LC0(length);
+            dataStream.GV0(destination);
         end 
         
         % Implemented @ MMI
-        function opINPUT_DEVICE_GET_MODENAME(cmd,layer,no,mode,length,destination)
-            % Command.opINPUT_DEVICE_GET_MODENAME Add a opINPUT_DEVICE_GET_MODENAME
+        function opINPUT_DEVICE_GET_MODENAME(dataStream,layer,no,mode,length,destination)
+            % DataStream.opINPUT_DEVICE_GET_MODENAME Add a opINPUT_DEVICE_GET_MODENAME
             %
-            % Command.opINPUT_DEVICE_GET_MODENAME(layer,no,mode,length,destination)
+            % DataStream.opINPUT_DEVICE_GET_MODENAME(layer,no,mode,length,destination)
             % adds a opINPUT_DEVICE opcode with a GET_MODENAME subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -1771,112 +1543,112 @@ classdef Command < handle
             % - mode is the sensor mode at NO
             % - length is the maximal length of string returned (-1 no check)
             % - destination is the address in response buffer where string should begin
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opINPUT_DEVICE,LC0(22),LC0(layer),LC0(no),LC0(mode),LC0(length),GV0(destination)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_MODENAME(0,SensorPort.Sensor1,Device.Bumps,12,0)
+            %           dataStream.opINPUT_DEVICE_GET_MODENAME(0,SensorPort.Sensor1,Device.Bumps,12,0)
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetModeName);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.LC0(mode);
-            cmd.LC0(length);
-            cmd.GV0(destination);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetModeName);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.LC0(mode);
+            dataStream.LC0(length);
+            dataStream.GV0(destination);
         end 
 
         % Implemented @ MMI
-        function opINPUT_DEVICE_GET_CONNECTION(cmd,layer,no,connection)
-            % Command.opINPUT_DEVICE_GET_CONNECTION Add a
+        function opINPUT_DEVICE_GET_CONNECTION(dataStream,layer,no,connection)
+            % DataStream.opINPUT_DEVICE_GET_CONNECTION Add a
             % opINPUT_DEVICE_GET_CONNECTION
             %
-            % Command.opINPUT_DEVICE_GET_CONNECTION(layer,no,connection)
+            % DataStream.opINPUT_DEVICE_GET_CONNECTION(layer,no,connection)
             % adds a opINPUT_DEVICE opcode with a GET_CONNECTION subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is the output port number from [0..3] or sensor port number minus 1
             % - connection is the address in response buffer where the connection type (DATA8) 
             %   should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i)            
+            %   -> more info about response buffer: refer to GV0(dataStream,i)            
             % - opINPUT_DEVICE,LC0(12),LC0(layer),LC0(no),GV0(connection)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_CONNECTION(0,SensorPort.Sensor1,0)  
+            %           dataStream.opINPUT_DEVICE_GET_CONNECTION(0,SensorPort.Sensor1,0)  
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetConnection);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(connection);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetConnection);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(connection);
         end
         
         % Implemented @ MMI
-        function opINPUT_DEVICE_GET_MINMAX(cmd,layer,no,min,max)
-            % Command.opINPUT_DEVICE_GET_MINMAX Add a
+        function opINPUT_DEVICE_GET_MINMAX(dataStream,layer,no,min,max)
+            % DataStream.opINPUT_DEVICE_GET_MINMAX Add a
             % opINPUT_DEVICE_GET_MINMAX
             %
-            % Command.opINPUT_DEVICE_GET_MINMAX(layer,no,min,max)
+            % DataStream.opINPUT_DEVICE_GET_MINMAX(layer,no,min,max)
             % adds a opINPUT_DEVICE opcode with a GET_MINMAX subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is the output port number from [0..3] or sensor port number minus 1
             % - min is the address in response buffer where the min val (DATAF) should be stored
             % - max is the address in response buffer where the max val (DATAF) should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % - opINPUT_DEVICE,LC0(30),LC0(layer),LC0(no),GV0(min),GV0(max)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_MINMAX(0,SensorPort.Sensor1,0,4)  
+            %           dataStream.opINPUT_DEVICE_GET_MINMAX(0,SensorPort.Sensor1,0,4)  
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetMinMax);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(min);
-            cmd.GV0(max);
-%             cmd.GV4(min);
-%             cmd.GV4(max);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetMinMax);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(min);
+            dataStream.GV0(max);
+%             dataStream.GV4(min);
+%             dataStream.GV4(max);
         end
 
         % Implemented @ MMI
-        function opINPUT_DEVICE_GET_CHANGES(cmd,layer,no,changes)
-            % Command.opINPUT_DEVICE_GET_CHANGES Add a
+        function opINPUT_DEVICE_GET_CHANGES(dataStream,layer,no,changes)
+            % DataStream.opINPUT_DEVICE_GET_CHANGES Add a
             % opINPUT_DEVICE_GET_CHANGES
             %
-            % Command.opINPUT_DEVICE_GET_CHANGES(layer,no,min,max)
+            % DataStream.opINPUT_DEVICE_GET_CHANGES(layer,no,min,max)
             % adds a opINPUT_DEVICE opcode with a GET_CHANGES subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is the output port number from [0..3] or sensor port number minus 1
             % - changes is the address in response buffer where changes (DATAF) should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opINPUT_DEVICE,LC0(25),LC0(layer),LC0(no),GV0(changes)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_CHANGES(0,SensorPort.Sensor1,0)  
+            %           dataStream.opINPUT_DEVICE_GET_CHANGES(0,SensorPort.Sensor1,0)  
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetChanges);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(changes);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetChanges);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(changes);
         end
         
         % Implemented @ MMI
-        function opINPUT_DEVICE_GET_FORMAT(cmd,layer,no,datasets,format,modes,view)
-            % Command.opINPUT_DEVICE_GET_FORMAT Add a
+        function opINPUT_DEVICE_GET_FORMAT(dataStream,layer,no,datasets,format,modes,view)
+            % DataStream.opINPUT_DEVICE_GET_FORMAT Add a
             % opINPUT_DEVICE_GET_FORMAT
             %
-            % Command.opINPUT_DEVICE_GET_FORMAT(layer,no,min,max)
+            % DataStream.opINPUT_DEVICE_GET_FORMAT(layer,no,min,max)
             % adds a opINPUT_DEVICE opcode with a GET_FORMAT subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -1888,56 +1660,56 @@ classdef Command < handle
             % - modes is the address in response buffer where the no of modes (DATA8) should be
             %   stored
             % - view is the address in response buffer where the view (DATA8) should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % opINPUT_DEVICE,LC0(2),LC0(layer),LC0(no),GV0(datasets),
             %                       GV0(format),GV0(modes),GV0(view)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_FORMAT(0,SensorPort.Sensor1,0,1,2,3)              
+            %           dataStream.opINPUT_DEVICE_GET_FORMAT(0,SensorPort.Sensor1,0,1,2,3)              
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetFormat);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(datasets);
-            cmd.GV0(format);
-            cmd.GV0(modes);
-            cmd.GV0(view);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetFormat);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(datasets);
+            dataStream.GV0(format);
+            dataStream.GV0(modes);
+            dataStream.GV0(view);
         end
         
         % Implemented @ MMI
-        function opINPUT_DEVICE_GET_BUMPS(cmd,layer,no,bumps)
-            % Command.opINPUT_DEVICE_GET_BUMPS Add a
+        function opINPUT_DEVICE_GET_BUMPS(dataStream,layer,no,bumps)
+            % DataStream.opINPUT_DEVICE_GET_BUMPS Add a
             % opINPUT_DEVICE_GET_BUMPS
             %
-            % Command.opINPUT_DEVICE_GET_BUMPS(layer,no,bumps)
+            % DataStream.opINPUT_DEVICE_GET_BUMPS(layer,no,bumps)
             % adds a opINPUT_DEVICE opcode with a GET_BUMPS subcode to the
-            % command object.
+            % DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is the output port number from [0..3] or sensor port number minus 1
             % - bumps is the address in response buffer where the no of bumps (DATA8)should be 
             %   stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             %
             % opINPUT_DEVICE,LC0(31),LC0(layer),LC0(no),GV0(bumps)
             %
             % Example::
-            %           cmd.opINPUT_DEVICE_GET_BUMPS(0,SensorPort.Sensor1,0)
+            %           dataStream.opINPUT_DEVICE_GET_BUMPS(0,SensorPort.Sensor1,0)
             
-            cmd.addDirectCommand(ByteCodes.InputDevice);
-            cmd.LC0(InputDeviceSubCodes.GetBumps);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(bumps);
+            dataStream.addDirectDataStream(ByteCodes.InputDevice);
+            dataStream.LC0(InputDeviceSubCodes.GetBumps);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(bumps);
         end
                 
-        function opINPUT_READY(cmd,layer,no)
-            % Command.opINPUT_READY Add a opINPUT_READY
+        function opINPUT_READY(dataStream,layer,no)
+            % DataStream.opINPUT_READY Add a opINPUT_READY
             %
-            % Command.opINPUT_READY(layer,no) adds a opINPUT_READY opcode
-            % to the command object. 
+            % DataStream.opINPUT_READY(layer,no) adds a opINPUT_READY opcode
+            % to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -1945,42 +1717,42 @@ classdef Command < handle
             % - opINPUT_READY,LC0(layer),LC0(no)
             %
             % Example::
-            %           cmd.opINPUT_READY(0,SensorPort.Sensor1)
+            %           dataStream.opINPUT_READY(0,SensorPort.Sensor1)
             
-            cmd.addDirectCommand(ByteCodes.InputReady);
-            cmd.LC0(layer);
-            cmd.LC0(no);
+            dataStream.addDirectDataStream(ByteCodes.InputReady);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
         end
         
         % Implemented @ MMI
-        function opINPUT_TEST(cmd,layer,no,busy)
-            % Command.opINPUT_TEST Add a opINPUT_TEST
+        function opINPUT_TEST(dataStream,layer,no,busy)
+            % DataStream.opINPUT_TEST Add a opINPUT_TEST
             %
-            % Command.opINPUT_TEST(layer,no,value) adds a opINPUT_TEST opcode
-            % to the command object. 
+            % DataStream.opINPUT_TEST(layer,no,value) adds a opINPUT_TEST opcode
+            % to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is the output port number from [0..3] or sensor port number minus 1
             % - busy is the address in response buffer where the busy flag (DATA8) should be 
             %   stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % - opINPUT_TEST,LC0(layer),LC0(no),GV0(value)
             %
             % Example::
-            %           cmd.opINPUT_TEST(0,SensorPort.Sensor1,0)
+            %           dataStream.opINPUT_TEST(0,SensorPort.Sensor1,0)
             
-            cmd.addDirectCommand(ByteCodes.InputTest);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(value);
+            dataStream.addDirectDataStream(ByteCodes.InputTest);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(value);
         end
         
-        function opINPUT_READ(cmd,layer,no,type,mode,pct)
-            % Command.opINPUT_READ Add a opINPUT_READ
+        function opINPUT_READ(dataStream,layer,no,type,mode,pct)
+            % DataStream.opINPUT_READ Add a opINPUT_READ
             %
-            % Command.opINPUT_READ(layer,no,type,mode,pct) adds a opINPUT_READ 
-            % opcode to the command object.
+            % DataStream.opINPUT_READ(layer,no,type,mode,pct) adds a opINPUT_READ 
+            % opcode to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -1989,27 +1761,27 @@ classdef Command < handle
             % - mode is the sensor mode from types.html [0..7] (-1 = don't change)
             % - pct is the address in response buffer where the read pct (DATA8) 
             %   should be stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % - The device type is already set when the sensor is
             % connected, you should only need to specify the mode
             % - opINPUT_READ,LC0(layer),LC0(no),LC0(type),LC0(mode),GV0(pct)
             %
             % Example::
-            %           cmd.opINPUT_READ(0,SensorPort.Sensor1,Device.Ultrasonic,Device.USDistCM,0)
+            %           dataStream.opINPUT_READ(0,SensorPort.Sensor1,Device.Ultrasonic,Device.USDistCM,0)
             
-            cmd.addDirectCommand(ByteCodes.InputRead);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.LC0(type);
-            cmd.LC0(mode);
-            cmd.GV0(pct);
+            dataStream.addDirectDataStream(ByteCodes.InputRead);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.LC0(type);
+            dataStream.LC0(mode);
+            dataStream.GV0(pct);
         end
         
-        function opINPUT_READSI(cmd,layer,no,type,mode,si)
-            % Command.opINPUT_READSI Add a opINPUT_READSI
+        function opINPUT_READSI(dataStream,layer,no,type,mode,si)
+            % DataStream.opINPUT_READSI Add a opINPUT_READSI
             %
-            % Command.opINPUT_READSI(layer,no,type,mode,si) adds a opINPUT_READSI  
-            % opcode to the command object.
+            % DataStream.opINPUT_READSI(layer,no,type,mode,si) adds a opINPUT_READSI  
+            % opcode to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2018,27 +1790,27 @@ classdef Command < handle
             % - mode is the sensor mode from types.html [0..7] (-1 = don't change)
             % - si is the address in response buffer where the read si value (DATA32) should be 
             %   stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % - The device type is already set when the sensor is connected, you should only 
             %   need to specify the mode
             % - opINPUT_READSI,LC0(layer),LC0(no),LC0(type),LC0(mode),GV0(si)
             %
             % Example::
-            %           cmd.opINPUT_READ(0,SensorPort.Sensor1,Device.Ultrasonic,Device.USDistCM,0)
+            %           dataStream.opINPUT_READ(0,SensorPort.Sensor1,Device.Ultrasonic,Device.USDistCM,0)
 
-            cmd.addDirectCommand(ByteCodes.InputReadSI);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.LC0(type);
-            cmd.LC0(mode);
-            cmd.GV0(si);
+            dataStream.addDirectDataStream(ByteCodes.InputReadSI);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.LC0(type);
+            dataStream.LC0(mode);
+            dataStream.GV0(si);
         end
         
-        function opOUTPUT_SET_TYPE(cmd,layer,nos,type)
-            % Command.opOUTPUT_SET_TYPE Add a opOUTPUT_SET_TYPE
+        function opOUTPUT_SET_TYPE(dataStream,layer,nos,type)
+            % DataStream.opOUTPUT_SET_TYPE Add a opOUTPUT_SET_TYPE
             %
-            % Command.opOUTPUT_SET_TYPE(layer,nos,type) adds a opOUTPUT_SET_TYPE
-            % opcode to the command object.
+            % DataStream.opOUTPUT_SET_TYPE(layer,nos,type) adds a opOUTPUT_SET_TYPE
+            % opcode to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2047,19 +1819,19 @@ classdef Command < handle
             % - opOUTPUT_SET_TYPE,LC0(layer),LC0(nos),LC0(type)
             %
             % Example::
-            %           cmd.opOUTPUT_SET_TYPE(0,MotorBitfield.MotorA,0)
+            %           dataStream.opOUTPUT_SET_TYPE(0,MotorBitfield.MotorA,0)
             
-            cmd.addDirectCommand(ByteCodes.OutputSetType);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC0(type);
+            dataStream.addDirectDataStream(ByteCodes.OutputSetType);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC0(type);
         end
         
-        function opOUTPUT_RESET(cmd,layer,nos)
-            % Command.opOUTPUT_RESET Add a opOUTPUT_RESET
+        function opOUTPUT_RESET(dataStream,layer,nos)
+            % DataStream.opOUTPUT_RESET Add a opOUTPUT_RESET
             %
-            % Command.opOUTPUT_RESET(layer,nos) adds a opOUTPUT_RESET opcode 
-            % to the command object.
+            % DataStream.opOUTPUT_RESET(layer,nos) adds a opOUTPUT_RESET opcode 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2067,18 +1839,18 @@ classdef Command < handle
             % - opOUTPUT_RESET,LC0(layer),LC0(nos)
             %
             % Example::
-            %           cmd.opOUTPUT_RESET(0,MotorBitfield.MotorA)
+            %           dataStream.opOUTPUT_RESET(0,MotorBitfield.MotorA)
                         
-            cmd.addDirectCommand(ByteCodes.OutputReset);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
+            dataStream.addDirectDataStream(ByteCodes.OutputReset);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
         end
         
-        function opOUTPUT_STOP(cmd,layer,nos,brake)
-            % Command.opOUTPUT_STOP Add a opOUTPUT_STOP
+        function opOUTPUT_STOP(dataStream,layer,nos,brake)
+            % DataStream.opOUTPUT_STOP Add a opOUTPUT_STOP
             %
-            % Command.opOUTPUT_STOP(layer,nos,brake) adds a opOUTPUT_STOP opcode 
-            % to the command object.
+            % DataStream.opOUTPUT_STOP(layer,nos,brake) adds a opOUTPUT_STOP opcode 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2086,19 +1858,19 @@ classdef Command < handle
             % - opOUTPUT_STOP,LC0(layer),LC0(nos),LC0(brake)
             %
             % Example::
-            %           cmd.opOUTPUT_STOP(0,MotorBitfield.MotorA,BrakeMode.Coast)
+            %           dataStream.opOUTPUT_STOP(0,MotorBitfield.MotorA,BrakeMode.Coast)
             
-            cmd.addDirectCommand(ByteCodes.OutputStop);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC0(brake);
+            dataStream.addDirectDataStream(ByteCodes.OutputStop);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC0(brake);
         end
         
-        function opOUTPUT_SPEED(cmd,layer,nos,speed)
-            % Command.opOUTPUT_SPEED Add a opOUTPUT_SPEED
+        function opOUTPUT_SPEED(dataStream,layer,nos,speed)
+            % DataStream.opOUTPUT_SPEED Add a opOUTPUT_SPEED
             %
-            % Command.opOUTPUT_SPEED(layer,nos,speed) adds a opOUTPUT_SPEED opcode 
-            % to the command object.
+            % DataStream.opOUTPUT_SPEED(layer,nos,speed) adds a opOUTPUT_SPEED opcode 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2107,19 +1879,19 @@ classdef Command < handle
             % - opOUTPUT_POWER,LC0(layer),LC0(nos),LC1(speed)
             %
             % Example::
-            %           cmd.opOUTPUT_SPEED(0,MotorBitfield.MotorA,10)
+            %           dataStream.opOUTPUT_SPEED(0,MotorBitfield.MotorA,10)
            
-            cmd.addDirectCommand(ByteCodes.OutputSpeed);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC1(speed);
+            dataStream.addDirectDataStream(ByteCodes.OutputSpeed);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC1(speed);
         end
         
-        function opOUTPUT_POWER(cmd,layer,nos,power)
-            % Command.opOUTPUT_POWER Add a opOUTPUT_POWER
+        function opOUTPUT_POWER(dataStream,layer,nos,power)
+            % DataStream.opOUTPUT_POWER Add a opOUTPUT_POWER
             %
-            % Command.opOUTPUT_POWER(layer,nos,speed) adds a opOUTPUT_POWER opcode 
-            % to the command object.
+            % DataStream.opOUTPUT_POWER(layer,nos,speed) adds a opOUTPUT_POWER opcode 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2128,19 +1900,19 @@ classdef Command < handle
             % - opOUTPUT_POWER,LC0(layer),LC0(nos),LC1(power)
             %
             % Example::
-            %           cmd.opOUTPUT_POWER(0,MotorBitfield.MotorA,10)
+            %           dataStream.opOUTPUT_POWER(0,MotorBitfield.MotorA,10)
             
-            cmd.addDirectCommand(ByteCodes.OutputPower);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC1(power);
+            dataStream.addDirectDataStream(ByteCodes.OutputPower);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC1(power);
         end
         
-        function opOUTPUT_START(cmd,layer,nos)
-            % Command.opOUTPUT_START Add a opOUTPUT_START
+        function opOUTPUT_START(dataStream,layer,nos)
+            % DataStream.opOUTPUT_START Add a opOUTPUT_START
             %
-            % Command.opOUTPUT_START(layer,nos) adds a opOUTPUT_START opcode 
-            % to the command object.
+            % DataStream.opOUTPUT_START(layer,nos) adds a opOUTPUT_START opcode 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2148,18 +1920,18 @@ classdef Command < handle
             % - opOUTPUT_START,LC0(layer),LC0(nos)
             %
             % Example::
-            %           cmd.opOUTPUT_START(0,MotorBitfield.MotorA)
+            %           dataStream.opOUTPUT_START(0,MotorBitfield.MotorA)
             
-            cmd.addDirectCommand(ByteCodes.OutputStart);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
+            dataStream.addByteCode(ByteCodes.OutputStart);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
         end
         
-        function opOUTPUT_POLARITY(cmd,layer,nos,pol)
-            % Command.opOUTPUT_POLARITY Add a opOUTPUT_POLARITY
+        function opOUTPUT_POLARITY(dataStream,layer,nos,pol)
+            % DataStream.opOUTPUT_POLARITY Add a opOUTPUT_POLARITY
             %
-            % Command.opOUTPUT_POLARITY(layer,nos,pol) adds a opOUTPUT_POLARITY opcode 
-            % to the command object.
+            % DataStream.opOUTPUT_POLARITY(layer,nos,pol) adds a opOUTPUT_POLARITY opcode 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2170,19 +1942,19 @@ classdef Command < handle
             % - opOUTPUT_POLARITY,LC0(layer),LC0(nos),LC0(pol)
             %
             % Example::
-            %           cmd.opOUTPUT_POLARITY(0,MotorBitfield.MotorA,0)
+            %           dataStream.opOUTPUT_POLARITY(0,MotorBitfield.MotorA,0)
             
-            cmd.addDirectCommand(ByteCodes.OutputPolarity);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC0(pol);
+            dataStream.addDirectDataStream(ByteCodes.OutputPolarity);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC0(pol);
         end
         
-        function opOUTPUT_READ(cmd,layer,no,speed,tacho)
-            % Command.opOUTPUT_READ Add a opOUTPUT_READ
+        function opOUTPUT_READ(dataStream,layer,no,speed,tacho)
+            % DataStream.opOUTPUT_READ Add a opOUTPUT_READ
             %
-            % Command.opOUTPUT_READ(layer,no,speed,tacho) adds a opOUTPUT_READ opcode 
-            % to the command object.
+            % DataStream.opOUTPUT_READ(layer,no,speed,tacho) adds a opOUTPUT_READ opcode 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2191,47 +1963,47 @@ classdef Command < handle
             %   stored
             % - tacho is the address in response buffer where the read tacho (DATA32) should be
             %   stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % - opOUTPUT_READ,LC0(layer),LC0(no),GV0(speed),GV0(tacho)
             %
             % Example::
-            %           cmd.opOUTPUT_READ(0,MotorPort.MotorA,0,1)
+            %           dataStream.opOUTPUT_READ(0,MotorPort.MotorA,0,1)
             
-            cmd.addDirectCommand(ByteCodes.OutputRead);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(tacho);
-            cmd.GV0(speed);
+            dataStream.addDirectDataStream(ByteCodes.OutputRead);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(tacho);
+            dataStream.GV0(speed);
         end 
         
-        function opOUTPUT_TEST(cmd,layer,nos,busy)
-            % Command.opOUTPUT_TEST Add a opOUTPUT_TEST
+        function opOUTPUT_TEST(dataStream,layer,nos,busy)
+            % DataStream.opOUTPUT_TEST Add a opOUTPUT_TEST
             %
-            % Command.opOUTPUT_READ(layer,nos) adds a opOUTPUT_TEST opcode 
-            % to the command object.
+            % DataStream.opOUTPUT_READ(layer,nos) adds a opOUTPUT_TEST opcode 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NOS is a bit field representing output 1 to 4 (0x01, 0x02, 0x04, 0x08)
             % - busy is the address in response buffer where the busy flag (DATA8) should be 
             %   stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % - opOUTPUT_TEST,LC0(layer),LC0(nos),GV0(value)
             %
             % Example::
-            %           cmd.opOUTPUT_TEST(0,MotorBitfield.MotorA,0)
+            %           dataStream.opOUTPUT_TEST(0,MotorBitfield.MotorA,0)
             
-            cmd.addDirectCommand(ByteCodes.OutputTest);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.GV0(busy);
+            dataStream.addDirectDataStream(ByteCodes.OutputTest);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.GV0(busy);
         end
         
-        function opOUTPUT_READY(cmd,layer,nos)
-            % Command.opOUTPUT_READY Add a opOUTPUT_READY
+        function opOUTPUT_READY(dataStream,layer,nos)
+            % DataStream.opOUTPUT_READY Add a opOUTPUT_READY
             %
-            % Command.opOUTPUT_READY(layer,nos) adds a opOUTPUT_READY opcode with 
-            % to the command object.
+            % DataStream.opOUTPUT_READY(layer,nos) adds a opOUTPUT_READY opcode with 
+            % to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2239,18 +2011,18 @@ classdef Command < handle
             % - opOUTPUT_READY,LC0(layer),LC0(nos)
             %
             % Example::
-            %           cmd.opOUTPUT_READY(0,MotorBitfield.MotorA)
+            %           dataStream.opOUTPUT_READY(0,MotorBitfield.MotorA)
             
-            cmd.addDirectCommand(ByteCodes.OutputReady);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
+            dataStream.addDirectDataStream(ByteCodes.OutputReady);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
         end 
         
-        function opOUTPUT_STEP_POWER(cmd,layer,nos,power,step1,step2,step3,brake)
-            % Command.opOUTPUT_STEP_POWER Add a opOUTPUT_STEP_POWER
+        function opOUTPUT_STEP_POWER(dataStream,layer,nos,power,step1,step2,step3,brake)
+            % DataStream.opOUTPUT_STEP_POWER Add a opOUTPUT_STEP_POWER
             %
-            % Command.opOUTPUT_STEP_POWER(layer,nos,power,step1,step2,step3,brake) 
-            % adds a opOUTPUT_STEP_POWER opcode to the command object. 
+            % DataStream.opOUTPUT_STEP_POWER(layer,nos,power,step1,step2,step3,brake) 
+            % adds a opOUTPUT_STEP_POWER opcode to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2263,24 +2035,24 @@ classdef Command < handle
             % - opOUTPUT_STEP_POWER,LC0(layer),LC0(nos),LC1(power),LC4(step1),LC4(step2),LC4(step3),LC0(brake)
             %
             % Example::
-            %           cmd.opOUTPUT_STEP_POWER(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
+            %           dataStream.opOUTPUT_STEP_POWER(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
             
-            cmd.addDirectCommand(ByteCodes.OutputStepPower);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC1(power);
-            cmd.LC4(step1);
-            cmd.LC4(step2);
-            cmd.LC4(step3);
-            cmd.LC0(brake);
+            dataStream.addDirectDataStream(ByteCodes.OutputStepPower);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC1(power);
+            dataStream.LC4(step1);
+            dataStream.LC4(step2);
+            dataStream.LC4(step3);
+            dataStream.LC0(brake);
         end
         
         % Implemented @ MMI 
-        function opOUTPUT_TIME_POWER(cmd,layer,nos,power,step1,step2,step3,brake)
-            % Command.opOUTPUT_TIME_POWER Add a opOUTPUT_TIME_POWER
+        function opOUTPUT_TIME_POWER(dataStream,layer,nos,power,step1,step2,step3,brake)
+            % DataStream.opOUTPUT_TIME_POWER Add a opOUTPUT_TIME_POWER
             %
-            % Command.opOUTPUT_TIME_POWER(layer,nos,power,step1,step2,step3,brake) 
-            % adds a opOUTPUT_TIME_POWER opcode to the command object. 
+            % DataStream.opOUTPUT_TIME_POWER(layer,nos,power,step1,step2,step3,brake) 
+            % adds a opOUTPUT_TIME_POWER opcode to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2293,23 +2065,23 @@ classdef Command < handle
             % - opOUTPUT_TIME_POWER,LC0(layer),LC0(nos),LC1(power),LC4(step1),LC4(step2),LC4(step3),LC0(brake)
             %
             % Example::
-            %           cmd.opOUTPUT_TIME_POWER(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
+            %           dataStream.opOUTPUT_TIME_POWER(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
             
-            cmd.addDirectCommand(ByteCodes.OutputTimePower);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC1(power);
-            cmd.LC4(step1);
-            cmd.LC4(step2);
-            cmd.LC4(step3);
-            cmd.LC0(brake);          
+            dataStream.addDirectDataStream(ByteCodes.OutputTimePower);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC1(power);
+            dataStream.LC4(step1);
+            dataStream.LC4(step2);
+            dataStream.LC4(step3);
+            dataStream.LC0(brake);          
         end
         
-        function opOUTPUT_STEP_SPEED(cmd,layer,nos,speed,step1,step2,step3,brake)
-            % Command.opOUTPUT_STEP_SPEED Add a opOUTPUT_STEP_SPEED
+        function opOUTPUT_STEP_SPEED(dataStream,layer,nos,speed,step1,step2,step3,brake)
+            % DataStream.opOUTPUT_STEP_SPEED Add a opOUTPUT_STEP_SPEED
             % 
-            % Command.opOUTPUT_STEP_SPEED(layer,nos,speed,step1,step2,step3,brake) 
-            % adds a opOUTPUT_STEP_SPEED opcode to the command object.
+            % DataStream.opOUTPUT_STEP_SPEED(layer,nos,speed,step1,step2,step3,brake) 
+            % adds a opOUTPUT_STEP_SPEED opcode to the DataStream object.
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2322,23 +2094,23 @@ classdef Command < handle
             % - opOUTPUT_STEP_POWER,LC0(layer),LC0(nos),LC1(speed),LC4(step1),LC4(step2),LC4(step3),LC0(brake)
             %
             % Example::
-            %           cmd.opOUTPUT_STEP_SPEED(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
+            %           dataStream.opOUTPUT_STEP_SPEED(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
             
-            cmd.addDirectCommand(ByteCodes.OutputStepSpeed);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC1(speed);
-            cmd.LC4(step1);
-            cmd.LC4(step2);
-            cmd.LC4(step3);
-            cmd.LC0(brake);
+            dataStream.addDirectDataStream(ByteCodes.OutputStepSpeed);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC1(speed);
+            dataStream.LC4(step1);
+            dataStream.LC4(step2);
+            dataStream.LC4(step3);
+            dataStream.LC0(brake);
         end
         
-        function opOUTPUT_TIME_SPEED(cmd,layer,nos,speed,step1,step2,step3,brake)
-            % Command.opOUTPUT_TIME_SPEED Add a opOUTPUT_TIME_SPEED
+        function opOUTPUT_TIME_SPEED(dataStream,layer,nos,speed,step1,step2,step3,brake)
+            % DataStream.opOUTPUT_TIME_SPEED Add a opOUTPUT_TIME_SPEED
             %
-            % Command.opOUTPUT_TIME_SPEED(layer,nos,speed,step1,step2,step3,brake) 
-            % adds a opOUTPUT_TIME_SPEED opcode to the command object. 
+            % DataStream.opOUTPUT_TIME_SPEED(layer,nos,speed,step1,step2,step3,brake) 
+            % adds a opOUTPUT_TIME_SPEED opcode to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2351,23 +2123,23 @@ classdef Command < handle
             % - opOUTPUT_TIME_SPEED,LC0(layer),LC0(nos),LC1(speed),LC4(step1),LC4(step2),LC4(step3),LC0(brake)
             %
             % Example::
-            %           cmd.opOUTPUT_TIME_SPEED(0,MotorBitfield.MotorA,50,100,1000,100,BrakeMode.Coast)
+            %           dataStream.opOUTPUT_TIME_SPEED(0,MotorBitfield.MotorA,50,100,1000,100,BrakeMode.Coast)
             
-            cmd.addDirectCommand(ByteCodes.OutputTimeSpeed);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC1(speed);
-            cmd.LC4(step1);
-            cmd.LC4(step2);
-            cmd.LC4(step3);
-            cmd.LC0(brake);
+            dataStream.addDirectDataStream(ByteCodes.OutputTimeSpeed);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC1(speed);
+            dataStream.LC4(step1);
+            dataStream.LC4(step2);
+            dataStream.LC4(step3);
+            dataStream.LC0(brake);
         end
         
-        function opOUTPUT_STEP_SYNC(cmd,layer,nos,power,turn,step,brake)
-            % Command.opOUTPUT_STEP_SYNC Add a opOUTPUT_STEP_SYNC
+        function opOUTPUT_STEP_SYNC(dataStream,layer,nos,power,turn,step,brake)
+            % DataStream.opOUTPUT_STEP_SYNC Add a opOUTPUT_STEP_SYNC
             %
-            % Command.opOUTPUT_STEP_SYNC(layer,nos,power,turn,step,brake) 
-            % adds a opOUTPUT_STEP_SYNC opcode to the command object. 
+            % DataStream.opOUTPUT_STEP_SYNC(layer,nos,power,turn,step,brake) 
+            % adds a opOUTPUT_STEP_SYNC opcode to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2379,22 +2151,22 @@ classdef Command < handle
             % - opOUTPUT_STEP_SYNC,LC0(layer),LC0(nos),LC1(power),LC2(turn),LC4(step),LC0(brake)
             %
             % Example::
-            %           cmd.opOUTPUT_STEP_SYNC(0,MotorBitfield.MotorA,50,30,100,BrakeMode.Coast)
+            %           dataStream.opOUTPUT_STEP_SYNC(0,MotorBitfield.MotorA,50,30,100,BrakeMode.Coast)
             
-            cmd.addDirectCommand(ByteCodes.OutputStepSync);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC1(power);
-            cmd.LC2(turn);
-            cmd.LC4(step);
-            cmd.LC0(brake);
+            dataStream.addDirectDataStream(ByteCodes.OutputStepSync);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC1(power);
+            dataStream.LC2(turn);
+            dataStream.LC4(step);
+            dataStream.LC0(brake);
         end
         
-        function opOUTPUT_TIME_SYNC(cmd,layer,nos,power,turn,time,brake)
-            % Command.opOUTPUT_TIME_SYNC Add a opOUTPUT_TIME_SYNC
+        function opOUTPUT_TIME_SYNC(dataStream,layer,nos,power,turn,time,brake)
+            % DataStream.opOUTPUT_TIME_SYNC Add a opOUTPUT_TIME_SYNC
             %
-            % Command.opOUTPUT_TIME_SYNC(layer,nos,power,turn,time,brake) 
-            % adds a opOUTPUT_TIME_SYNC opcode to the command object. 
+            % DataStream.opOUTPUT_TIME_SYNC(layer,nos,power,turn,time,brake) 
+            % adds a opOUTPUT_TIME_SYNC opcode to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2406,22 +2178,22 @@ classdef Command < handle
             % - opOUTPUT_STEP_SYNC,LC0(layer),LC0(nos),LC1(power),LC2(turn),LC4(time),LC0(brake)
             %
             % Example::
-            %           cmd.opOUTPUT_TIME_SYNC(0,MotorBitfield.MotorA,50,30,1000,BrakeMode.Coast)
+            %           dataStream.opOUTPUT_TIME_SYNC(0,MotorBitfield.MotorA,50,30,1000,BrakeMode.Coast)
             
-            cmd.addDirectCommand(ByteCodes.OutputTimeSync);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
-            cmd.LC1(power);
-            cmd.LC2(turn);
-            cmd.LC4(time);
-            cmd.LC0(brake);
+            dataStream.addDirectDataStream(ByteCodes.OutputTimeSync);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
+            dataStream.LC1(power);
+            dataStream.LC2(turn);
+            dataStream.LC4(time);
+            dataStream.LC0(brake);
         end
         
-        function opOUTPUT_CLR_COUNT(cmd,layer,nos)
-            % Command.opOUTPUT_CLR_COUNT Add a opOUTPUT_CLR_COUNT
+        function opOUTPUT_CLR_COUNT(dataStream,layer,nos)
+            % DataStream.opOUTPUT_CLR_COUNT Add a opOUTPUT_CLR_COUNT
             %
-            % Command.opOUTPUT_TIME_SYNC(layer,nos) adds a opOUTPUT_CLR_COUNT opcode 
-            % to the command object. 
+            % DataStream.opOUTPUT_TIME_SYNC(layer,nos) adds a opOUTPUT_CLR_COUNT opcode 
+            % to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
@@ -2429,42 +2201,42 @@ classdef Command < handle
             % - opOUTPUT_CLR_COUNT,LC0(layer),LC0(nos)
             %
             % Example::
-            %           cmd.opOUTPUT_CLR_COUNT(0,MotorBitfield.MotorA)
+            %           dataStream.opOUTPUT_CLR_COUNT(0,MotorBitfield.MotorA)
 
-            cmd.addDirectCommand(ByteCodes.OutputClrCount);
-            cmd.LC0(layer);
-            cmd.LC0(nos);
+            dataStream.addDirectDataStream(ByteCodes.OutputClrCount);
+            dataStream.LC0(layer);
+            dataStream.LC0(nos);
         end
         
-        function opOUTPUT_GET_COUNT(cmd,layer,no,tacho)
-            % Command.opOUTPUT_GET_COUNT Add a opOUTPUT_GET_COUNT
+        function opOUTPUT_GET_COUNT(dataStream,layer,no,tacho)
+            % DataStream.opOUTPUT_GET_COUNT Add a opOUTPUT_GET_COUNT
             %
-            % Command.opOUTPUT_GET_COUNT(layer,no,tacho) adds a opOUTPUT_GET_COUNT
-            % to the command object. 
+            % DataStream.opOUTPUT_GET_COUNT(layer,no,tacho) adds a opOUTPUT_GET_COUNT
+            % to the DataStream object. 
             %
             % Notes::
             % - layer is the usb chain layer (usually 0)
             % - NO is output motor number [0...3] ( != NOS)
             % - tacho is the address in response buffer where read tacho (DATA32) should be 
             %   stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % - opOUTPUT_GET_COUNT,LC0(layer),LC0(NO),GV0(tacho)
             %
             % Example::
-            %           cmd.opOUTPUT_GET_COUNT(0,MotorPort.MotorA,4)
+            %           dataStream.opOUTPUT_GET_COUNT(0,MotorPort.MotorA,4)
  
-            cmd.addDirectCommand(ByteCodes.OutputGetCount);
-            cmd.LC0(layer);
-            cmd.LC0(no);
-            cmd.GV0(tacho);
+            dataStream.addDirectDataStream(ByteCodes.OutputGetCount);
+            dataStream.LC0(layer);
+            dataStream.LC0(no);
+            dataStream.GV0(tacho);
         end
         
         % Implemented @ MMI
-        function opCOM_TEST(cmd,hardware,name,busy)
-            % Command.opCOM_TEST Add a opCOM_TEST
+        function opCOM_TEST(dataStream,hardware,name,busy)
+            % DataStream.opCOM_TEST Add a opCOM_TEST
             %
-            % Command.opCOM_TEST(hardware,name,value) adds a opCOM_TEST to
-            % the command object.
+            % DataStream.opCOM_TEST(hardware,name,value) adds a opCOM_TEST to
+            % the DataStream object.
             %
             % Notes::
             % - hardware is the communication adapter to be tested. 
@@ -2472,24 +2244,24 @@ classdef Command < handle
             % - name is the name of the device ('0': own adapter) (?)
             % - busy is the address in response buffer where the busy flag (DATA8) should be 
             %   stored
-            %   -> more info about response buffer: refer to GV0(cmd,i) 
+            %   -> more info about response buffer: refer to GV0(dataStream,i) 
             % - opCOM_TEST,LC0(hardware),LCS,'0',GV0(value)
             %
             % Example::
-            %           cmd.opCOM_TEST(1,'0',0)
+            %           dataStream.opCOM_TEST(1,'0',0)
             
-            cmd.addDirectCommand(ByteCodes.COMTest);
-            cmd.LC0(hardware);
-            cmd.addLCSString(name); 
-            cmd.GV0(value);
+            dataStream.addDirectDataStream(ByteCodes.COMTest);
+            dataStream.LC0(hardware);
+            dataStream.addLCSString(name); 
+            dataStream.GV0(value);
         end
         
         % Implemented @ MMI
-        function opCOM_READY(cmd,hardware,name)
-            % Command.opCOM_READY Add a opCOM_READY
+        function opCOM_READY(dataStream,hardware,name)
+            % DataStream.opCOM_READY Add a opCOM_READY
             %
-            % Command.opCOM_READY(hardware,name,value) adds a opCOM_READY to
-            % the command object.
+            % DataStream.opCOM_READY(hardware,name,value) adds a opCOM_READY to
+            % the DataStream object.
             %
             % Notes::
             % - hardware is the communication adapter to be tested. 
@@ -2499,57 +2271,57 @@ classdef Command < handle
             % - opCOM_READY,LC0(hardware),LCS,'0'
             %
             % Example::
-            %           cmd.opCOM_TEST(1,'0')
+            %           dataStream.opCOM_TEST(1,'0')
             
-            cmd.addDirectCommand(Bytecodes.COMReady);
-            cmd.LC0(hardware);
-            cmd.addLCSString(name);
+            dataStream.addDirectDataStream(Bytecodes.COMReady);
+            dataStream.LC0(hardware);
+            dataStream.addLCSString(name);
         end
         
-        function opCOMGET_GET_BRICKNAME(cmd,length,name)
-            % Command.opCOMGET_GET_BRICKNAME Add a opCOMGET_GET_BRICKNAME
+        function opCOMGET_GET_BRICKNAME(dataStream,length,name)
+            % DataStream.opCOMGET_GET_BRICKNAME Add a opCOMGET_GET_BRICKNAME
             %
-            % Command.opCOMGET_GET_BRICKNAME(length,name) adds a opCOMGET
-            % with a GET_BRICKNAME subcode to the command object. 
+            % DataStream.opCOMGET_GET_BRICKNAME(length,name) adds a opCOMGET
+            % with a GET_BRICKNAME subcode to the DataStream object. 
             %
             % Notes::
             % - length is the maximal length of string returned (-1 no check)
             % - name is the address in response buffer where string should begin
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opCOMGET_GET_BRICKNAME,LC0(13),LC0(length),GV0(name)
             %
             % Example::
-            %           cmd.opCOMGET_GET_BRICKNAME(10,0)
+            %           dataStream.opCOMGET_GET_BRICKNAME(10,0)
  
-            cmd.addDirectCommand(ByteCodes.COMGet);
-            cmd.LC0(COMGetSubCodes.GetBrickName);
-            cmd.LC0(length);
-            cmd.GV0(name);
+            dataStream.addDirectDataStream(ByteCodes.COMGet);
+            dataStream.LC0(COMGetSubCodes.GetBrickName);
+            dataStream.LC0(length);
+            dataStream.GV0(name);
         end 
         
-        function opCOMSET_SET_BRICKNAME(cmd,name)
-            % Command.opCOMSET_SET_BRICKNAME Add a opCOMSET_SET_BRICKNAME
+        function opCOMSET_SET_BRICKNAME(dataStream,name)
+            % DataStream.opCOMSET_SET_BRICKNAME Add a opCOMSET_SET_BRICKNAME
             %
-            % Command.opCOMSET_SET_BRICKNAME(name) adds a opCOMSET
-            % with a SET_BRICKNAME subcode to the command object. 
+            % DataStream.opCOMSET_SET_BRICKNAME(name) adds a opCOMSET
+            % with a SET_BRICKNAME subcode to the DataStream object. 
             %
             % Notes::
             % - name is the brick name to be set
             % - opCOMSET_SET_BRICKNAME,LC0(13),LCS,'E','V','3',0
             %
             % Example::
-            %           cmd.opCOMSET_SET_BRICKNAME('EV3')
+            %           dataStream.opCOMSET_SET_BRICKNAME('EV3')
  
-            cmd.addDirectCommand(ByteCodes.COMSet);
-            cmd.LC0(COMSetSubCodes.SetBrickName);
-            cmd.addLCSString(name);  
+            dataStream.addDirectDataStream(ByteCodes.COMSet);
+            dataStream.LC0(COMSetSubCodes.SetBrickName);
+            dataStream.addLCSString(name);  
         end
         
-        function opCOMGET_NETWORK(cmd,hardware,length,name,mac,ip)
-            % Command.opCOMGET_NETWORK Add a opCOMGET_NETWORK
+        function opCOMGET_NETWORK(dataStream,hardware,length,name,mac,ip)
+            % DataStream.opCOMGET_NETWORK Add a opCOMGET_NETWORK
             %
-            % Command.opCOMGET_NETWORK(length,name) adds a opCOMGET
-            % with a GET_NETWORK subcode to the command object. 
+            % DataStream.opCOMGET_NETWORK(length,name) adds a opCOMGET
+            % with a GET_NETWORK subcode to the DataStream object. 
             %
             % Notes::
             % - hardware is the hardware type (should always be 3 for this method)
@@ -2557,49 +2329,49 @@ classdef Command < handle
             % - name is the address in response buffer where name-string should begin
             % - mac is the address in response buffer where mac-string should begin
             % - ip is the address in response buffer where ip-string should begin
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opCOMGET_GET_BRICKNAME,LC0(13),LC0(hardware),LC0(length)
             %
             % Example::
-            %           cmd.opCOMGET_NETWORK(3,18,0,4,10)
+            %           dataStream.opCOMGET_NETWORK(3,18,0,4,10)
             
-            cmd.addDirectCommand(ByteCodes.COMGet);
-            cmd.LC0(COMGetSubCodes.GetNetwork);
-            cmd.LC0(hardware);
-            cmd.LC0(length);
-            cmd.GV0(name);
-            cmd.GV0(mac);
-            cmd.GV0(ip);
+            dataStream.addDirectDataStream(ByteCodes.COMGet);
+            dataStream.LC0(COMGetSubCodes.GetNetwork);
+            dataStream.LC0(hardware);
+            dataStream.LC0(length);
+            dataStream.GV0(name);
+            dataStream.GV0(mac);
+            dataStream.GV0(ip);
         end
         
-        function opCOMGET_ID(cmd,hardware,length,id)
-            % Command.opCOMGET_ID Add a opCOMGET_ID
+        function opCOMGET_ID(dataStream,hardware,length,id)
+            % DataStream.opCOMGET_ID Add a opCOMGET_ID
             %
-            % Command.opCOMGET_ID(hardware,length,id) adds a opCOMGET
-            % with a GET_ID subcode to the command object. 
+            % DataStream.opCOMGET_ID(hardware,length,id) adds a opCOMGET
+            % with a GET_ID subcode to the DataStream object. 
             %
             % Notes::
             % - hardware is the hardware type (should always be 2 for this method)
             % - length is the maximal length of string returned (-1 no check)
             % - id is the address in response buffer where string should begin
-            %   -> more info about response buffer: refer to GV0(cmd,i)
+            %   -> more info about response buffer: refer to GV0(dataStream,i)
             % - opCOMGET_ID,LC0(13),LC0(hardware),LC0(length),GV0(id)
             %
             % Example::
-            %           cmd.opCOMGET_ID(1,20,0)
+            %           dataStream.opCOMGET_ID(1,20,0)
  
-            cmd.addDirectCommand(ByteCodes.COMGet);
-            cmd.LC0(COMGetSubCodes.GetID);
-            cmd.LC0(hardware);
-            cmd.LC0(length);
-            cmd.GV0(id);
+            dataStream.addDirectDataStream(ByteCodes.COMGet);
+            dataStream.LC0(COMGetSubCodes.GetID);
+            dataStream.LC0(hardware);
+            dataStream.LC0(length);
+            dataStream.GV0(id);
         end
         
-        function opMAILBOX_WRITE(cmd,brickname,boxname,type,msg)
-            % Command.opMAILBOX_WRITE Add a opMAILBOX_WRITE
+        function opMAILBOX_WRITE(dataStream,brickname,boxname,type,msg)
+            % DataStream.opMAILBOX_WRITE Add a opMAILBOX_WRITE
             %
-            % Command.opMAILBOX_WRITE(brickname,boxname,type,msg) adds a
-            % opMAILBOX_WRITE to the command object.
+            % DataStream.opMAILBOX_WRITE(brickname,boxname,type,msg) adds a
+            % opMAILBOX_WRITE to the DataStream object.
             %
             % Notes::
             % - brickname is the name of remote device
@@ -2610,37 +2382,37 @@ classdef Command < handle
             % - opMAILBOX_WRITE,LCS,'T','5','0','0',0,0,LCS,'a','b','c',LC0(0),LC0(1),LC0(1)
             %
             % Example::
-            %           cmd.opMAILBOX_WRITE('T500','abc','logical',1)
+            %           dataStream.opMAILBOX_WRITE('T500','abc','logical',1)
             
-            cmd.addDirectCommand(ByteCodes.MailboxWrite);
-            cmd.addLCSString(brickname);
+            dataStream.addDirectDataStream(ByteCodes.MailboxWrite);
+            dataStream.addLCSString(brickname);
             % hardware transportation media (not used)
-            cmd.LC0(0);
-            cmd.addLCSString(boxname);
+            dataStream.LC0(0);
+            dataStream.addLCSString(boxname);
             % type
             switch type
                 case 'logic'
-                    cmd.LC0(0);
-                    cmd.LC0(1);
-                    cmd.LC0(msg);
+                    dataStream.LC0(0);
+                    dataStream.LC0(1);
+                    dataStream.LC0(msg);
                 case 'numeric'
-                    cmd.LC0(3);
-                    cmd.LC0(1);
-                    cmd.LC4(typecast(single(msg),'int32'));
+                    dataStream.LC0(3);
+                    dataStream.LC0(1);
+                    dataStream.LC4(typecast(single(msg),'int32'));
                 case 'text'
-                    cmd.LC0(4);
-                    cmd.LC0(1);
-                    cmd.addLCSString(msg);
+                    dataStream.LC0(4);
+                    dataStream.LC0(1);
+                    dataStream.addLCSString(msg);
                  otherwise
                     fprintf('Error! Type must be ''text'', ''numeric'' or ''logic''.\n');
             end
         end
     
-        function BEGIN_DOWNLOAD(cmd,filelength,filename)
-            % Command.BEGIN_DOWNLOAD Add a BEGIN_DOWNLOAD 
+        function BEGIN_DOWNLOAD(dataStream,filelength,filename)
+            % DataStream.BEGIN_DOWNLOAD Add a BEGIN_DOWNLOAD 
             %
-            % Command.BEGIN_DOWNLOAD(filelength,filename) adds a BEGIN_DOWNLOAD
-            % system command to the command object. Download is from PC to
+            % DataStream.BEGIN_DOWNLOAD(filelength,filename) adds a BEGIN_DOWNLOAD
+            % system DataStream to the DataStream object. Download is from PC to
             % brick.
             %
             % Notes::
@@ -2650,18 +2422,18 @@ classdef Command < handle
             % - ss (BEGIN_DOWNLOAD) llllllll (filelength) nn.. (filename)
             %
             % Example::
-            %           cmd.BEGIN_DOWNLOAD(60,'../apps/tst/tst.rbf')
+            %           dataStream.BEGIN_DOWNLOAD(60,'../apps/tst/tst.rbf')
             
-            cmd.addSystemCommand(SystemCommands.BeginDownload);
-            cmd.addArray(typecast(uint32(filelength),'uint8'));
-            cmd.addString(filename);            
+            dataStream.addSystemDataStream(SystemDataStreams.BeginDownload);
+            dataStream.addArray(typecast(uint32(filelength),'uint8'));
+            dataStream.addString(filename);            
         end
             
-        function CONTINUE_DOWNLOAD(cmd,handle,payload)
-            % Command.CONTINUE_DOWNLOAD Add a CONTINUE_DOWNLOAD
+        function CONTINUE_DOWNLOAD(dataStream,handle,payload)
+            % DataStream.CONTINUE_DOWNLOAD Add a CONTINUE_DOWNLOAD
             %
-            % Command.CONTINUE_DOWNLOAD(handle,payload) adds a
-            % CONTINUE_DOWNLOAD system command to the command object.
+            % DataStream.CONTINUE_DOWNLOAD(handle,payload) adds a
+            % CONTINUE_DOWNLOAD system DataStream to the DataStream object.
             % Download is from PC to brick.
             %
             % Notes::
@@ -2670,18 +2442,18 @@ classdef Command < handle
             % - ss (CONTINUE_DOWNLOAD) hh (handle from BEGIN_DOWNLOAD REPLY) pppppppp ... (payload)
             %
             % Example::
-            %           cmd.CONTINUE_DOWNLOAD(0,[10 20 30 .... ])
+            %           dataStream.CONTINUE_DOWNLOAD(0,[10 20 30 .... ])
             
-            cmd.addSystemCommand(SystemCommands.ContinueDownload);
-            cmd.addValue(handle);
-            cmd.addArray(payload);
+            dataStream.addSystemDataStream(SystemDataStreams.ContinueDownload);
+            dataStream.addValue(handle);
+            dataStream.addArray(payload);
         end
         
-        function BEGIN_UPLOAD(cmd,filelength,filename)
-            % Command.BEGIN_UPLOAD Add a BEGIN_UPLOAD
+        function BEGIN_UPLOAD(dataStream,filelength,filename)
+            % DataStream.BEGIN_UPLOAD Add a BEGIN_UPLOAD
             %
-            % Command.BEGIN_UPLOAD(filelength,filename) adds a BEGIN_UPLOAD
-            % system command to the command object. Upload is from brick to
+            % DataStream.BEGIN_UPLOAD(filelength,filename) adds a BEGIN_UPLOAD
+            % system DataStream to the DataStream object. Upload is from brick to
             % PC.
             %
             % Notes::
@@ -2691,18 +2463,18 @@ classdef Command < handle
             % - ss (BEGIN_UPLOAD) llll (filelength/bytes to read) nn..(filename including path)
             %
             % Example::
-            %            cmd.BEGIN_UPLOAD(100,'../apps/tst/tst.rbf')
+            %            dataStream.BEGIN_UPLOAD(100,'../apps/tst/tst.rbf')
            
-           cmd.addSystemCommand(SystemCommands.BeginUpload);
-           cmd.addArray(typecast(uint16(filelength),'uint8'));
-           cmd.addString(filename);
+           dataStream.addSystemDataStream(SystemDataStreams.BeginUpload);
+           dataStream.addArray(typecast(uint16(filelength),'uint8'));
+           dataStream.addString(filename);
         end
         
-        function CONTINUE_UPLOAD(cmd,handle,maxlength)
-            % Command.CONTINUE_UPLOAD Add a CONTINUE_UPLOAD
+        function CONTINUE_UPLOAD(dataStream,handle,maxlength)
+            % DataStream.CONTINUE_UPLOAD Add a CONTINUE_UPLOAD
             %
-            % Command.CONTINUE_UPLOAD(handle,maxlength) adds a
-            % CONTINUE_UPLOAD system command to the commanc object. Upload
+            % DataStream.CONTINUE_UPLOAD(handle,maxlength) adds a
+            % CONTINUE_UPLOAD system DataStream to the commanc object. Upload
             % is from brick to PC.
             %
             % Notes::
@@ -2710,18 +2482,18 @@ classdef Command < handle
             % - maxlength is the max buffer size used for file upload
             % - ss (CONTINUE_UPLOAD) hh (handle from BEGIN_UPLOAD REPLY) llll (maxlength/bytes to read)
             % Example::
-            %           cmd.CONTINUE_UPLOAD(0,100)
+            %           dataStream.CONTINUE_UPLOAD(0,100)
             
-            cmd.addSystemCommand(SystemCommands.ContinueUpload);
-            cmd.addValue(handle);
-            cmd.addArray(typecast(uint16(maxlength),'uint8'));
+            dataStream.addSystemDataStream(SystemDataStreams.ContinueUpload);
+            dataStream.addValue(handle);
+            dataStream.addArray(typecast(uint16(maxlength),'uint8'));
         end
         
-        function LIST_FILES(cmd,maxlength,pathname)
-            % Command.LIST_FILES Add a LIST_FILES
+        function LIST_FILES(dataStream,maxlength,pathname)
+            % DataStream.LIST_FILES Add a LIST_FILES
             %
-            % Command.LIST_FILES(maxlength,pathname) adds a LIST_FILES
-            % system command to the command object.
+            % DataStream.LIST_FILES(maxlength,pathname) adds a LIST_FILES
+            % system DataStream to the DataStream object.
             %
             % Notes::
             % - maxlength is the max buffer size used for file listing
@@ -2729,18 +2501,18 @@ classdef Command < handle
             % - ss (LIST_FILES) llll (maxlength/max bytes to read) nn..(pathname)
             %
             % Example::
-            %           cmd.LIST_FILES(100,'/home/root/lms2012/')
+            %           dataStream.LIST_FILES(100,'/home/root/lms2012/')
             
-            cmd.addSystemCommand(SystemCommands.ListFiles);
-            cmd.addArray(typecast(uint16(maxlength),'uint8'));
-            cmd.addString(pathname)
+            dataStream.addSystemDataStream(SystemDataStreams.ListFiles);
+            dataStream.addArray(typecast(uint16(maxlength),'uint8'));
+            dataStream.addString(pathname)
         end
         
-        function CONTINUE_LIST_FILES(cmd,handle,maxlength)
-            % Command.CONTINUE_LIST_FILES Add a CONTINUE_LIST_FILES
+        function CONTINUE_LIST_FILES(dataStream,handle,maxlength)
+            % DataStream.CONTINUE_LIST_FILES Add a CONTINUE_LIST_FILES
             %
-            % Command.CONTINUE_LIST_FILES(handle,maxlength) adds a
-            % CONTINUE_LIST_FILES system command to the command object.
+            % DataStream.CONTINUE_LIST_FILES(handle,maxlength) adds a
+            % CONTINUE_LIST_FILES system DataStream to the DataStream object.
             %
             % Notes::
             % - handle is the handle returned by LIST_FILES
@@ -2749,18 +2521,18 @@ classdef Command < handle
             
             %
             % Example::
-            %           cmd.CONTINUE_LIST_FILES(0,100)
+            %           dataStream.CONTINUE_LIST_FILES(0,100)
             
-            cmd.addSystemCommand(SystemCommands.ContinueListFiles);
-            cmd.addValue(handle);
-            cmd.addArray(typecast(uint16(maxlength),'uint8'));
+            dataStream.addSystemDataStream(SystemDataStreams.ContinueListFiles);
+            dataStream.addValue(handle);
+            dataStream.addArray(typecast(uint16(maxlength),'uint8'));
         end
         
-        function CREATE_DIR(cmd,pathname)
-            % Command.CREATE_DIR Add a CREATE_DIR
+        function CREATE_DIR(dataStream,pathname)
+            % DataStream.CREATE_DIR Add a CREATE_DIR
             %
-            % Command.CREATE_DIR(pathname) adds a CREATE_DIR system command
-            % to the command object.
+            % DataStream.CREATE_DIR(pathname) adds a CREATE_DIR system DataStream
+            % to the DataStream object.
             %
             % Notes::
             % - pathname is the absolute path for directory creation.
@@ -2768,34 +2540,34 @@ classdef Command < handle
             
             %
             % Example::
-            %           cmd.CREATE_DIR('/home/root/lms2012/newdir')
+            %           dataStream.CREATE_DIR('/home/root/lms2012/newdir')
             
-            cmd.addSystemCommand(SystemCommands.CreateDir);
-            cmd.addString(pathname);
+            dataStream.addSystemDataStream(SystemDataStreams.CreateDir);
+            dataStream.addString(pathname);
         end
         
-        function DELETE_FILE(cmd,pathname)
-            % Command.DELETE_FILE Add a DELETE_FILE
+        function DELETE_FILE(dataStream,pathname)
+            % DataStream.DELETE_FILE Add a DELETE_FILE
             %
-            % Command.DELETE_FILE(pathname) adds a DELETE_FILE system
-            % command to the command object.
+            % DataStream.DELETE_FILE(pathname) adds a DELETE_FILE system
+            % DataStream to the DataStream object.
             %
             % Notes::
             % - pathname is the absolute file path for deleteion
             % - ss (DELETE_FILE) pp (pathname)
             %
             % Example::
-            %           cmd.DELETE_FILE('/home/root/lms2012/newdir')
+            %           dataStream.DELETE_FILE('/home/root/lms2012/newdir')
             
-            cmd.addSystemCommand(SystemCommands.DeleteFile);
-            cmd.addString(pathname);
+            dataStream.addSystemDataStream(SystemDataStreams.DeleteFile);
+            dataStream.addString(pathname);
         end
         
-        function WRITEMAILBOX(cmd,title,type,msg)
-            % Command.WRITEMAILBOX Add a WRITEMAILBOX
+        function WRITEMAILBOX(dataStream,title,type,msg)
+            % DataStream.WRITEMAILBOX Add a WRITEMAILBOX
             %
-            % Command.WRITEMAILBOX(title,type,msg) adds a WRITEMAILBOX
-            % command to the command object. 
+            % DataStream.WRITEMAILBOX(title,type,msg) adds a WRITEMAILBOX
+            % DataStream to the DataStream object. 
             %
             % Notes::
             % - title is the message title sent from the brick
@@ -2804,25 +2576,25 @@ classdef Command < handle
             % - msg is the message to be sent
             %
             % Example::
-            %           cmd.WRITEMAILBOX('abc','text','hello!')
+            %           dataStream.WRITEMAILBOX('abc','text','hello!')
  
-            cmd.addSystemCommand(SystemCommands.WriteMailBox);
-            cmd.addValue(length(title)+1);
-            cmd.addString(title);
+            dataStream.addSystemDataStream(SystemDataStreams.WriteMailBox);
+            dataStream.addValue(length(title)+1);
+            dataStream.addString(title);
             switch type
                 case 'text'
-                    cmd.addArray(typecast(uint16(length(msg)+1),'uint8'));
-                    cmd.addString(msg);
+                    dataStream.addArray(typecast(uint16(length(msg)+1),'uint8'));
+                    dataStream.addString(msg);
                 case 'numeric'
-                    cmd.addArray(typecast(uint16(4),'uint8'));
-                    cmd.addArray(typecast(single(msg),'uint8'));
+                    dataStream.addArray(typecast(uint16(4),'uint8'));
+                    dataStream.addArray(typecast(single(msg),'uint8'));
                 case 'logic'
-                    cmd.addArray(typecast(uint16(1),'uint8'));
+                    dataStream.addArray(typecast(uint16(1),'uint8'));
                     if msg(1) >= 1
                         msg(1) = 1;
                     else msg(1) = 0;
                     end
-                    cmd.addArray(typecast(uint8(msg),'uint8'));
+                    dataStream.addArray(typecast(uint8(msg),'uint8'));
             end
         end 
         
diff --git a/source/Packet.m b/source/Packet.m
new file mode 100644
index 0000000..1c309ca
--- /dev/null
+++ b/source/Packet.m
@@ -0,0 +1,45 @@
+classdef Packet < DataStream
+    properties
+        packetType;
+        counter;
+        
+        nGlobalVariables;
+        nLocalVariables;
+    end
+    
+    methods
+        function addHeader(packet, varargin)
+            packet.msg = [packet.msg typecast(uint16(packet.counter), 'uint8') uint8(packet.packetType)];
+            if packet.packetType == PacketType.DirectCommandReply || packet.packetType == PacketType.DirectCommandNoReply
+                packet.addVariables(); 
+            end
+        end
+        
+        function addLength(packet)
+            % Command.addLength Add command length
+            %
+            % Command.addLength() adds the command message length to the 
+            % start of command object message.
+            % 
+            % Example::
+            %            cmd.addLength()
+            
+           cmd.msg = [typecast( uint16(length(packet.msg)), 'uint8') packet.msg]; 
+        end
+        
+        function opOUTPUT_START(packet,layer,nos)
+            packet.packetType = PacketType.DirectCommandNoReply;
+            packet.counter = 42;
+            packet.nGlobalVariables = 0;
+            packet.nLocalVariables = 0;
+            opOUTPUT_START@DataStream(packet,layer,nos);
+        end
+    end
+    
+    methods (Access = private) 
+        function addVariables(packet)
+            packet.msg = [packet.msg typecast( bitor(bitshift(uint16(packet.nLocalVariables),10),uint16(packet.nGlobalVariables)), 'uint8')];
+        end
+    end
+end
+
diff --git a/source/PacketType.m b/source/PacketType.m
new file mode 100644
index 0000000..7473c4b
--- /dev/null
+++ b/source/PacketType.m
@@ -0,0 +1,9 @@
+classdef PacketType < uint8
+    enumeration
+        DirectCommandReply (0)
+        DirectCommandNoReply (128)
+        SystemCommandReply (1)
+        SystemCommandNoReply (129)
+    end
+end
+
diff --git a/source/Program.m b/source/Program.m
new file mode 100644
index 0000000..cfb8cb0
--- /dev/null
+++ b/source/Program.m
@@ -0,0 +1,155 @@
+classdef Program < DataStream
+    properties
+    end
+    
+    methods
+        function addHeader(packet, varargin)
+            
+        end
+        
+        function PROGRAMHeader(cmd,VersionInfo,NumberOfObjects,GlobalBytes)
+            % Command.PROGRAMHeader add a PROGRAMHeader
+            %
+            % Command.PROGRAMHeader(VersionInfo,NumberOfObjects,GlobalBytes) 
+            % adds a PROGRAMHeader to the command object.
+            %
+            % Notes::
+            % - VersionInfo is not used in the current byte implementation
+            % (hardcoded to 1.04)
+            % - NumberOfObjects is the number of objects used
+            % - GlobalBytes is the number of global bytes
+            % - PROGRAMHEADER is defined as 'L','E','G','O',LONGToBytes(0),WORDToBytes((UWORD)(BYTECODE_VERSION * 100.0)),WORDToBytes(NumberOfObjects),LONGToBytes(GlobalBytes)
+            %
+            % Example::
+            %           cmd.PROGRAMHeader(0,1,0)
+            
+            BYTECODE_VERSION = 1.04;
+            cmd.msg = [cmd.msg,uint8('L'),uint8('E'),uint8('G'),uint8('O')] ;
+            cmd.LONGToBytes(0);
+            cmd.WORDToBytes(BYTECODE_VERSION*100);
+            cmd.WORDToBytes(NumberOfObjects);
+            cmd.LONGToBytes(GlobalBytes);
+        end
+        
+        function VMTHREADHeader(cmd,OffsetToInstructions,LocalBytes)
+            % Command.VMTHREADHeader Add a VMTHREADHeader
+            %
+            % Command.VMTHREADHeader(OffsetToInstructions,LocalBytes)
+            % adds a VMTHREADHeader to the command object.
+            %
+            % Notes::
+            % - OffsetToInstructions is the offset to the instructions
+            % - LocalBytes is the number of local bytes
+            % - VMTHREADHeader is defined as LONGToBytes(OffsetToInstructions),0,0,0,0,LONGToBytes(LocalBytes)
+            %
+            % Example::
+            %           cmd.VMTHREADHeader(0,1)
+            
+            cmd.LONGToBytes(OffsetToInstructions);
+            cmd.msg = [cmd.msg uint8(0),uint8(0),uint8(0),uint8(0)];
+            cmd.LONGToBytes(LocalBytes) ;
+        end
+        
+        function SUBCALLHeader(cmd,OffsetToInstructions,LocalBytes)
+            % Command.SUBCALLHeader Add a SUBCALLHeader
+            %
+            % Command.SUBCALLHeader(OffsetToInstructions,LocalBytes)
+            % adds a SUBCALLHeader to the command object.
+            %
+            % Notes::
+            % - OffsetToInstructions is the offset to the instructions
+            % - LocalBytes is the number of local bytes
+            % - SUBCALLHeader is defined as LONGToBytes(OffsetToInstructions),0,0,1,0,LONGToBytes(LocalBytes)
+            %
+            % Example::
+            %           cmd.SUBCALLHeader(0,1)
+            
+            cmd.LONGToBytes(OffsetToInstructions);
+            cmd.msg = [cmd.msg uint8(0),uint8(0),uint8(1),uint8(0)];
+            cmd.LONGToBytes(LocalBytes) ;
+        end
+        
+        function BLOCKHeader(cmd,OffsetToInstructions,OwnerObjectId,TriggerCount)
+            % Command.BLOCKHeader
+            %
+            % Command.BLOCKHeader(OffsetToInstructions,OwnerObjectId,TriggerCount)
+            % adds a BLOCKHeader to the command object.
+            %
+            % Notes::
+            % - OffsetToInstructions is the offset to the instructions
+            % - OwnerObjectId is the owner object id
+            % - TriggerCount is the trigger count
+            % - BLOCKHeader is defined as LONGToBytes(OffsetToInstructions),WORDToBytes(OwnerObjectId),WORDToBytes(TriggerCount),LONGToBytes(0)
+            %
+            % Example::
+            %           cmd.BLOCKHeader(0,0,0)
+            
+            cmd.LONGToBytes(OffsetToInstructions);
+            cmd.WORDToBytes(OwnerObjectId);
+            cmd.WORDToBytes(TriggerCount)
+            cmd.LONGToBytes(0);
+        end  
+        
+        function addLength(cmd)
+            % Command.addFileSize Add file size
+            % 
+            % Command.addFileSize() adds the file size to the command
+            % object.
+            %
+            % Notes::
+            % - With bytecode compiling using "Old header", the file size is 
+            % inserted at byte number 5 which corresponds to the two bytes 
+            % after 'L','E','G','O'
+            %
+            % Example::
+            %            cmd.addFileSize
+            
+            cmd.msg(5:6) = typecast(uint16(length(cmd.msg)),'uint8');            
+        end
+        
+        function opOBJECT_END(cmd)
+            % Command.opOBJECT_END Add a opOBJECT_END
+            % 
+            % Command.opOBJECT_END() adds a opOBJECT_END opcode to the
+            % command object. 
+            %
+            % Notes::
+            % - opOBJECT_END
+            %
+            % Example::            
+            %           cmd.opOBJECT_END()
+           
+            cmd.addDirectCommand(ByteCodes.ObjectEnd);
+        end
+        
+        function opNOP(cmd)
+            % Command.opNOP Add a opNOP 
+            %
+            % Command.opNOP() adds a opNOP opcode to the command object.
+            %
+            % Example::
+            %           cmd.opNOP()
+           
+            cmd.addDirectCommand(ByteCodes.Nop);            
+        end
+        
+        function opJR(cmd,offset)
+            % Command.opJR Add a opJR
+            %
+            % Command.opJR(offset) adds a opJR opcode to the command
+            % object.
+            %
+            % Notes::
+            % - offset is the number of command to jump where the sign
+            % indicates the jump direction
+            % - opJR,LC0(offset)
+            %
+            % Example::
+            %           cmd.opJR(-10)
+
+            cmd.addDirectCommand(ByteCodes.Jr);
+            cmd.LC0(offset);
+        end
+    end
+end
+
-- 
GitLab