Example #1
1
 public FuncDef(string zName, byte iPrefEnc, short nArg, int iArg, FUNC iflags, dxStep xStep, dxFinal xFinal)
 {
     this.nArg = nArg;
     this.iPrefEnc = iPrefEnc;
     this.flags = iflags;
     this.pUserData = iArg;
     this.pNext = null;
     this.xFunc = null;
     this.xStep = xStep;
     this.xFinalize = xFinal;
     this.zName = zName;
 }
Example #2
1
 public FuncDef(short nArg, byte iPrefEnc, FUNC iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor)
 {
     this.nArg = nArg;
     this.iPrefEnc = iPrefEnc;
     this.flags = iflags;
     this.pUserData = pUserData;
     this.pNext = pNext;
     this.xFunc = xFunc;
     this.xStep = xStep;
     this.xFinalize = xFinalize;
     this.zName = zName;
     this.pHash = pHash;
     this.pDestructor = pDestructor;
 }
Example #3
0
    public static void Main()
    {
        FUNC uni = Test.Method1;

        int ret1 = uni();

        Console.WriteLine(ret1); // 1



        FUNC multi = Test.Method1;

        multi += Test.Method2;
        multi += Test.Method3;
        multi += Test.Method4;

        int ret2 = multi();

        Console.WriteLine(ret2); // 4

        //-------------------------
        Delegate[] arr = multi.GetInvocationList();

        foreach (Delegate d in arr)
        {
            FUNC f    = (FUNC)d;
            int  ret3 = f();
            Console.WriteLine(ret3);
        }
    }
Example #4
0
        static void Main(string[] args)
        {
            CONFIG.Load();

            CARD.Open();

            int[] d = new int[5];

            d[0] = FUNC.ToInt32(0x27, 0x26, 0x13, 0x1A);
            d[1] = FUNC.ToInt32(0x04, 0x04, 0x0C, 0x00);
            d[2] = 0;
            d[3] = 0;
            d[4] = 0;

            CARD.SendCMD(1, 1, 1, 0x10, d, 100);

            Console.WriteLine("选择工作模式:1 有线 2 无线");
            int mode = -1;

            int.TryParse(Console.ReadLine(), out mode);
            switch (mode)
            {
            case 1: Test1(); break;

            case 2: Test2(); break;
            }

            CARD.Close();
        }
Example #5
0
 public void Display(int a, int x, double step, FUNC L)
 {
     for (double n = a; n < x; n += step)
     {
         Console.WriteLine($"{n,3}: {Math.Round(L(a, n),2)}");
     }
 }
Example #6
0
 static void DoThePlot(FUNC TheDelegate)
 {
     fillUp(LINE, WithChar: DOT);   // line of dots for "vertical" axis
     Console.WriteLine(LINE);
     fillUp(LINE, WithChar: BLANK); // clear the line
     PlotFunc(TheDelegate);
 }
Example #7
0
    public static void Main()
    {
        FUNC f1 = Test.Method1;
        FUNC f2 = Test.Method2;
        FUNC f3 = Test.Method3;

        // 1. Delegate.Combine()
        //FUNC f4 = (FUNC)Delegate.Combine(f1, f2);
        //FUNC f4 = (FUNC)Delegate.Combine(f1, f2, f3);
        //FUNC f4 = (FUNC)Delegate.Combine(f1, Test.Method4);
        //f4();

        // 2. +, -, += , -=
        //FUNC f5 = f1 + f2 + f3;
        //FUNC f5 = f1 + Test.Method4 + f2;
        //f5();

        // 3. delegate 는 reference type
        FUNC f6 = Test.Method1;
        FUNC f7 = f6;

        Console.WriteLine(f6 == f7); // true

        f6 += Test.Method2;          // f6 = f6 + Test.Method2;
                                     // f6 = new FUNC(  ... )
        Console.WriteLine(f6 == f7); // false


        f6(); // 2개 호출
        Console.WriteLine("----");
        f7(); // 1개
    }
