Ejemplo n.º 1
0
        /// <summary>
        /// Атоматичекая настройка БО
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void автоматическаяНастройкаБлокаОтображенияToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ((this.handle != null) && (this.handle.VisionBlock != null))
            {
                FastInitForm form = new FastInitForm();
                form.NetAddress = this.handle.VisionBlock.Address;
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    byte netAddress = form.NetAddress;
                    byte num2 = 0;
                    byte num3 = 2;
                    for (int i = 0; i < this.handle.VisionBlock.Indicators.Count; i++)
                    {
                        switch (this.handle.VisionBlock.Indicators[i].IndicatorType)
                        {
                            case IndicatorType.Clock:
                            case IndicatorType.Default:
                                break;

                            default:
                                this.handle.VisionBlock.Indicators[i].Address = netAddress;
                                this.handle.VisionBlock.Indicators[i].Offset = num2;
                                if (((byte)(this.handle.VisionBlock.Indicators[i].Con & 0x80)) != 0)
                                {
                                    num3 = 4;
                                }
                                else
                                {
                                    num3 = 2;
                                }
                                num2 = (byte)(num2 + num3);
                                break;
                        }
                    }
                    byte num6 = num2;
                    byte num7 = 0;
                    for (int j = 0; j < this.handle.VisionBlock.Indicators.Count; j++)
                    {
                        switch (this.handle.VisionBlock.Indicators[j].IndicatorType)
                        {
                            case IndicatorType.Clock:
                            case IndicatorType.Default:
                                break;

                            default:
                                this.handle.VisionBlock.Indicators[j].OffsetPp.OffsetOfByte = num6;
                                this.handle.VisionBlock.Indicators[j].OffsetPp.OffsetOfBits = num7;
                                num7 = (byte)(num7 + 2);
                                if (num7 > 6)
                                {
                                    num6 = (byte)(num6 + 1);
                                    num7 = 0;
                                }
                                break;
                        }
                    }
                    byte num9 = num6;
                    for (int k = 0; k < this.handle.VisionBlock.Indicators.Count; k++)
                    {
                        switch (this.handle.VisionBlock.Indicators[k].IndicatorType)
                        {
                            case IndicatorType.Clock:
                            case IndicatorType.Default:
                                break;

                            default:
                                this.handle.VisionBlock.Indicators[k].OffsetThr.OffsetOfByte = num9;
                                this.handle.VisionBlock.Indicators[k].OffsetThr.OffsetOfBits = num7;
                                num7 = (byte)(num7 + 2);
                                if (num7 > 6)
                                {
                                    num9 = (byte)(num9 + 1);
                                    num7 = 0;
                                }
                                break;
                        }
                    }
                    bool paraDelat = form.ParaDelat;
                    this.ShowInTable();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Атоматичекая настройка БО
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void автоматическаяНастройкаБлокаОтображенияToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ((this.handle != null) && (this.handle.VisionBlock != null))
            {
                FastInitForm form = new FastInitForm();
                form.NetAddress = this.handle.VisionBlock.Address;
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    byte netAddress = form.NetAddress;
                    byte num2       = 0;
                    byte num3       = 2;
                    for (int i = 0; i < this.handle.VisionBlock.Indicators.Count; i++)
                    {
                        switch (this.handle.VisionBlock.Indicators[i].IndicatorType)
                        {
                        case IndicatorType.Clock:
                        case IndicatorType.Default:
                            break;

                        default:
                            this.handle.VisionBlock.Indicators[i].Address = netAddress;
                            this.handle.VisionBlock.Indicators[i].Offset  = num2;
                            if (((byte)(this.handle.VisionBlock.Indicators[i].Con & 0x80)) != 0)
                            {
                                num3 = 4;
                            }
                            else
                            {
                                num3 = 2;
                            }
                            num2 = (byte)(num2 + num3);
                            break;
                        }
                    }
                    byte num6 = num2;
                    byte num7 = 0;
                    for (int j = 0; j < this.handle.VisionBlock.Indicators.Count; j++)
                    {
                        switch (this.handle.VisionBlock.Indicators[j].IndicatorType)
                        {
                        case IndicatorType.Clock:
                        case IndicatorType.Default:
                            break;

                        default:
                            this.handle.VisionBlock.Indicators[j].OffsetPp.OffsetOfByte = num6;
                            this.handle.VisionBlock.Indicators[j].OffsetPp.OffsetOfBits = num7;
                            num7 = (byte)(num7 + 2);
                            if (num7 > 6)
                            {
                                num6 = (byte)(num6 + 1);
                                num7 = 0;
                            }
                            break;
                        }
                    }
                    byte num9 = num6;
                    for (int k = 0; k < this.handle.VisionBlock.Indicators.Count; k++)
                    {
                        switch (this.handle.VisionBlock.Indicators[k].IndicatorType)
                        {
                        case IndicatorType.Clock:
                        case IndicatorType.Default:
                            break;

                        default:
                            this.handle.VisionBlock.Indicators[k].OffsetThr.OffsetOfByte = num9;
                            this.handle.VisionBlock.Indicators[k].OffsetThr.OffsetOfBits = num7;
                            num7 = (byte)(num7 + 2);
                            if (num7 > 6)
                            {
                                num9 = (byte)(num9 + 1);
                                num7 = 0;
                            }
                            break;
                        }
                    }
                    bool paraDelat = form.ParaDelat;
                    this.ShowInTable();
                }
            }
        }