public MoveRequest(params Point[] points)
     : base(CommandConstants.Move)
 {
     foreach (Point point in points)
     {
         Bytes.Add((Byte)(point.X >> 8));
         Bytes.Add((Byte)(point.X & 0xFF));
         Bytes.Add((Byte)(point.Y >> 8));
         Bytes.Add((Byte)(point.Y & 0xFF));
     }
 }
Beispiel #2
0
        public override byte[] ByteOutput()
        {
            TreatVariable(V1, 0);
            TreatVariable(V2, 1);

            Bytes.Add(OPCodes.Codes.Ifn);
            Bytes.Add((int)Flag);

            Bytes.Add(0);

            return(Bytes.Convert());
        }
 public LineRequest(Point from, Point to)
     : base(CommandConstants.Line)
 {
     Bytes.Add((Byte)(from.X >> 8));
     Bytes.Add((Byte)(from.X & 0xFF));
     Bytes.Add((Byte)(from.Y >> 8));
     Bytes.Add((Byte)(from.Y & 0xFF));
     Bytes.Add((Byte)(to.X >> 8));
     Bytes.Add((Byte)(to.X & 0xFF));
     Bytes.Add((Byte)(to.Y >> 8));
     Bytes.Add((Byte)(to.Y & 0xFF));
 }
        public override byte[] ByteOutput()
        {
            Bytes.Add(OPCodes.Codes.AssignTypeRegister);
            Bytes.Add(0);
            Bytes.Add(V1.Type);

            Bytes.Add(new AssignOperationRegister(V1, 0).ByteOutput());

            Bytes.Add(OPCodes.Codes.Cast);
            Bytes.Add(V2.Type);
            Bytes.Add(V2.Address);

            return(Bytes.Convert());
        }
Beispiel #5
0
 private void TreatVariable(Variable v, int id)
 {
     if (v is IConstVariable)
     {
         Bytes.Add(OPCodes.Codes.AssignStaticConditionRegister);
         Bytes.Add(id);
         Bytes.Add(v.As <IConstVariable>().GetValueAsBytes());
     }
     else
     {
         Bytes.Add(OPCodes.Codes.AssignConditionRegister);
         Bytes.Add(id);
         Bytes.Add(v.Address);
     }
 }
Beispiel #6
0
        public override byte[] ByteOutput()
        {
            Bytes.Add(new AssignTargetRegisterInstruction(Source, 0));
            Bytes.Add(new AssignTargetRegisterInstruction(Destination, 1));

            if (Source is ConstPtrVariable)
            {
                Bytes.Add(OPCodes.Codes.AssignPtrCarry);
            }

            Bytes.Add(OPCodes.Codes.Set);
            Bytes.Add(Source.Size);
            Bytes.Add(Source.GetAddressOrValue());
            Bytes.Add(Destination.GetAddressOrValue());

            return(Bytes.Convert());
        }
Beispiel #7
0
        public override byte[] ByteOutput()
        {
            if (Variable is IConstVariable)
            {
                Bytes.Add(OPCodes.Codes.SetReturnCarry);
                Bytes.Add(Variable.Size);
                Bytes.Add(Variable.As <IConstVariable>().GetValueAsBytes());
            }
            else
            {
                Bytes.Add(OPCodes.Codes.Ret);
                Bytes.Add(Variable.Address);
                Bytes.Add(Defines.SIZE_INT);
            }

            Bytes.Add(OPCodes.Codes.FctPop);

            return(Bytes.Convert());
        }
Beispiel #8
0
        private void TreatVariable(int id)
        {
            if (From[id] is IConstVariable)
            {
                IConstVariable v = From[1] as IConstVariable;

                Bytes.Add(OPCodes.Codes.AssignConstOperationRegister);
                Bytes.Add(id);
                Bytes.Add(From[id].Size);
                Bytes.Add(v.GetValueAsBytes());
            }
            else
            {
                Bytes.Add(OPCodes.Codes.AssignOperationRegister);
                Bytes.Add(id);
                Bytes.Add(From[id].Size);
                Bytes.Add(From[id].Address);
            }
        }