Example #8
0
        private void button1_Click(object sender, EventArgs ev)
        {
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            s.Connect("192.168.16.170", 10000);

            byte[] buf;

            buf = new byte[] { 0x00, 0x06, 0x10, 0x12, 0x00, 0x00 };

            s.Send(buf);

            byte[] rec = new byte[128];
            int    r   = 0;

            s.ReceiveTimeout = 1000;

            try
            {
                r = s.Receive(rec);
                Debug.WriteLine(FUNC.BytesToString(rec, 0, r));

                r = s.Receive(rec);
                Debug.WriteLine(FUNC.BytesToString(rec, 0, r));
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            s.Disconnect(false);
        }
Example #9
0
        public ActionResult Edit(vFUNC_Manage VFM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Fun";
            SL.Action        = "Edit";
            SL.TotalCount    = 1;
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            try
            {
                FUNC F = context.FUNCS.Find(VFM.SN);
                F.FuncName      = VFM.FuncName;
                F.Controller    = VFM.Controller;
                F.Action        = VFM.Action;
                F.Url           = VFM.Url;
                F.PId           = VFM.PId;
                F.ShowOrder     = VFM.ShowOrder;
                F.IsEnable      = VFM.IsEnable;
                F.UpadteAccount = Session["UserID"].ToString().Trim();
                F.UpdateTime    = DateTime.Now;

                context.Entry(F).State = EntityState.Modified;
                context.SaveChanges();

                SL.EndDateTime  = DateTime.Now;
                SL.SuccessCount = 1;
                SL.FailCount    = 0;
                SL.Result       = true;
                SL.Msg          = "編輯功能作業成功,FId:[" + VFM.FId.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return(RedirectToAction("Index", "Fun"));
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 1;
                SL.SuccessCount = 0;
                SL.FailCount    = 1;
                SL.Result       = false;
                SL.Msg          = "編輯功能作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["EditMsg"] = "<script>alert('發生異常');</script>";

                return(RedirectToAction("Edit", "Fun", new { SN = VFM.SN }));
            }
        }
Example #10
0
 //NETLIB_CONSTRUCTOR_EX(analog_callback, nl_fptype threshold, FUNC &&func)
 public nld_analog_callback(object owner, string name, nl_fptype threshold, FUNC func)
     : base(owner, name)
 {
     m_in        = new analog_input_t(this, "IN", in_);
     m_threshold = threshold;
     m_last      = new state_var <nl_fptype>(this, "m_last", 0);
     m_func      = func;
 }
Example #11
0
 private void Countdown()
 {
     timer -= Time.deltaTime;
     if (timer <= 0f)
     {
         step = StartExplode;
     }
 }
Example #12
0
 public void StartExplode()
 {
     gs.SendGrenadeExplode(grenadeNum, base.transform.position, throwerID);
     base.gameObject.GetComponent <Rigidbody>().isKinematic = true;
     step  = Explode;
     timer = 2f;
     Logger.trace("start explode");
 }
Example #13
0
        // GET: Fun/Edit
        public ActionResult Edit(int SN)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Fun";
            SL.Action        = "Edit";
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            try
            {
                vFUNC_Manage VFM = new vFUNC_Manage();
                FUNC         F   = context.FUNCS.Find(SN);

                VFM.SN         = F.SN;
                VFM.FId        = F.FId;
                VFM.FuncName   = F.FuncName;
                VFM.PId        = F.PId;
                VFM.Controller = F.Controller;
                VFM.Action     = F.Action;
                VFM.Url        = F.Url;
                VFM.ShowOrder  = F.ShowOrder;
                VFM.IsEnable   = F.IsEnable;

                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 1;
                SL.SuccessCount = 1;
                SL.FailCount    = 0;
                SL.Result       = true;
                SL.Msg          = "取得功能資料作業成功,FId:[" + F.FId.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return(View(VFM));
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 0;
                SL.SuccessCount = 0;
                SL.FailCount    = 0;
                SL.Result       = false;
                SL.Msg          = "取得功能資料作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return(RedirectToAction("Index", "Fun"));
            }
        }
Example #14
0
    public static void Main()
    {
        FUNC f1 = new FUNC(foo); // 정확한 표기법

        f1.Invoke(10);           //


        FUNC f2 = foo;

        f2(10); // f2.Invoke(10)
    }
Example #15
0
    static void Main()
    {
        int    n = 10;
        double d = 3.4;
        string s = "hello";

        FUNC f = foo;

        f(10);        // foo(10)
        f.Invoke(10); // foo(10)
    }
Example #16
0
    public static void Main()
    {
        //FUNC f = Add;

        FUNC f = delegate(int a, int b) { return(a + b); };

        Console.WriteLine(f(1, 2));

        Foo(Add);
        Foo(delegate(int a, int b) { return(a - b); });
    }
Example #17
0
 public FuncDef(string zName, byte iPrefEnc, short nArg, object arg, dxFunc xFunc, FUNC flags)
 {
     this.nArg      = nArg;
     this.iPrefEnc  = iPrefEnc;
     this.flags     = flags;
     this.pUserData = arg;
     this.pNext     = null;
     this.xFunc     = xFunc;
     this.xStep     = null;
     this.xFinalize = null;
     this.zName     = zName;
 }
Example #18
0
 protected void Files_OnSelected(object sender, ObjectDataSourceStatusEventArgs e)
 {
     if (null == e.Exception && null != e.ReturnValue)
     {
         Type type = e.ReturnValue.GetType();
         if (type == typeof(FUNC))
         {
             FUNC tbl = (FUNC)e.ReturnValue;
             Count.Text = "" + tbl.SelectCount("*");
         }
     }
 }
