Exemple #1
0
        /// <summary>
        /// Converts a DataSet into its RDL representation .
        /// </summary>
        /// <param name="writer">The <typeparamref name="XmlWriter"/> stream to which the DataSet is serialized.</param>
        public void WriteXml(XmlWriter writer)
        {
            //--- DataSet
            writer.WriteStartElement(Rdl.DATASET);
            writer.WriteAttributeString(Rdl.NAME, _name);

            //--- Fields
            if (_fields != null)
            {
                ((IXmlSerializable)_fields).WriteXml(writer);
            }

            //--- Query
            if (_query != null)
            {
                ((IXmlSerializable)_query).WriteXml(writer);
            }

            //--- CaseSensitivity
            if (_caseSensitivity != Sensitivity.Auto)
            {
                writer.WriteElementString(Rdl.CASESENSITIVITY, _caseSensitivity.ToString());
            }

            //--- Collation
            writer.WriteElementString(Rdl.COLLATION, _collation);

            //--- AccentSensitivity
            if (_accentSensitivity != Sensitivity.Auto)
            {
                writer.WriteElementString(Rdl.ACCENTSENSITIVITY, _accentSensitivity.ToString());
            }

            //--- KanatypeSensitivity
            if (_kanatypeSensitivity != Sensitivity.Auto)
            {
                writer.WriteElementString(Rdl.KANATYPESENSITIVITY, _kanatypeSensitivity.ToString());
            }

            //--- WidthSensititvity
            if (_widthSensitivity != Sensitivity.Auto)
            {
                writer.WriteElementString(Rdl.WIDTHSENSITIVITY, _widthSensitivity.ToString());
            }

            //--- Filters
            if (_filters != null)
            {
                ((IXmlSerializable)_filters).WriteXml(writer);
            }

            writer.WriteEndElement();
        }