Beispiel #9
0
        public void GetBytes(Bytes bytes)
        {
            Bytes thingsBytes  = new Bytes();
            Bytes rectsBytes   = new Bytes();
            Bytes circlesBytes = new Bytes();
            Bytes textsBytes   = new Bytes();

            foreach (Thing obj in things)
            {
                obj.GetBytes(thingsBytes, POV);
            }

            foreach (Rect rect in rects)
            {
                rect.GetBytes(rectsBytes, POV);
            }

            foreach (Circle circle in circles)
            {
                circle.GetBytes(circlesBytes, POV);
            }

            foreach (Text text in texts)
            {
                text.GetBytes(textsBytes, POV);
            }

            bytes.Add(thingsBytes.Count);
            bytes.Add(thingsBytes);

            bytes.Add(rectsBytes.Count);
            bytes.Add(rectsBytes);

            bytes.Add(circlesBytes.Count);
            bytes.Add(circlesBytes);

            bytes.Add(textsBytes.Count);
            bytes.Add(textsBytes);
        }
Beispiel #10
0
        public int LoadSourceFile(string pathByteCode, SourceFileFormat format)
        {
            BytesROM bytesROM;

            SourceCodeFormat = format;

            if (format == SourceFileFormat.JSON_HEX)
            {
                using (StreamReader file = File.OpenText(pathByteCode))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    bytesROM = (BytesROM)serializer.Deserialize(file, typeof(BytesROM));

                    for (int i = 0; i < bytesROM.Bytes.Length; i++)
                    {
                        Bytes.Add(bytesROM.Bytes[i]);
                    }
                }
            }
            //TODO: add other formats from the enum

            return(0);
        }
        public override byte[] ByteOutput()
        {
            int addr = 0;

            Bytes.Add(OPCodes.Codes.LibCall);
            Bytes.Add(Variables.Sum(i => i.Size));
            Bytes.Add(Lib.Length);
            Bytes.Add(Fct.Length);
            Bytes.Add(Lib);
            Bytes.Add(Fct);

            // arguments à gérer
            foreach (Variable variable in Variables)
            {
                if (variable is IConstVariable)
                {
                    Bytes.Add(OPCodes.Codes.VarConstCopy);
                    Bytes.Add(variable.Size);
                    Bytes.Add(variable.As <IConstVariable>().GetValueAsBytes());
                    Bytes.Add(addr);
                }
                else
                {
                    Bytes.Add(OPCodes.Codes.VarFctCopy);
                    Bytes.Add(variable.Size);
                    Bytes.Add(variable.Address);
                    Bytes.Add(addr);
                }

                addr += variable.Size;
            }

            Bytes.Add(OPCodes.Codes.FctStart);

            return(Bytes.Convert());
        }
Beispiel #12
0
 public DigitalReadRequest(byte pinToRead)
     : base(CommandConstants.DigitalRead)
 {
     Bytes.Add(pinToRead);
 }
 public AnalogWriteRequest(byte pinToWrite, byte valueToWrite)
     : base(CommandConstants.AnalogWrite)
 {
     Bytes.Add(pinToWrite);
     Bytes.Add(valueToWrite);
 }
Beispiel #14
0
 public LuaString(string s)
 {
     Bytes = Encoding.UTF8.GetBytes(s).ToList();
     Bytes.Add(0);
 }
Beispiel #15
0
 public PinModeRequest(byte pin, PinMode mode)
     : base(CommandConstants.PinMode)
 {
     Bytes.Add(pin);
     Bytes.Add((byte)mode);
 }
Beispiel #16
0
 public DigitalWriteRequest(byte pinToWrite, DigitalValue pinValue)
     : base(CommandConstants.DigitalWrite)
 {
     Bytes.Add(pinToWrite);
     Bytes.Add((byte)pinValue);
 }
Beispiel #17
0
 public Packet(PacketOP op)
 {
     OP = op;
     Bytes.Add((byte)op);
 }
Beispiel #18
0
        public override byte[] ByteOutput()
        {
            Bytes.Add(OPCodes.Codes.FctPop);

            return(Bytes.Convert());
        }
