예제 #1
0
파일: Program.cs 프로젝트: cubean/CG
        static void asm(string[] args)
        {
            string f = null, o = null;
            bool d = false;
            string port = "COM6", baud="9600";
            char parity='E';
            int address=2;

            var p = new OptionSet() {
               	                        { "f|file=",  v => f = v },
               	                        { "o|output=",  v => o = v },
               	                        { "c|comport=",  v => port = v },
               	                        { "b|baud=",  v => baud = v },
               	                        { "p|parity=",  v => parity = v[0] },
               	                        { "a|address=",  v => address = int.Parse(v) },
               	                        { "d|download",  v => d = (v != null) },
                        };
            List<string> extra = p.Parse(args);
            if (f == null)
                UsageAndExit();

            using (TextReader streamReader =
                new StreamReader(f))
            {
                var source = streamReader.ReadToEnd();

                byte[] dest = null;
                var compiler = new Compiler();
                compiler.AssemblyBlock(
                    eBLOCK200_BLOCKTYPES.eBLOCK200_BLOCKTYPE_OB,
                    1,
                    STLCompiler.eBLOCK200_OB_VERSIONS.eBLOCK200_OB_VERSION_2ND_GEN_6,
                    false,
                    true,
                    true,
                    source,
                    out dest);

                if (o != null)
                {
                    using (BinaryWriter binWriter = new BinaryWriter(
                        File.Open(o, FileMode.Create)))
                    {
                        binWriter.Write(dest);
                    }
                }

                if (d)
                    DownloadProgramBlock(port, baud, parity, address, dest);
            }
        }
예제 #2
0
파일: FXService.cs 프로젝트: cubean/CG
        public bool Complie(string sourceCode, out byte[] block)
        {
            block = null;
            try
            {
                var compiler = new Compiler();
                compiler.AssemblyBlock(
                    eBLOCK200_BLOCKTYPES.eBLOCK200_BLOCKTYPE_OB,
                    1,
                    STLCompiler.eBLOCK200_OB_VERSIONS.eBLOCK200_OB_VERSION_2ND_GEN_6,
                    false,
                    true,
                    true,
                    sourceCode,
                    out block);
            }
            catch (System.Exception )
            {
                return false;
            }

            return true;
        }