Beispiel #1
0
        public void TestMethod30()
        {
            // testing jmp_link and ret

            RegisterFile <Vector4> vRF = new RegisterFile <Vector4>(32);
            RegisterFile <Scalar>  sRF = new RegisterFile <Scalar>(33);
            Memory           m         = new Memory(5000);
            Memory           m_ic      = new Memory(5000);
            IntersectionCore ic        = new IntersectionCore(m_ic);



            jmp_link j = new jmp_link(10);

            sRF[31] = 1;

            j.Process(vRF, sRF, m, ic);
            Assert.AreEqual <int>(1, sRF[30].i);
            Assert.AreEqual <int>(11, sRF[31].i);

            ret r = new ret();

            r.Process(vRF, sRF, m, ic);
            Assert.AreEqual <int>(1, sRF[31]);
        }
Beispiel #2
0
        public HttpResponseMessage GetDataStandard(dynamic obj)
        {
            string result = string.Empty;

            try
            {
                string    sql = "select * from [tblEQIW_R_DevelopmentPace] where 上报时间=(select max(上报时间) from [tblEQIW_R_DevelopmentPace]) ";
                DataTable dt  = new DataTable();
                dt = rule.getdt(sql);
                int count = 0;
                if (obj.isall == "0")
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        bool all = true;
                        for (int j = 0; j < dt.Columns.Count; j++)
                        {
                            if (dt.Rows[i][j].ToString() == "否")
                            {
                                all = false;
                            }
                        }
                        if (all == false)
                        {
                            count++;
                        }
                    }
                }

                ret zz = new ret();
                zz.AllStande = ((float.Parse((dt.Rows.Count - count).ToString()) / float.Parse(dt.Rows.Count.ToString())) * 100).ToString();
                string named = obj.name + "_是否完成";
                var    pt    = (from x in dt.AsEnumerable()
                                where x[named].ToString() == "是"
                                select x);
                float prt      = pt.Count();
                float allcount = prt / float.Parse(dt.Rows.Count.ToString());
                zz.PartStande = ((prt / dt.Rows.Count) * 100).ToString();

                result = rule.JsonStr("ok", "达标率", zz);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }
            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Beispiel #3
