コード例 #1
0
        private void UpdateControl(TagRead ent)
        {
            if (this.InvokeRequired)
            {
                UpdateControlDelegate d = new UpdateControlDelegate(UpdateControl);
                this.Invoke(d, ent);
            }
            else
            {
                bool exist = false;
                foreach (TagRead var in list)
                {
                    if (var.Epc == ent.Epc)
                    {
                        exist = true;
                        var.Count += ent.Count;
                    }
                }
                if (!exist)
                {
                    ent.Serial = list.Count + 1;
                    list.Add(ent);
                }
                this._lvReadID.Items.Clear();
                foreach (TagRead var in list)
                {
                    string[] strArr = new string[3];
                    strArr[0] = var.Serial.ToString();
                    strArr[1] = var.Epc;
                    strArr[2] = var.Count.ToString();

                    ListViewItem item = new ListViewItem(strArr);
                    this._lvReadID.Items.Add(item);
                }
                _lbSumTagsReadID.Invoke(new EventHandler(delegate
                {
                    _lbSumTagsReadID.Text = list.Count.ToString();
                }));

            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: kingtut666/holly
        public Form1()
        {
            InitializeComponent();

            Form1.server = this;
            //recogSAPI = new AudioRecog_SAPI();
            //recogSAPI.RecognitionSuccessful += new AudioRecog.RecognitionSuccessfulDelegate(r_RecognitionSuccessful);
            //recogSphinx = new AudioRecog_CMUSphinx();
            //recogSphinx.RecognitionSuccessful += new AudioRecog.RecognitionSuccessfulDelegate(r_RecognitionSuccessful);
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
            Talker = new SpeechOut();
            Talker.AddEndpoint("beast", null);
            lwrf = new LWRF();
            clkActions = new Dictionary<string, Tuple<bool, bool,string>>();
            Recog = new AudioRecogHolder();
            Recog.RegisterRecogEngine(new AudioRecog_SAPI());
            Recog.RegisterRecogEngine(new AudioRecog_CMUSphinx());
            Recog.RecognitionSuccessful += new AudioRecogHolder.RecognitionSuccessfulDelegate(Recog_RecognitionSuccessful);
            mControllables = new List<IControllable>();

            //Controllables
            theWorld = TheWorld.CreateTestWorld();
            mControllables.Add(theWorld);
            clk = new AlarmClock();
            clk.ControllableEvent += new IControllableEventDelegate(clk_ControllableEvent);
            mControllables.Add(clk);
            List<Device> devs = theWorld.ListDevicesByCaps(null, EDeviceCapabilities.Special_XBMC);
            if (devs != null)
            {
                foreach (Device d in devs)
                {
                    XBMC xbmc = new XBMC(d.ID, d.Args["port"], d.Args["user"], d.Args["pass"]);
                    if (!xbmc.VerifyConnection())
                    {
                        Form1.updateLog("Couldn't connect to XBMC at " + d.ID + ":" + d.Args["port"],
                            ELogLevel.Warning, ELogType.XBMC);
                        d.Disable();
                        continue;
                    }
                    xbmc.ControllableEvent += new IControllableEventDelegate(xbmc_ControllableEvent);
                    mControllables.Add(xbmc);
                    d.Instance = xbmc;
                }
            }

            protos = new DeviceProtocolMappings();
            protos.SetWorld(theWorld);

            List<string> done = new List<string>();
            foreach (IControllable ic in mControllables)
            {
                Recog.AddControllable(ic);
            }

            p = new AudioProto();
            p.Listen(s_port);
            p.NewAudioStream += new AudioProto.NewAudioStreamDelegate(p_NewAudioStream);

            prog1.Minimum = 0;
            prog1.Maximum = 250;
            prog2.Minimum = 0;
            prog2.Maximum = 250;
            prog3.Minimum = 0;
            prog3.Maximum = 250;
            progCmd1.Minimum = 0;
            progCmd1.Maximum = 250;
            progCmd2.Minimum = 0;
            progCmd2.Maximum = 250;
            progCmd3.Minimum = 0;
            progCmd3.Maximum = 250;
            UpdateControlD += new UpdateControlDelegate(UpdateControl);
            tick = new System.Timers.Timer();
            tick.Elapsed += new ElapsedEventHandler(tick_Elapsed);
            tick.Interval = 1000;
            tick.Start();
        }