Example #19
0
 public FuncDef(string zName, byte iPrefEnc, short nArg, int iArg, FUNC iflags, dxFunc xFunc)
 {
     this.nArg      = nArg;
     this.iPrefEnc  = iPrefEnc;
     this.flags     = iflags;
     this.pUserData = iArg;
     this.pNext     = null;
     this.xFunc     = xFunc;
     this.xStep     = null;
     this.xFinalize = null;
     this.zName     = zName;
 }
Example #20
0
        static void ExcuteCmd(byte addr, byte cmd)
        {
            byte[] buf = new byte[15];

            buf[0] = Convert.ToByte('w');
            buf[1] = Convert.ToByte('a');
            buf[2] = Convert.ToByte('t');
            buf[3] = addr;

            for (int i = 4; i < 14; i++)
            {
                //buf[i] = (byte)FUNC.Random.Next(256);
                buf[i] = 0;
            }



            if (!list.Keys.Contains(addr))
            {
                CardData d = new CardData();
                Random   r = new Random();
                d.a    = (Int16)r.Next(1000);
                d.b    = (Int16)r.Next(2000);
                d.last = DateTime.Now;

                list.Add(addr, d);
            }


            TimeSpan t = new TimeSpan(DateTime.Now.Ticks - list[addr].last.Ticks);

            if (t.TotalSeconds >= 3)
            {
                list[addr].a++;
                list[addr].b++;
                list[addr].last = DateTime.Now;
            }


            buf[4]  = addr;
            buf[7]  = (byte)((cmd == 0x10)? 1 : 0);
            buf[10] = (byte)(list[addr].a / 256);
            buf[11] = (byte)(list[addr].a % 256);
            buf[12] = (byte)(list[addr].b / 256);
            buf[13] = (byte)(list[addr].b % 256);
            buf[14] = FUNC.CRC8(buf, 0, 14);

            //com.Write(buf, 3, 2);
            com.Write(buf, 0, 15);
            WriteLine("send: " + FUNC.BytesToString(buf, 0, 15));
            WriteLine("");
        }
        public static double GaussCheb(List <double> nods, int n, FUNCf fx, FUNC f)//
        {
            double suma = 0.0;

            for (int i = 0; i < nods.Count; i++)
            {
                suma += fx(nods.ElementAt(i), f);
                //if(i>0)
                //Console.WriteLine("Wynik dla " + (i + 1) + " węzłów: " + absolute(suma));
            }
            suma = 2.0 / nods.Count * suma;
            return(suma);
        }
        public static List <double> lambdaK_n(int n, List <double> nods, FUNC f)
        {
            List <double> lst = new List <double>();

            lst.Add(GaussCheb(nods, n, czebPolFx0, f) / Math.PI);
            lst.Add(GaussCheb(nods, n, czebPolFx1, f) / (Math.PI / 2.0));
            lst.Add(GaussCheb(nods, n, czebPolFx2, f) / (Math.PI / 2.0));
            lst.Add(GaussCheb(nods, n, czebPolFx3, f) / (Math.PI / 2.0));
            lst.Add(GaussCheb(nods, n, czebPolFx4, f) / (Math.PI / 2.0));


            return(lst);
        }
Example #23
0
 public FuncDef(short nArg, byte iPrefEnc, FUNC iflags, object pUserData, FuncDef pNext, dxFunc xFunc, dxStep xStep, dxFinal xFinalize, string zName, FuncDef pHash, FuncDestructor pDestructor)
 {
     this.nArg        = nArg;
     this.iPrefEnc    = iPrefEnc;
     this.flags       = iflags;
     this.pUserData   = pUserData;
     this.pNext       = pNext;
     this.xFunc       = xFunc;
     this.xStep       = xStep;
     this.xFinalize   = xFinalize;
     this.zName       = zName;
     this.pHash       = pHash;
     this.pDestructor = pDestructor;
 }
Example #24
0
    public static void Main()
    {
        FUNC f1 = Test.static_method;
        //FUNC f2 = Program.static_method;
        FUNC f2 = static_method;

        Test t  = new Test();
        FUNC f3 = t.instance_method;

        Program p  = new Program();
        FUNC    f4 = p.instance_method;

        p.foo();
    }
Example #25
0
 private void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.tag != "Player" && other.gameObject.tag != "pickup")
     {
         base.gameObject.GetComponent <AudioSource>().volume = GameData.mGameSettings.mSoundVolume;
         base.gameObject.GetComponent <AudioSource>().Play();
     }
     else if (!other.gameObject.name.Contains("Collision"))
     {
         step = StartExplode;
         Logger.trace("i should damage " + other.gameObject.name);
         Logger.trace("<< colliding with: " + other.gameObject.name);
     }
 }
