コード例 #1
0
        private void startListener()
        {
            this.communicationManager = new CommunicationManager()
            {
                LocalAddress  = ConfigurationManager.AppSettings.Get("LocalAddress"),
                RemoteAddress = ConfigurationManager.AppSettings.Get("RemoteAddress"),
                LocalPort     = int.Parse(ConfigurationManager.AppSettings.Get("LocalPort")),
                RemotePort    = int.Parse(ConfigurationManager.AppSettings.Get("RemotePort")),
                TimeToLive    = int.Parse(ConfigurationManager.AppSettings.Get("TimeToLive"))
            };

            this.communicationManager.Start();

            byte[] bytesReceived = null;

            int bytesCount = -1;

            while (true)
            {
                bytesReceived = this.communicationManager.Receive(out bytesCount);

                if ((bytesCount > 0) && (bytesReceived != null) && (bytesReceived.Length > 0))
                {
                    DataIdentifier identifier = CommonUtility.BinaryDeserialize(bytesReceived) as DataIdentifier; //JsonUtility.JsonDeserialize(bytesReceived, typeof(DataIdentifier), null, null) as DataIdentifier;

                    DataPair pair = this.doAcquisition(identifier);

                    this.saveDataPair(pair);

                    Thread thread = new Thread(this.threadProcSafe);

                    thread.Start(pair);
                }
            }
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: v-rawang/Rally.IO
        private void loadAppState()
        {
            if (File.Exists("appState.dat"))
            {
                byte[] appStateBytes = new byte[1024];

                using (FileStream fileStream = new FileStream("appState.dat", FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    appStateBytes = new byte[fileStream.Length];
                    fileStream.Read(appStateBytes, 0, appStateBytes.Length);
                }

                Dictionary <string, object> appState = CommonUtility.BinaryDeserialize(appStateBytes) as Dictionary <string, object>;

                if (appState != null && appState.Count > 0)
                {
                    this.textBoxAssemblyName.Text      = appState["AssemblyName"].ToString();
                    this.textBoxClassname.Text         = appState["ClassName"].ToString();
                    this.textBoxNamespace.Text         = appState["Namespace"].ToString();
                    this.textBoxOutputDir.Text         = appState["OutputDir"].ToString();
                    this.checkBoxShouldCompile.Checked = (bool)appState["ShouldCompile"];
                    this.fieldMappins = appState["FieldMappings"] as IDictionary <string, int[]>;

                    this.ucContractItem1.Populate(this.fieldMappins);
                }
            }
        }
コード例 #3
0
        private void startListener()
        {
            NetworkParameter networkParameter = this.parameters.GetNetworkParameter();

            this.communicationManager = new CommunicationManager()
            {
                LocalAddress  = networkParameter.LocalAddress,  //ConfigurationManager.AppSettings.Get("LocalAddress"),
                RemoteAddress = networkParameter.RemoteAddress, //networkParameter.MulticastAddress, //ConfigurationManager.AppSettings.Get("RemoteAddress"),
                LocalPort     = networkParameter.LocalPort,     //int.Parse(ConfigurationManager.AppSettings.Get("LocalPort")),
                RemotePort    = networkParameter.RemotePort,    //networkParameter.MulticastPort, //int.Parse(ConfigurationManager.AppSettings.Get("RemotePort")),
                TimeToLive    = networkParameter.TimeToLive,    //int.Parse(ConfigurationManager.AppSettings.Get("TimeToLive"))
                PipeName      = networkParameter.PipeName
            };

            //this.communicationManager.Start();

            this.communicationManager.Start((int)(networkParameter.CommunicationType));

            byte[] bytesReceived = null;

            int bytesCount = -1;

            while (true)
            {
                bytesReceived = this.communicationManager.Receive(out bytesCount);

                if ((bytesCount > 0) && (bytesReceived != null) && (bytesReceived.Length > 0))
                {
                    DataIdentifier identifier = CommonUtility.BinaryDeserialize(bytesReceived) as DataIdentifier; //JsonUtility.JsonDeserialize(bytesReceived, typeof(DataIdentifier), null, null) as DataIdentifier;

                    DataPair pair = this.doAcquisition(identifier);

                    pair = this.doComputation(pair);

                    pair = this.doCorrelation(pair.Identifier, pair.Items[0]);

                    this.saveDataPair(pair);

                    this.Invoke(new Action(() =>
                    {
                        using (MemoryStream stream = new MemoryStream(pair.Items[1].DataBytes))
                        {
                            this.bitmap = Bitmap.FromStream(stream) as Bitmap;
                            this.pictureBoxAcquiredImage.Image = this.bitmap;
                            this.pictureBoxAcquiredImage.Refresh();
                        }

                        if ((pair.Items[0].DataParameters != null) && (pair.Items[1].DataParameters.Count > 0))
                        {
                            //this.listBoxBarcodes.DataSource = pair.Items[0].DataParameters[0].Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                            string barcodes = pair.Items[1].GetParameterValue("BarCodes");

                            this.listBoxBarcodes.DataSource = !String.IsNullOrEmpty(barcodes) ? barcodes.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries) : null;
                        }
                        else
                        {
                            this.listBoxBarcodes.DataSource = null;
                        }

                        this.listBoxBarcodes.Refresh();

                        this.tabControlMain.SelectedTab = this.tabPageBarcodes;

                        this.toolStripStatusLabelCurrentStatus.Text = this.currentImageFile;

                        if (this.bindingSource.Count == 20)
                        {
                            string imageUrlMappingKey = this.bindingSource[0].ToString();

                            if (this.imageUrlMappings.ContainsKey(imageUrlMappingKey))
                            {
                                this.imageUrlMappings.Remove(imageUrlMappingKey);
                            }

                            this.bindingSource.RemoveAt(0);
                        }

                        this.bindingSource.Add(new DataParameter()
                        {
                            Name = this.currentImageFile, Value = this.currentImageFile
                        });

                        this.dataGridViewRecentImages.Refresh();
                    }));
                }
            }
        }