0
        public void TestMethod33()
        {
            // ToString test
            and and = new and(1, 2, 3);

            Assert.AreEqual("and r1 r2 r3", and.ToString());
            bne bne = new bne(1);

            Assert.AreEqual("bne 1", bne.ToString());
            bg bg = new bg(1);

            Assert.AreEqual("bg 1", bg.ToString());
            bl bl = new bl(1);

            Assert.AreEqual("bl 1", bl.ToString());
            bge_rt bge_rt = new bge_rt(1);

            Assert.AreEqual("bge_rt 1", bge_rt.ToString());
            ble_rt ble_rt = new ble_rt(1);

            Assert.AreEqual("ble_rt 1", ble_rt.ToString());
            cmp_i cmpi = new cmp_i(1, 2);

            Assert.AreEqual("cmp_i r1 r2", cmpi.ToString());
            cmp_f cmpf = new cmp_f(1, 2);

            Assert.AreEqual("cmp_f r1 r2", cmpf.ToString());
            cmp_v cmpv = new cmp_v(1, 2);

            Assert.AreEqual("cmp_v r1 r2", cmpv.ToString());
            ff_add ff_add = new ff_add(1, 2, 3);

            Assert.AreEqual("ff_add r1 r2 r3", ff_add.ToString());
            ff_sub ff_sub = new ff_sub(1, 2, 3);

            Assert.AreEqual("ff_sub r1 r2 r3", ff_sub.ToString());
            ff_mul ff_mul = new ff_mul(1, 2, 3);

            Assert.AreEqual("ff_mul r1 r2 r3", ff_mul.ToString());
            ff_div ff_div = new ff_div(1, 2, 3);

            Assert.AreEqual("ff_div r1 r2 r3", ff_div.ToString());
            fin fin = new fin();

            Assert.AreEqual("fin", fin.ToString());
            ftoi ftoi = new ftoi(1, 2);

            Assert.AreEqual("ftoi r1 r2", ftoi.ToString());
            ii_add ii_add = new ii_add(1, 2, 3);

            Assert.AreEqual("ii_add r1 r2 r3", ii_add.ToString());
            ii_addi ii_addi = new ii_addi(1, 2, 3);

            Assert.AreEqual("ii_addi r1 r2 3", ii_addi.ToString());
            ii_sub ii_sub = new ii_sub(1, 2, 3);

            Assert.AreEqual("ii_sub r1 r2 r3", ii_sub.ToString());
            ii_subi ii_subi = new ii_subi(1, 2, 3);

            Assert.AreEqual("ii_subi r1 r2 3", ii_subi.ToString());
            ii_mul ii_mul = new ii_mul(1, 2, 3);

            Assert.AreEqual("ii_mul r1 r2 r3", ii_mul.ToString());
            ii_muli ii_muli = new ii_muli(1, 2, 3);

            Assert.AreEqual("ii_muli r1 r2 3", ii_muli.ToString());
            ii_div ii_div = new ii_div(1, 2, 3);

            Assert.AreEqual("ii_div r1 r2 r3", ii_div.ToString());
            ii_divi ii_divi = new ii_divi(1, 2, 3);

            Assert.AreEqual("ii_divi r1 r2 3", ii_divi.ToString());
            itof itof = new itof(1, 2);

            Assert.AreEqual("itof r1 r2", itof.ToString());
            real_jmp real_jmp = new real_jmp(1);

            Assert.AreEqual("real_jmp 1", real_jmp.ToString());
            jmp_link jmp_link = new jmp_link(1);

            Assert.AreEqual("jmp_link 1", jmp_link.ToString());
            not not = new not(1, 2);

            Assert.AreEqual("not r1 r2", not.ToString());
            or or = new or(1, 2, 3);

            Assert.AreEqual("or r1 r2 r3", or.ToString());
            ret ret = new ret();

            Assert.AreEqual("ret", ret.ToString());
            s_get_from_v sgfv = new s_get_from_v(1, 2, 3);

            Assert.AreEqual("s_get_from_v r1 r2 3", sgfv.ToString());
            s_load_4byte sl4b = new s_load_4byte(1, 2, 3);

            Assert.AreEqual("s_load_4byte r1 r2 3", sl4b.ToString());
            s_store_4byte ss4b = new s_store_4byte(1, 2, 3);

            Assert.AreEqual("s_store_4byte r1 r2 3", ss4b.ToString());
            s_write_high swh = new s_write_high(1, 5);

            Assert.AreEqual("s_write_high r1 5", swh.ToString());
            s_write_low swl = new s_write_low(1, 5);

            Assert.AreEqual("s_write_low r1 5", swl.ToString());
            s_push s_push = new s_push(1);

            Assert.AreEqual("s_push r1", s_push.ToString());
            s_pop s_pop = new s_pop(1);

            Assert.AreEqual("s_pop r1", s_pop.ToString());
            v_push v_push = new v_push(1);

            Assert.AreEqual("v_push r1", v_push.ToString());
            v_pop v_pop = new v_pop(1);

            Assert.AreEqual("v_pop r1", v_pop.ToString());
            v_get_from_s vgfs = new v_get_from_s(1, 2, 3);

            Assert.AreEqual("v_get_from_s r1 r2 3", vgfs.ToString());
            v_load_16byte vl16 = new v_load_16byte(1, 2, 3);

            Assert.AreEqual("v_load_16byte r1 r2 3", vl16.ToString());
            v_magn v_magn = new v_magn(1, 2);

            Assert.AreEqual("v_magn r1 r2", v_magn.ToString());
            v_store_16byte vs16 = new v_store_16byte(1, 2, 3);

            Assert.AreEqual("v_store_16byte r1 r2 3", vs16.ToString());
            vf_add vf_add = new vf_add(1, 2, 3);

            Assert.AreEqual("vf_add r1 r2 r3", vf_add.ToString());
            vf_sub vf_sub = new vf_sub(1, 2, 3);

            Assert.AreEqual("vf_sub r1 r2 r3", vf_sub.ToString());
            vf_mul vf_mul = new vf_mul(1, 2, 3);

            Assert.AreEqual("vf_mul r1 r2 r3", vf_mul.ToString());
            vf_div vf_div = new vf_div(1, 2, 3);

            Assert.AreEqual("vf_div r1 r2 r3", vf_div.ToString());
            vi_add vi_add = new vi_add(1, 2, 3);

            Assert.AreEqual("vi_add r1 r2 r3", vi_add.ToString());
            vi_sub vi_sub = new vi_sub(1, 2, 3);

            Assert.AreEqual("vi_sub r1 r2 r3", vi_sub.ToString());
            vi_mul vi_mul = new vi_mul(1, 2, 3);

            Assert.AreEqual("vi_mul r1 r2 r3", vi_mul.ToString());
            vi_div vi_div = new vi_div(1, 2, 3);

            Assert.AreEqual("vi_div r1 r2 r3", vi_div.ToString());
            vv_add vv_add = new vv_add(1, 2, 3);

            Assert.AreEqual("vv_add r1 r2 r3", vv_add.ToString());
            vv_sub vv_sub = new vv_sub(1, 2, 3);

            Assert.AreEqual("vv_sub r1 r2 r3", vv_sub.ToString());
            vv_mul_ele vv_mul_ele = new vv_mul_ele(1, 2, 3);

            Assert.AreEqual("vv_mul_ele r1 r2 r3", vv_mul_ele.ToString());
            vv_mul_dot vv_mul_dot = new vv_mul_dot(1, 2, 3);

            Assert.AreEqual("vv_mul_dot r1 r2 r3", vv_mul_dot.ToString());
            vv_div vv_div = new vv_div(1, 2, 3);

            Assert.AreEqual("vv_div r1 r2 r3", vv_div.ToString());
            xor xor = new xor(1, 2, 3);

            Assert.AreEqual("xor r1 r2 r3", xor.ToString());
        }