Exemple #2
0
 public override void WriteXml(XmlWriter writer)
 {
     base.WriteXml(writer);
     writer.WriteElementString("KnobImage", KnobImage);
     writer.WriteElementString("RotationStep", RotationStep.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("StepValue", StepValue.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("InitialRotation", InitialRotation.ToString(CultureInfo.InvariantCulture));
     writer.WriteStartElement("ClickType");
     writer.WriteElementString("Type", ClickType.ToString());
     if (ClickType != ClickType.Touch)
     {
         writer.WriteElementString("Sensitivity", Sensitivity.ToString(CultureInfo.InvariantCulture));
     }
     writer.WriteEndElement();
 }
Exemple #3
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteAttributeString("name", Name);
     writer.WriteAttributeString("desc1", Description1);
     writer.WriteAttributeString("desc2", Description2);
     writer.WriteAttributeString("partName", PartName);
     writer.WriteAttributeString("featureName", FeatureName);
     writer.WriteAttributeString("toleranceValue", ToleranceValue.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("toleranceEffective",
                                 ToleranceEffective.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("effect", Effect.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("sensitivity", Sensitivity.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("meanShift", MeanShift.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("src", Src);
     writer.WriteAttributeString("weight", Weight.ToString(CultureInfo.InvariantCulture));
 }
Exemple #4
0
        public override void WriteXml(XmlWriter writer)
        {
            base.WriteXml(writer);
            writer.WriteElementString("MetricImage", MetricImage);
            writer.WriteElementString("InitialValueRotation", InitialValueRotation.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("StepValueRotation", StepValueRotation.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("MaxValueRotation", MaxValueRotation.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("MinValueRotation", MinValueRotation.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("InitialRotation", InitialRotation.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("RotationTravel", RotationTravel.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("InitialValueTranslationX", InitialValueTranslationX.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("StepValueTranslationX", StepValueTranslationX.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("MaxValueTranslationX", MaxValueTranslationX.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("MinValueTranslationX", MinValueTranslationX.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("InitialTranslationX", InitialTranslationX.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("TranslationTravelX", TranslationTravelX.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("InitialValueTranslationY", InitialValueTranslationY.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("StepValueTranslationY", StepValueTranslationY.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("MaxValueTranslationY", MaxValueTranslationY.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("MinValueTranslationY", MinValueTranslationY.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("InitialTranslationY", InitialTranslationY.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("TranslationTravelY", TranslationTravelY.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("ClickableVertical", ClickableVertical.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("ClickableHorizontal", ClickableHorizontal.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("InvertedHorizontal", InvertedHorizontal.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("InvertedVertical", InvertedVertical.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString("DragOneOnOne", DragOneForOne.ToString(CultureInfo.InvariantCulture));

            writer.WriteStartElement("ClickType");
            writer.WriteElementString("Type", ClickType.ToString( ));
            if (ClickType == LinearClickType.Swipe)
            {
                writer.WriteElementString("Sensitivity", Sensitivity.ToString(CultureInfo.InvariantCulture));
            }
            writer.WriteEndElement( );
        }
        public override AdaptiveCard GetCreateNewCard(List <Group> groups, List <Team> teams, bool isEditCard)
        {
            // Update this code to add groups & teams.
            var employeGroups = new List <AdaptiveChoice>();

            foreach (var group in groups)
            {
                employeGroups.Add(new AdaptiveChoice()
                {
                    Title = group.Name, Value = group.Id
                });
            }

            var channels = new List <AdaptiveChoice>();

            foreach (var team in teams)
            {
                foreach (var channel in team.Channels)
                {
                    channels.Add(new AdaptiveChoice()
                    {
                        Title = $"{team.Name} > {channel.Name}", Value = $"{team.Id};{channel.Id}"
                    });
                }
            }

            string groupRecipients = null;

            if (Recipients.Groups != null && Recipients.Groups.Count != 0)
            {
                groupRecipients = string.Join(",", Recipients.Groups.Select(g => g.GroupId));
            }

            string channelRecipients = null;

            if (Recipients.Channels != null & Recipients.Channels.Count != 0)
            {
                channelRecipients = string.Join(",", Recipients.Channels.Select(g => g.TeamId + ";" + g.Channel.Id));
            }

            var messageTypeChoices = new List <AdaptiveChoice>();

            messageTypeChoices.Add(new AdaptiveChoice()
            {
                Title = "❕ Important", Value = "Important"
            });
            messageTypeChoices.Add(new AdaptiveChoice()
            {
                Title = "❗ Emergency", Value = "Emergency"
            });
            messageTypeChoices.Add(new AdaptiveChoice()
            {
                Title = "📄 Information", Value = "Information"
            });
            var newCampaignCard = new AdaptiveCard(new AdaptiveSchemaVersion("1.0"))
            {
                Body = new List <AdaptiveElement>()
                {
                    new AdaptiveContainer()
                    {
                        Items = new List <AdaptiveElement>()
                        {
                            new AdaptiveImage()
                            {
                                Url = new System.Uri(ApplicationSettings.BaseUrl + "/Resources/CreateMessageHeader.png")
                            },
                            new AdaptiveTextBlock()
                            {
                                Text     = $"This {ApplicationSettings.AppFeature} will be sent from the {ApplicationSettings.AppName} app handle. Fields marked with (*) are mandatory while composing.",
                                Size     = AdaptiveTextSize.Small,
                                Color    = AdaptiveTextColor.Accent,
                                Spacing  = AdaptiveSpacing.Small,
                                Weight   = AdaptiveTextWeight.Bolder,
                                IsSubtle = true,
                                Wrap     = true,
                            },
                            new AdaptiveTextBlock()
                            {
                                Separator = true,

                                Spacing = AdaptiveSpacing.Large,
                                Size    = AdaptiveTextSize.Large,
                                Color   = AdaptiveTextColor.Accent,
                                Text    = "Choose Audience"
                            },
                            new AdaptiveColumnSet()
                            {
                                Columns = new List <AdaptiveColumn>()
                                {
                                    new AdaptiveColumn()
                                    {
                                        Items = new List <AdaptiveElement>()
                                        {
                                            new AdaptiveTextBlock()
                                            {
                                                Text = "Choose group(s) of people",
                                                HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                            }
                                        },
                                        Width = "50",
                                    },
                                    new AdaptiveColumn()
                                    {
                                        Items = new List <AdaptiveElement>()
                                        {
                                            new AdaptiveChoiceSetInput()
                                            {
                                                Id      = "groups",
                                                Spacing = AdaptiveSpacing.None,

                                                Choices       = new List <AdaptiveChoice>(employeGroups),
                                                IsMultiSelect = true,
                                                Style         = AdaptiveChoiceInputStyle.Compact,
                                                Value         = isEditCard? groupRecipients:""
                                            },
                                        },
                                        Width = "50"
                                    }
                                }
                            },
                            new AdaptiveColumnSet()
                            {
                                Columns = new List <AdaptiveColumn>()
                                {
                                    new AdaptiveColumn()
                                    {
                                        Items = new List <AdaptiveElement>()
                                        {
                                            new AdaptiveTextBlock()
                                            {
                                                Text = "Choose channel(s) in Teams",
                                                HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                            }
                                        },
                                        Width = "50",
                                    },
                                    new AdaptiveColumn()
                                    {
                                        Items = new List <AdaptiveElement>()
                                        {
                                            new AdaptiveChoiceSetInput()
                                            {
                                                Id            = "channels",
                                                Spacing       = AdaptiveSpacing.None,
                                                Value         = isEditCard? channelRecipients:"",
                                                Choices       = new List <AdaptiveChoice>(channels),
                                                IsMultiSelect = true,
                                                Style         = AdaptiveChoiceInputStyle.Compact
                                            },
                                        },
                                        Width = "50"
                                    }
                                }
                            },
                            new AdaptiveContainer()
                            {
                                Spacing   = AdaptiveSpacing.Large,
                                Separator = true,
                                Items     = new List <AdaptiveElement>()
                                {
                                    new AdaptiveTextBlock()
                                    {
                                        Size  = AdaptiveTextSize.Large,
                                        Color = AdaptiveTextColor.Accent,
                                        Text  = "Compose Message"
                                    },
                                    new AdaptiveColumnSet()
                                    {
                                        Columns = new List <AdaptiveColumn>()
                                        {
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextBlock()
                                                    {
                                                        Text = "Title*",
                                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                                    }
                                                },
                                                Width = "20"
                                            },
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextInput()
                                                    {
                                                        Id          = "title",
                                                        Placeholder = "eg: Giving Campaign 2018 is here",
                                                        Value       = isEditCard? Title: ""
                                                    }
                                                },
                                                Width = "85"
                                            }
                                        }
                                    },
                                    new AdaptiveColumnSet()
                                    {
                                        Columns = new List <AdaptiveColumn>()
                                        {
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextBlock()
                                                    {
                                                        Text = "Sub-Title",
                                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                                    }
                                                },
                                                Width = "20"
                                            },
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextInput()
                                                    {
                                                        Id          = "subTitle",
                                                        Placeholder = "eg: Have you contributed to the mission?",
                                                        Value       = isEditCard? SubTitle: ""
                                                    }
                                                },
                                                Width = "85"
                                            }
                                        }
                                    },
                                    new AdaptiveColumnSet()
                                    {
                                        Columns = new List <AdaptiveColumn>()
                                        {
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextBlock()
                                                    {
                                                        Text = "Image*",
                                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                                    }
                                                },
                                                Width = "20"
                                            },
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextInput()
                                                    {
                                                        Id          = "image",
                                                        Placeholder = "eg: https:// URL to image of exact size 530px X 95px",
                                                        Value       = isEditCard? ImageUrl: ""
                                                    }
                                                },
                                                Width = "85"
                                            }
                                        }
                                    },
                                    new AdaptiveColumnSet()
                                    {
                                        Columns = new List <AdaptiveColumn>()
                                        {
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextBlock()
                                                    {
                                                        Text = "Author alias*",
                                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                                    }
                                                },
                                                Width = "20"
                                            },
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextInput()
                                                    {
                                                        Id          = "authorAlias",
                                                        Placeholder = "eg: [email protected]",
                                                        Value       = isEditCard? Author?.EmailId: ""
                                                    }
                                                },
                                                Width = "85"
                                            }
                                        }
                                    },
                                    new AdaptiveColumnSet()
                                    {
                                        Columns = new List <AdaptiveColumn>()
                                        {
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextBlock()
                                                    {
                                                        Text = "Preview*",
                                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                                    }
                                                },
                                                Width = "20"
                                            },
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextInput()
                                                    {
                                                        Id          = "preview",
                                                        Placeholder = "eg: The 2018 Employee Giving Campaign is officially underway! Our incredibly generous culture of employee giving is unique to Contoso, and has a long history going back to our founder and his family’s core belief and value in philanthropy. Individually and collectively, we can have an incredible impact no matter how we choose to give. We are all very fortunate and 2018 has been a good year for the company which we are all participating in. Having us live in a community with a strong social safety net benefits us all so lets reflect our participation in this year's success with participation in Give.",
                                                        IsMultiline = true,
                                                        Value       = isEditCard? Preview: ""
                                                    }
                                                },
                                                Width = "85"
                                            }
                                        }
                                    },
                                    new AdaptiveColumnSet()
                                    {
                                        Columns = new List <AdaptiveColumn>()
                                        {
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextBlock()
                                                    {
                                                        Text = "Body*",
                                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                                    }
                                                },
                                                Width = "20"
                                            },
                                            new AdaptiveColumn()
                                            {
                                                Items = new List <AdaptiveElement>()
                                                {
                                                    new AdaptiveTextInput()
                                                    {
                                                        Id          = "body",
                                                        Placeholder = "eg: I hope you will take advantage of some of the fun and impactful opportunities that our giving team has put together and I’d like to thank our VPALs John Doe and Jason Natie for all the hard work they've put into planning these events for our team. To find out more about these opportunities, look for details in Give 2018 > General channel.",
                                                        IsMultiline = true,
                                                        Value       = isEditCard? Body: ""
                                                    }
                                                },
                                                Width = "85"
                                            }
                                        }
                                    },
                                }
                            }
                        }
                    },
                    new AdaptiveContainer()
                    {
                        Spacing   = AdaptiveSpacing.Large,
                        Separator = true,
                        Items     = new List <AdaptiveElement>()
                        {
                            new AdaptiveTextBlock()
                            {
                                Size  = AdaptiveTextSize.Large,
                                Color = AdaptiveTextColor.Accent,
                                Text  = "Choose Message Properties"
                            },
                        },
                    },
                    new AdaptiveContainer()
                    {
                        Spacing = AdaptiveSpacing.Medium,
                        Items   = new List <AdaptiveElement>()
                        {
                            new AdaptiveColumnSet()
                            {
                                Columns = new List <AdaptiveColumn>()
                                {
                                    new AdaptiveColumn()
                                    {
                                        Items = new List <AdaptiveElement>()
                                        {
                                            new AdaptiveToggleInput()
                                            {
                                                Id    = "acknowledge",
                                                Title = "Request acknowledgement",
                                                Value = isEditCard? IsAcknowledgementRequested.ToString(): "false",
                                            }
                                        }
                                    },
                                    new AdaptiveColumn()
                                    {
                                        Items = new List <AdaptiveElement>()
                                        {
                                            new AdaptiveToggleInput()
                                            {
                                                Id    = "allowContactIns",
                                                Title = "Allow recipient to contact",
                                                Value = isEditCard? IsContactAllowed.ToString(): "false",
                                            }
                                        },
                                        Width = "stretch"
                                    }
                                }
                            },
                            new AdaptiveColumnSet()
                            {
                                Columns = new List <AdaptiveColumn>()
                                {
                                    new AdaptiveColumn()
                                    {
                                        Items = new List <AdaptiveElement>()
                                        {
                                            new AdaptiveTextBlock()
                                            {
                                                HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                                Text = "Choose Message Sensitivity",
                                            }
                                        },
                                        Width = "50"
                                    },
                                    new AdaptiveColumn()
                                    {
                                        Items = new List <AdaptiveElement>()
                                        {
                                            new AdaptiveChoiceSetInput()
                                            {
                                                Id            = "messageType",
                                                Spacing       = AdaptiveSpacing.None,
                                                Value         = isEditCard?  Sensitivity.ToString() : "Important",
                                                Choices       = new List <AdaptiveChoice>(messageTypeChoices),
                                                IsMultiSelect = false,
                                                Style         = AdaptiveChoiceInputStyle.Compact,
                                            },
                                        },
                                        Width = "50"
                                    }
                                }
                            }
                        }
                    }
                },
                Actions = new List <AdaptiveAction>()
                {
                    new AdaptiveSubmitAction()
                    {
                        Title = "✔️ Preview",
                        Data  = isEditCard?
                                new AnnouncementActionDetails()
                        {
                            ActionType = Constants.CreateOrEditAnnouncement, Id = Id
                        }
                        :new ActionDetails()
                        {
                            ActionType = Constants.CreateOrEditAnnouncement
                        }
                    },
                    new AdaptiveSubmitAction()
                    {
                        Title = "❌ Cancel",
                        Data  = new ActionDetails()
                        {
                            ActionType = Constants.Cancel
                        }
                    }
                }
            };

            return(newCampaignCard);
        }
        /// <summary>
        /// 终测命令
        /// </summary>
        private void ExecuteTest()
        {
            bool          isSaveData = false;
            StringBuilder strBuild   = new StringBuilder();

            IsTestEnable = false;
            try
            {
                //另一线程执行该方法
                Thread thread = new Thread(() =>
                {
                    //SN
                    if (!string.IsNullOrEmpty(SN))
                    {
                        TestingPara.SN = SN;
                    }
                    //GPIB通信
                    if (IsReady)
                    {
                        double ini  = IniAtt;
                        double span = 0.2;
                        double voltage;
                        double saturation = 0;
                        //Hp8156A.Open();
                        Mp2100A.AutoScale();
                        Aq6317B.SetSingle();

                        //Supply Current
                        SupplyCurrent             = AgE3631A.GetCurrent();
                        TestingPara.SupplyCurrent = SupplyCurrent.ToString("F3");
                        //OutputPower
                        OutputPower             = Hp8153A.ReadPower("2");
                        TestingPara.OutputPower = OutputPower.ToString("F3");

                        //SD_Desserted SD_High
                        for (int i = 0; i <= 40; i++)
                        {
                            Hp8156A.SetAtt(ini.ToString());
                            Thread.Sleep(300);
                            voltage = Ag34401A.GetVoltage();
                            Thread.Sleep(100);
                            if (i == 0 && voltage >= 2.0)
                            {
                                MessageBox.Show("初始即为高电压,请检查设备连接!", "系统提示");
                                return;
                            }
                            if (voltage >= 2.0)
                            {
                                SdDesserted = ini;
                                TestingPara.SD_Desserted = SdDesserted.ToString();
                                SDHigh = voltage;
                                TestingPara.SD_High = SDHigh.ToString("F3");
                                //SdDesserted SdHigh
                                strBuild.Append(string.Format("SdDesserted:{0}", SdDesserted));
                                strBuild.Append(string.Format("SdHigh:{0}", SDHigh));
                                DisplayInfo = strBuild.ToString();
                                break;
                            }
                            else
                            {
                                ini += span;
                                if (i == 40)
                                {
                                    strBuild.Append("获取SdDesserted失败!");
                                    DisplayInfo = strBuild.ToString();
                                }
                            }
                        }
                        ;
                        //SD_Asserted,SD_Low
                        for (int i = 0; i <= 30; i++)
                        {
                            Hp8156A.SetAtt(ini.ToString());
                            Thread.Sleep(200);
                            voltage = Ag34401A.GetVoltage();
                            Thread.Sleep(100);
                            if (voltage < 0.5)
                            {
                                SdAsserted = ini;
                                TestingPara.SD_Asserted = SdAsserted.ToString();
                                SDLow = voltage;
                                TestingPara.SD_Low = SDLow.ToString();
                                strBuild.Append(string.Format("SdAsserted:{0}", SdAsserted));
                                strBuild.Append(string.Format("SdLow:{0}", SDLow));
                                DisplayInfo = strBuild.ToString();
                                break;
                            }
                            else
                            {
                                ini -= span;
                                if (i == 30)
                                {
                                    strBuild.Append("获取SdAsserted失败");
                                    DisplayInfo = strBuild.ToString();
                                }
                            }
                        }
                        //Hysteresis
                        Hysteresis             = SdDesserted = SdAsserted;
                        TestingPara.Hysteresis = Hysteresis.ToString();
                        #region MP2100
                        Hp8156A.SetAtt(IniAtt.ToString());
                        //Exit.Ratio
                        ExtiRatio = Mp2100A.GetExRatio();
                        TestingPara.ExtioRatio = ExtiRatio.ToString("F3");
                        strBuild.Append(string.Format("Extinction Ratio:{0}", ExtiRatio));
                        DisplayInfo = strBuild.ToString();
                        //Crossing
                        CrossingRate         = Mp2100A.GetCrossing();
                        TestingPara.Crossing = CrossingRate.ToString("F3");
                        strBuild.Append(string.Format("CrossingRate:{0}", CrossingRate));
                        DisplayInfo = strBuild.ToString();
                        //MaskMargin
                        MaskMargin             = Mp2100A.GetMaskMargin();
                        TestingPara.MaskMargin = MaskMargin.ToString("F3");
                        strBuild.Append(string.Format("Mask Margin:{0}", MaskMargin));
                        DisplayInfo = strBuild.ToString();
                        //Jitter
                        Jitter             = Mp2100A.GetJitter();
                        TestingPara.Jitter = Jitter.ToString("F3");
                        strBuild.Append(string.Format("Jitter:{0}", Jitter));
                        DisplayInfo = strBuild.ToString();
                        Thread.Sleep(2000);
                        //OSA
                        string osaData = Aq6317B.GetData();
                        string[] data  = osaData.Split(',');
                        //CenterWavelength
                        if (double.TryParse(data[1].Trim(), out double data1))
                        {
                            CenterWavelength = data1;
                        }
                        else
                        {
                            CenterWavelength = 0;
                        }
                        TestingPara.CenterWavelength = CenterWavelength.ToString();
                        //SMSR
                        if (double.TryParse(data[4].Trim(), out double data4))
                        {
                            SMSR = data4;
                        }
                        else
                        {
                            SMSR = 0;
                        }
                        TestingPara.SMSR = SMSR.ToString();
                        //WavelengthDiff
                        if (double.TryParse(data[0].Trim(), out double data0))
                        {
                            DifferenceWavelength = data0;
                        }
                        else
                        {
                            DifferenceWavelength = 0;
                        }
                        TestingPara.WavelengthDiff = DifferenceWavelength.ToString();

                        strBuild.AppendLine(string.Format("中心波长:{0}", CenterWavelength));
                        strBuild.AppendLine(string.Format("Δλ:{0}", DifferenceWavelength));
                        strBuild.AppendLine(string.Format("SMSR:{0}", SMSR));
                        DisplayInfo = strBuild.ToString();
                        //Sensitivity
                        Sensitivity             = Math.Round(GetSensitivity(), 2);
                        TestingPara.Sensitivity = Sensitivity.ToString();
                        strBuild.Append(string.Format("Sensitivity:{0}", Sensitivity));
                        DisplayInfo = strBuild.ToString();
                        #endregion
                        Thread.Sleep(300);

                        //Saturation
                        //测试饱和度 设置 衰减
                        Hp8156A.SetAtt(AttInSaturation);
                        Thread.Sleep(3000);
                        for (int i = 0; i < 5; i++)
                        {
                            Thread.Sleep(300);
                            double r = Mp2100A.GetErrorRate();
                            if (r >= 0)
                            {
                                saturation = Math.Log10(r);
                                if (saturation > -9)
                                {
                                    Saturation = false;
                                    break;
                                }
                            }
                            else
                            {
                                MessageBox.Show("读取眼图仪误码率发生错误", "系统设置");
                                break;
                            }
                            Saturation = true;
                        }
                        TestingPara.Saturation = Saturation;
                        strBuild.Append(string.Format("Saturation:{0}", Saturation));
                        DisplayInfo = strBuild.ToString();

                        //TxDisable
                        Thread.Sleep(200);
                        Hp8156A.Close();
                        P3202.SetVolage("1", "2.0");
                        Thread.Sleep(3000);
                        double txDisablePower = Hp8153A.ReadPower("2");
                        strBuild.Append(string.Format("Power@TxDisable:{0}", txDisablePower));
                        DisplayInfo = strBuild.ToString();
                        if (txDisablePower < -20.0 || Math.Log10(txDisablePower) > 10)
                        {
                            TxDisable             = true;
                            TestingPara.TxDisable = true;
                        }
                        P3202.SetVolage("1", "0.8");
                        isSaveData = true;
                    }
                    else
                    {
                        MessageBox.Show("设备初始化未完成,将无法进行GPIB测试", "系统提示");
                    }
                    //IIC通信参数
                    if (IsPortReady)
                    {
                        I2CTest();
                        isSaveData = true;
                    }
                    else
                    {
                        MessageBox.Show("串口初始化未完成", "系统提示");
                    }
                    if (isSaveData)
                    {
                        //将数据存储到本地
                        MessageBoxResult result = MessageBox.Show("测试完成,是否储存数据?", "系统提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
                        if (result == MessageBoxResult.OK)
                        {
                            bool isEmpty = false;
                            if (!Directory.Exists(@"E:\Xu"))
                            {
                                Directory.CreateDirectory(@"E:\Xu");
                            }
                            using (FileStream fs = new FileStream(SavePath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None))
                            {
                                using (StreamReader sr = new StreamReader(fs))
                                {
                                    string output = null;
                                    if ((output = sr.ReadLine()) == null)
                                    {
                                        isEmpty = true;
                                    }
                                    else
                                    {
                                        isEmpty = false;
                                    }
                                }
                            }
                            using (FileStream fs = new FileStream(SavePath, FileMode.Append, FileAccess.Write, FileShare.None))
                            {
                                using (StreamWriter sw = new StreamWriter(fs))
                                {
                                    if (isEmpty == true)
                                    {
                                        sw.WriteLine("SN,SupplyCurrent,OutputPower,ExRatio,Crossing,Jitter,MaskMargin," +
                                                     "CenterWavelength,SMSR,WavelengthDiff,TxDisable,Sensitivity,SD_Asserted,SD_Desserted," +
                                                     "Hysteresis,SD_High,SD_Low,Saturation,RxPoint1,RxPoint2,RxPoint3,TxPower," +
                                                     "Vcc,Temp,Bias,IsAwPass,Date");
                                    }
                                    sw.WriteLine(TestingPara.ToString());
                                }
                            }
                        }
                    }
                    IsTestEnable = true;
                });
                thread.IsBackground = true;
                thread.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "系统提示");
            }
        }
Exemple #7
0
        /// <summary>
        /// Sends a request to the kernel to set the wockets sensitivity
        /// </summary>
        /// <param name="mac">MAC address of the wocket</param>
        /// <param name="sensitivity">Sensitivity of the wocket</param>
        public static void SET_WOCKET_SENSITIVITY(string mac, Sensitivity sensitivity)
        {
            ThreadPool.QueueUserWorkItem(func =>
            {
                kernelLock.WaitOne();
                try
                {
                    if ((_Registered) && (_Connected))
                    {
                        string commandPath = REGISTRY_REGISTERED_APPLICATIONS_PATH + "\\{" + _IcomingChannel + "}";
                        NamedEvents namedEvent = new NamedEvents();

                        RegistryKey rk = Registry.LocalMachine.OpenSubKey(commandPath, true);
                        rk.SetValue("Message", KernelCommand.SET_WOCKET_SENSITIVITY.ToString(), RegistryValueKind.String);
                        rk.SetValue("Param", mac.ToString() + ":" + sensitivity.ToString(), RegistryValueKind.String);
                        rk.Flush();
                        rk.Close();

                        namedEvent.Send(Core._OutgoingChannel);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error("Core.cs:SET_WOCKET_SENSITIVITY:" + e.ToString());
                }

                kernelLock.Release();
            });
        }