Beispiel #19
0
    public MotorolaSRECfile(string filename)
    {
        // if (filename.ToLower().EndsWith(".s19") != true) FileErrorMessages.Add("Файл имеет расширение отличное от s19");
        if (filename.ToLower().EndsWith(".s19") | filename.ToLower().EndsWith(".s28") | filename.ToLower().EndsWith(".s37") |
            filename.ToLower().EndsWith(".srec") | filename.ToLower().EndsWith(".sx"))
        {
        }
        else
        {
            FileErrorMessages.Add(" Файл имеет расширение отличное от srec (s19, s28, s37, sx)");
        }
        try
        {
            StreamReader sr         = new StreamReader(filename);
            bool         eof        = false;
            int          lineNumber = 0;
            while (!eof)
            {
                lineNumber++;
                SRECline line = new SRECline(sr.ReadLine(), lineNumber);
                //if (ErrorMessage == "") ErrorMessage = line.ErrorMessages;
                FileErrorMessages.AddRange(line.LineErrorMessages);
                if (line.CriticalErrors == true)
                {
                    CriticalError = true;
                }
                LinesOfFile.Add(line.crntLine);

                switch (line.recordtype)
                {
                case SRECline.RecordType.DataRecord16:
                case SRECline.RecordType.DataRecord24:
                case SRECline.RecordType.DataRecord32:
                    //data.AddRange(line.data);
                    AddressLineSorted.Add(line.address, line.data);
                    int ij = 0;
                    foreach (byte bt in line.data)
                    {
                        AddressByteSorted.Add((long)(line.address + ij), line.data[ij]);
                        Addresses.Add((long)(line.address + ij));
                        Bytes.Add(line.data[ij]);
                        if (minAddress > (long)(line.address + ij))
                        {
                            minAddress = (long)(line.address + ij);
                        }
                        if (maxAddress < (long)(line.address + ij))
                        {
                            maxAddress = (long)(line.address + ij);
                        }
                        ij++;
                    }

                    break;


                case SRECline.RecordType.CountRecord16:
                case SRECline.RecordType.CountRecord24:
                    //recordCount = line.address;

                    break;


                case SRECline.RecordType.StartAddressRecord32:
                case SRECline.RecordType.StartAddressRecord24:
                case SRECline.RecordType.StartAddressRecord16:
                    eof = true;
                    break;
                }
                if (sr.EndOfStream)
                {
                    eof = true;
                }
            }

            sr.Close();
            sr.Dispose();
        }
        catch (Exception ex)
        {
            ErrorMessage  = ex.Message;
            CriticalError = true;
        }
    }
 public NoToneRequest(byte pinToWrite)
     : base(CommandConstants.NoTone)
 {
     Bytes.Add(pinToWrite);
 }
Beispiel #21
0
    public IntelHEXfile(string filename)
    {
        if (filename.EndsWith(".hex") != true)
        {
            FileErrorMessages.Add("Файл имеет расширение отличное от hex");
        }

        try
        {
            StreamReader sr         = new StreamReader(filename);
            bool         eof        = false;
            int          lineNumber = 0;
            while (!eof)
            {
                lineNumber++;
                HEXline line = new HEXline(sr.ReadLine(), lineNumber);
                //if (ErrorMessage == "") ErrorMessage = line.ErrorMessages;
                FileErrorMessages.AddRange(line.LineErrorMessages);
                if (line.CriticalErrors == true)
                {
                    CriticalError = true;
                }

                switch (line.recordtype)
                {
                case HEXline.RecordType.DataRecord:
                    //data.AddRange(line.data);
                    int ij = 0;
                    foreach (byte bt in line.data)
                    {
                        AddressByteSorted.Add((long)(line.address + ij), line.data[ij]);
                        ij++;
                    }

                    break;

                case HEXline.RecordType.EndOfFile:
                    eof = true;
                    break;
                }
                if (sr.EndOfStream)
                {
                    eof = true;
                }
            }

            foreach (KeyValuePair <long, byte> dabs in AddressByteSorted)
            {
                Addresses.Add(dabs.Key);
                Bytes.Add(dabs.Value);
            }

            for (int i = 0; i < AddressByteSorted.Count; i++)
            {
                if (Addresses[i] < minAddress)
                {
                    minAddress = Addresses[i];
                }
            }

            for (int i = 0; i < AddressByteSorted.Count; i++)
            {
                if (Addresses[i] > maxAddress)
                {
                    maxAddress = Addresses[i];
                }
            }



            sr.Close();
            sr.Dispose();
        }
        catch (Exception ex)
        {
            ErrorMessage  = ex.Message;
            CriticalError = true;
        }
    }
 public AnalogReferenceRequest(AnalogReferenceType analogReferenceType)
     : base(CommandConstants.AnalogReference)
 {
     Bytes.Add((byte)analogReferenceType);
 }
        public override byte[] ByteOutput()
        {
            Bytes.Add(Code);

            return(Bytes.Convert());
        }
