Пример #1
0
        public ICustomData <double, double> AddCustom(string name, Func <double, double> algo)
        {
            var newRefSeries = new CUSTOM(name, algo);
            var result       = DataSeriesManager.CreateCustom(HistoryDataSeries, newRefSeries);

            return(result);
        }
        public override void Init()
        {
            C = CreateSimpleCustomSeries("C");

            L = CreateSimpleCustomSeries("L");

            H = CreateSimpleCustomSeries("H");
        }
        public override void Init()
        {
            // native TE build-in indicator Momentum;
            momentum = IndicatorsManager.BuildIn.Momentum(HistoryDataSeries, momPeriod);

            // custom wrapper for build-in indicator Momentum;
            MTST_momentum = AddCustom("MTST_momentum", (value) => {
                return(value);
            }) as CUSTOM;
        }
        public override void Init()
        {
            b1 = AddCustom("b1", (value) => {
                return(value <PREV["a1"] ? a2 : a2> PREV["a1"] ? a2 : PREV["a1"]);
            }) as CUSTOM;

            b2 = AddCustom("b2", (value) => {
                return(value > PREV["a1"] ? a3 : a3 < PREV["a1"] ? a3 : PREV["a1"]);
            }) as CUSTOM;
        }
Пример #5
0
        /// <summary>
        /// ตรวจสอบกระดาษ - Custom Thermal Printer
        /// </summary>
        /// <param name="model">Printer Model</param>
        /// <param name="vid">VID value</param>
        /// <param name="pid">PID value</param>
        /// <returns>สถานะกระกาษและปริ๊นเตอร์ในรูปแบบ array.
        /// กรณีปกติ จะได้ ok
        /// กรณีผิดปกติ จะเป็นข้อความอื่นๆ
        /// กรณีตรวจสอบไม่ได้ จะไม่มีข้อความใดๆ</returns>
        public string[] CheckPaperStatus(string model, string vid, string pid)
        {
            try
            {
                string deviceID = string.Format("VID_{0}&PID_{1}", vid, pid);
                CUSTOM printer  = new CUSTOM(model, "", deviceID);
                int[]  arrRet   = printer.CheckPaperStatus();

                List <string> paperStatus = new List <string>();

                if (arrRet != null)
                {
                    if (arrRet.Length >= 1 && arrRet[0] > 0)
                    {
                        paperStatus.Add("low_paper");
                    }

                    if (arrRet.Length >= 2 && arrRet[1] > 0)
                    {
                        paperStatus.Add("end_paper");
                    }

                    if (arrRet.Length >= 3 && arrRet[2] > 0)
                    {
                        paperStatus.Add("paper_jam");
                    }

                    if (arrRet.Length >= 4 && arrRet[3] > 0)
                    {
                        paperStatus.Add("ticket_not_present");
                    }

                    if (arrRet.Length >= 5 && arrRet[4] > 0)
                    {
                        paperStatus.Add("cuter_error");
                    }

                    if (paperStatus.Count == 0)
                    {
                        paperStatus.Add("ok");
                    }
                }

                return(paperStatus.ToArray());
            }
            catch (Exception ex)
            {
                throw new Exception("Custom - CheckPaperStatus failed. " + ex.Message, ex);
            }
            finally
            {
                USBFilter.ReinstallUSBFilter();
            }
        }
Пример #6
0
        //Method that takes the tuples from the inqueue and processes them.
        public void process_inQueue()
        {
            FILTER filter = new FILTER();
            CUSTOM custom = new CUSTOM();
            UNIQ   uniq   = new UNIQ();
            DUP    dup    = new DUP();
            COUNT  count  = new COUNT();

            while (true)
            {
                Monitor.Enter(tLock);
                try
                {
                    if (in_queue.Count > 0)
                    {
                        string[] words = op_spec.Split(',');

                        remoting_interfaces.Tuple outTuple;

                        if (in_queue[0].getID() != 0)
                        {
                            Console.WriteLine("   ");
                            Console.WriteLine("ID: " + in_queue[0].getID());
                            Console.WriteLine("User: "******"URL: " + in_queue[0].getURL());
                        }

                        if (words[0] == "FILTER")
                        {
                            //get the tuple after computation of Filter
                            outTuple = filter.doTweeters(in_queue[0], Int32.Parse(words[1]), words[2], words[3]);
                            out_queue.Add(outTuple);
                            in_queue.Remove(in_queue[0]);
                            Console.WriteLine("Output from Operator:");
                            Console.WriteLine(outTuple.getID());
                            Console.WriteLine(outTuple.getUser());
                            Console.WriteLine(outTuple.getURL());
                        }
                        if (words[0] == "CUSTOM")
                        {
                            List <string> Followers = new List <string>();

                            //get the list of followers
                            Followers = custom.getoutput(words[1], words[3], in_queue[0]);
                            foreach (string follower in Followers)
                            {
                                Console.WriteLine("follower: " + follower);
                                remoting_interfaces.Tuple Tuple = new remoting_interfaces.Tuple(0, follower, "");
                                out_queue.Add(Tuple);
                            }

                            in_queue.Remove(in_queue[0]);
                        }
                        if (words[0] == "UNIQ")
                        {
                            outTuple = uniq.uniqTuple(in_queue[0], Int32.Parse(words[1]));
                            //only put the tuple in the out_queue if don't exists another equal to that tuple
                            if (outTuple.getUser() != "")
                            {
                                out_queue.Add(outTuple);
                                Console.WriteLine("Output from Operator:");
                                Console.WriteLine(outTuple.getUser());
                            }
                            in_queue.Remove(in_queue[0]);
                        }
                        if (words[0] == "DUP")
                        {
                            List <remoting_interfaces.Tuple> duplicatedTuple = dup.duplicate(in_queue[0]);

                            foreach (remoting_interfaces.Tuple tuplo in duplicatedTuple)
                            {
                                out_queue.Add(tuplo);
                                Console.WriteLine("Output from Operator:");
                                Console.WriteLine(tuplo.getID());
                                Console.WriteLine(tuplo.getUser());
                                Console.WriteLine(tuplo.getURL());
                            }
                            duplicatedTuple.Remove(in_queue[0]);
                            duplicatedTuple.Remove(in_queue[0]);

                            in_queue.Remove(in_queue[0]);
                        }
                        if (words[0] == "COUNT")
                        {
                            outTuple = count.countMethod(in_queue[0]);
                            out_queue.Add(outTuple);

                            Console.WriteLine("Output from Operator:");
                            Console.WriteLine(outTuple.getUser());
                            Console.WriteLine("Tuples count until now: " + count.getCount());
                            Console.WriteLine("      ");

                            in_queue.Remove(in_queue[0]);
                        }
                    }
                }
                finally
                {
                    Monitor.Exit(tLock);
                }
            }
        }