Beispiel #4
0
        private void OnTimer(object sender, System.Timers.ElapsedEventArgs args)
        {
            EventLog.WriteEntry("FastIR Agent: check for order...", EventLogEntryType.Information);
            //Get keys
            P.URL    = ReadKey("URL");
            P.Port   = ReadKey("Port");
            P.APIKey = ReadKey("APIKey");
            P.lpk    = ReadKey("PUBLIC_SSL");
            string exe = Process.GetCurrentProcess().MainModule.FileName;

            P.ApplicationPath = Path.GetDirectoryName(exe);
            //
            if (P.Port.Equals(null) || P.URL.Equals(null) || P.lpk.Equals(null) || P.APIKey.Equals(null))
            {
                EventLog.WriteEntry("FastIR Agent: Bad URL, Port, or SSL Public key in the configuration...", EventLogEntryType.Error);
                ServiceController sc = new ServiceController("FastIR");
                sc.Stop();
                sc.Close();
            }
            else
            {
                EventLog.WriteEntry("FastIR Agent: URL: " + P.URL + ":" + P.Port + ".", EventLogEntryType.Information);
                NetworkFastIR prop = new NetworkFastIR(P.URL, P.Port, P.lpk);
                ret           r    = prop.query("");
                if (r.SSL_status)
                {
                    ReturnJson rj;
                    try
                    {
                        rj = JsonConvert.DeserializeObject <ReturnJson>(r.Web_return);
                        EventLog.WriteEntry("FastIR Agent: Connection established to the server", EventLogEntryType.Information);
                        //Get new FastIR binary
                        string arch = null;
                        if (Environment.Is64BitOperatingSystem)
                        {
                            arch = "x64";
                        }
                        else
                        {
                            arch = "x86";
                        }
                        string sha256 = "";
                        try
                        {
                            sha256 = GetSHA256(P.ApplicationPath + "\\FastIR.exe");
                        }
                        catch { }
                        string POST = "APIKey=" + P.APIKey + "&sha256=" + sha256 + "&arch=" + arch;
                        r = prop.query("getbinary/", POST);
                        if (r.SSL_status)
                        {
                            try
                            {
                                rj = JsonConvert.DeserializeObject <ReturnJson>(r.Web_return);
                            }
                            catch { rj = null; }

                            if (rj.Equals(null))
                            {
                                EventLog.WriteEntry("FastIR Agent: bad json from the server", EventLogEntryType.Error);
                            }
                            else if (rj.Return.Equals("KO"))
                            {
                                EventLog.WriteEntry("FastIR Agent: bad request: " + rj.Data, EventLogEntryType.Error);
                            }
                            else
                            {
                                if (rj.Binary.Equals("1"))
                                {
                                    EventLog.WriteEntry("FastIR Agent: new FastIR binary available", EventLogEntryType.Information);
                                    try
                                    {
                                        byte[] data = Convert.FromBase64String(rj.Data);
                                        File.WriteAllBytes(P.ApplicationPath + "\\FastIR.exe", data);
                                    }
                                    catch { EventLog.WriteEntry("FastIR Agent: cannot download the new FastIR binary", EventLogEntryType.Error); }
                                }
                                else
                                {
                                    EventLog.WriteEntry("FastIR Agent: no new FastIR binary", EventLogEntryType.Information);
                                }
                            }
                        }
                        else
                        {
                            EventLog.WriteEntry("FastIR Agent: Bad SSL or URL", EventLogEntryType.Error);
                        }

                        //Get Order
                        POST = "APIKey=" + P.APIKey + "&hostname=" + Dns.GetHostName();
                        r    = prop.query("getorder/", POST);
                        if (r.SSL_status)
                        {
                            try
                            {
                                rj = JsonConvert.DeserializeObject <ReturnJson>(r.Web_return);
                            }
                            catch { rj = null; }

                            if (rj.Equals(null))
                            {
                                EventLog.WriteEntry("FastIR Agent: bad json from the server", EventLogEntryType.Error);
                            }
                            else if (rj.Return.Equals("KO"))
                            {
                                EventLog.WriteEntry("FastIR Agent: bad request: " + rj.Data, EventLogEntryType.Error);
                            }
                            else
                            {
                                if (rj.Order.Equals("1"))
                                {
                                    EventLog.WriteEntry("FastIR Agent: an order exist for the machine: " + Dns.GetHostName(), EventLogEntryType.Information);
                                    try
                                    {
                                        PECheck pe   = new PECheck();
                                        byte[]  data = Convert.FromBase64String(rj.Data);
                                        File.WriteAllBytes(P.ApplicationPath + "\\FastIR.conf", data);
                                        EventLog.WriteEntry("FastIR Agent: the new config file is created.", EventLogEntryType.Information);
                                        if (pe.checkfile(P.ApplicationPath + "\\FastIR.exe"))
                                        {
                                            using (Process process = new Process())
                                            {
                                                EventLog.WriteEntry("FastIR Agent: execution of the collect.", EventLogEntryType.Information);
                                                process.StartInfo.FileName    = P.ApplicationPath + "\\FastIR.exe";
                                                process.StartInfo.Arguments   = "--profile " + P.ApplicationPath + "\\FastIR.conf";
                                                process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                                                process.Start();
                                            }
                                        }
                                        else
                                        {
                                            EventLog.WriteEntry("FastIR Agent: bad signature.", EventLogEntryType.Error);
                                        }
                                    }
                                    catch { EventLog.WriteEntry("FastIR Agent: cannot download the config file", EventLogEntryType.Error); }
                                }
                                else
                                {
                                    EventLog.WriteEntry("FastIR Agent: no order for the machine: " + Dns.GetHostName(), EventLogEntryType.Information);
                                }
                            }
                        }
                        else
                        {
                            EventLog.WriteEntry("FastIR Agent: Bad SSL or URL", EventLogEntryType.Error);
                        }
                    }
                    catch { EventLog.WriteEntry("FastIR Agent: bad json from the server", EventLogEntryType.Error); }
                }
                else
                {
                    EventLog.WriteEntry("FastIR Agent: Bad SSL or URL", EventLogEntryType.Error);
                }
            }
        }
 var(ret, pathSpans1) = writers[rendererArg.ResolveRendererKey()].Invoke(o, language, true);
Beispiel #6
0
 ret.Body = f(ret, args...);
Beispiel #7
0
		ret.Body = f(ret, args...);