Beispiel #24
0
 public PenRequest(PenState state)
     : base(CommandConstants.Pen)
 {
     Bytes.Add((byte)state);
 }
Beispiel #25
0
    public MotorolaSRECfile_long(string filename)
    {
        if (filename.ToLower().EndsWith(".s19") | filename.ToLower().EndsWith(".srec"))
        {
        }
        else
        {
            FileErrorMessages.Add(" Файл имеет расширение отличное от .s19(.srec)");
        }
        try
        {
            StreamReader sr         = new StreamReader(filename);
            bool         eof        = false;
            int          lineNumber = 0;
            while (!eof)
            {
                lineNumber++;
                SRECline line = new SRECline(sr.ReadLine(), lineNumber);
                //if (ErrorMessage == "") ErrorMessage = line.ErrorMessages;
                FileErrorMessages.AddRange(line.LineErrorMessages);
                if (line.CriticalErrors == true)
                {
                    CriticalError = true;
                }

                switch (line.recordtype)
                {
                case SRECline.RecordType.DataRecordS19:
                case SRECline.RecordType.DataRecordSREC:
                    AddressLineSorted.Add((long)(line.address), line.data);
                    AddressLine.Add((long)(line.address), line.data);
                    int ij = 0;
                    foreach (byte bt in line.data)
                    {
                        AddressByteSorted.Add((long)(line.address + ij), line.data[ij]);
                        ij++;
                    }

                    break;

                case SRECline.RecordType.EndOfFileS19:
                case SRECline.RecordType.EndOfFileSREC:
                    eof = true;
                    break;
                }
                if (sr.EndOfStream)
                {
                    eof = true;
                }
            }
            if (AddressByteSorted.Count != 0)
            {
                foreach (KeyValuePair <long, byte> dabs in AddressByteSorted)
                {
                    Addresses.Add(dabs.Key);
                    Bytes.Add(dabs.Value);
                }

                for (int i = 0; i < AddressByteSorted.Count; i++)
                {
                    if (Addresses[i] < minAddress)
                    {
                        minAddress = Addresses[i];
                    }
                }

                for (int i = 0; i < AddressByteSorted.Count; i++)
                {
                    if (Addresses[i] > maxAddress)
                    {
                        maxAddress = Addresses[i];
                    }
                }
            }
            else
            {
                FileErrorMessages.Add(" Файл не имеет адресов.");
                minAddress = maxAddress = long.MinValue;
            }

            sr.Close();
            sr.Dispose();
        }
        catch (Exception ex)
        {
            ErrorMessage  = ex.Message;
            CriticalError = true;
        }
    }
Beispiel #26
0
 public void WriteInt8(int value)
 {
     Bytes.Add((byte)(value));
 }
 public AnalogReadRequest(byte pinToRead)
     : base(CommandConstants.AnalogRead)
 {
     Bytes.Add(pinToRead);
 }
Beispiel #28
0
 public void WriteBoolean(bool value)
 {
     Bytes.Add(value ? ((byte)1) : ((byte)0));
 }
Beispiel #29
0
 public void WriteByte(byte value)
 {
     Bytes.Add(value);
 }
Beispiel #30
0
 public void GetBytes(Bytes bytes, Vector POV = null)
 {
     bytes.Add(POV == null ? position : position - POV);
     bytes.Add(radius);
     bytes.Add(texture);
 }