Example #26
0
        public void SaveFunc(string FileName, double a, double b, double h, FUNC A)
        {
            FileStream   fs = new FileStream(FileName, FileMode.Create, FileAccess.Write);
            BinaryWriter bw = new BinaryWriter(fs);
            double       x  = a;

            while (x <= b)
            {
                bw.Write(A(x));
                x += h;
            }

            bw.Close();
            fs.Close();
        }
Example #27
0
        static void Main(string[] args)
        {
            String port = "COM9";

            if (args.Length > 0)
            {
                port = args[0];
            }

            if (args.Length > 1)
            {
                Process.Start(args[1]);
            }

            try
            {
                com = new SerialPort(port, 57600, Parity.None, 8, StopBits.One);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadKey(false);
                return;
            }

            com.Open();
            while (true)
            {
                byte[] buf = new byte[10];
                com.ReadTimeout = Timeout.Infinite;
                int n = com.Read(buf, 0, 10);
                //FUNC.Sleep(1000);
                //int n = 10;
                Write("recv: " + FUNC.BytesToString(buf, 0, n));

                byte c = FUNC.CRC8(buf, 0, n - 1);
                if ((n == 10) && (c == buf[9]))
                {
                    WriteLine(" [OK]");
                    ExcuteCmd(buf[3], buf[4]);
                }
                else
                {
                    WriteLine(" [Failed]");
                }
                FUNC.Sleep(30);
            }
        }
Example #28
0
        static void PlotFunc(FUNC f)
        {
            double maxval = 9.0; //arbitrary values
            double delta  = 0.2; //size of iteration steps
            int    loc;

            LINE[cHalf] = DOT;                              // for "horizontal" axis
            for (double x = 0.0001; x < maxval; x += delta) //0.0001 to avoid DIV/0 error
            {
                loc       = (int)Math.Round(f(x) * cHalf) + cHalf;
                LINE[loc] = X;
                Console.WriteLine(LINE);
                fillUp(LINE, WithChar: BLANK); // blank the line, remove X point
                LINE[cHalf] = DOT;             // for horizontal axis
            }
        }
Example #29
0
        private double MetodaTrapezow(FUNC f, double xp, double xk, int n)
        {
            double dx, calka;

            dx = (xk - xp) / n;

            calka = 0;
            for (int i = 1; i < n; i++)
            {
                calka += f(xp + i * dx);
            }
            calka += (f(xp) + f(xk)) / 2;
            calka *= dx;

            return(calka);
        }
Example #30
0
        private double MetodaProstokatow(FUNC f, double xp, double xk, int n)
        {
            double dx, calka;

            dx = (xk - xp) / n;

            calka = 0;
            for (int i = 1; i <= n; i++)
            {
                System.Console.WriteLine(calka);
                calka += f(xp + i * dx);
            }
            calka *= dx;

            return(calka);
        }
Example #31
0
        //пилим котлин метод
        //fun hello(name: String = "world"): String {}
        void T_FUNC_Kotlin(BLOCK_CS P_BL)//-> fun
        {
            var  func_name = SET_KWq();
            FUNC F         = CREATE_Func(P_BL, func_name);

            INK();
            T_PAR_KOTLIN(F);
            if (NOT(":"))
            {
                ADD_ERR();
            }
            SET_END_ROW_EXTAN(GetChep, EXTAN.TYPE_ONLY);
            INK();
            F.TYPE_W5 = T_W5();
            TAKE_FUNC_BODY(F);
        }
Example #32
0
 protected void UploadButton_Click(object sender, EventArgs e)
 {
     if (FileUploadControl.HasFile)
     {
         try
         {
             FUNC   tbl      = new FUNC();
             string filename = Path.GetFileName(FileUploadControl.FileName);
             string fullpath = Config.GetTempPath + filename;
             FileUploadControl.SaveAs(fullpath);
             //StatusLabel.Text = "Upload status: File uploaded!";
             tbl.update_func_mappings(Master.CurrentUserName, fullpath);
         }
         catch (Exception ex)
         {
             //StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
             throw ex;
         }
     }
 }
Example #33
0
 public FuncDef(string zName, byte iPrefEnc, short nArg, object arg, dxFunc xFunc, FUNC flags)
 {
     this.nArg = nArg;
     this.iPrefEnc = iPrefEnc;
     this.flags = flags;
     this.pUserData = arg;
     this.pNext = null;
     this.xFunc = xFunc;
     this.xStep = null;
     this.xFinalize = null;
     this.zName = zName;
 }
Example #34
0
 private string Test1(FUNC f)
 {
     MessageBox.Show(f());
     return "";
 }