public void Parse()
        {
            var frameList = new List <Frame>();

            using (var process = new TSharkProcess(new FrameListQuery(mParser.NetworkTrace.FullName, new[] { WSD_REQUEST_FILTER, WSD_RESPONSE_FILTER })))
            {
                frameList.AddRange(process.StandartOutput.ReadAllLines()
                                   .Select(line => line.Split('\t'))
                                   .Select(parts =>
                                           new Frame(int.Parse(parts[0]), mParser.NetworkTrace, parts[1], parts[2], String.Empty, String.Empty, "ws-discovery"))
                                   .Where(item => null != UnitSet.GetUnit(item.SourceMac)));
            }

            if (0 == frameList.Count)
            {
                return;
            }

            var frames = new List <String>();

            using (var process = new TSharkProcess(new WSDiscoveryQuery(frameList.Select(item => item.Number), mParser.NetworkTrace.FullName)))
            {
                frames.AddRange(process.StandartOutput.ReadAllLines().Select(HexToASCIIConverter.Convert));
            }

            var xmlList   = BuildXmlList(ref frames);
            var requests  = xmlList.Where(item => null != item.GetElementWithName("Probe")).ToList();
            var responses = xmlList.Where(item => null != item.GetElementWithName("ProbeMatches")).Distinct(new ProbeMatchesEqualityComparer()).ToList();

            var pairs = BuildPairs(frameList, xmlList, requests, responses);

            ProcessPairs(frameList, xmlList, pairs);
        }
Example #2
0
        protected void AddDevicesList(XElement doc)
        {
            String headerId = GetIdWithPostfix(ID_DEVICE_TABLE, 1);

            var deviceTableHeaderTemplate = XmlUtil.GetElementById(doc, headerId);
            var deviceTableTemplate       = deviceTableHeaderTemplate.NextNode as XElement;

            XElement lastElement = deviceTableTemplate;

            if (null == deviceTableTemplate)
            {
                throw new XmlException("device table does not exist");
            }

            var devices = UnitSet.GetDevices();
            int count   = 3 > devices.Count ? 3 : devices.Count;

            for (int i = 1; i < count; ++i)
            {
                var newHeader = new XElement(deviceTableHeaderTemplate);
                var newTable  = new XElement(deviceTableTemplate);

                ProcessDeviceHeader(newHeader, i + 1);
                ProcessDeviceTable(newTable, i + 1);

                lastElement.AddAfterSelf(newHeader);
                newHeader.AddAfterSelf(newTable);

                lastElement = newTable;
            }
        }
Example #3
0
        private void OnEnter()
        {
            String systemName = tBSystemName.Text.Trim();

            UnitSet.Merge(systemName, mClients);
            Close();
        }
Example #4
0
        private void btnRunConformance_Click(object sender, EventArgs e)
        {
            if (ApplicationState.Idle != StateManager.GetState())
            {
                return;
            }

            if (ConversationList.IsEmpty)
            {
                DialogHelper.ShowError(Resources.Message_Diagnostics_ConversationList_Empty);
                return;
            }

            var devices = UnitSet.GetDevices();

            if (devices.Any(item => !item.IsFeatureListAttached))
            {
                var result = DialogHelper.ShowWarning(Resources.Message_Diagnostics_FeatureList_NotAttached);

                if (DialogResult.Cancel == result)
                {
                    return;
                }
            }

            Clear();
            RunTests();
        }
        private void ProcessPairs(List <Frame> frameList, List <XElement> xmlList, IEnumerable <Tuple <XElement, XElement> > pairs)
        {
            foreach (var pair in pairs)
            {
                var requestFrame  = frameList[xmlList.IndexOf(pair.Item1)];
                var responseFrame = frameList[xmlList.IndexOf(pair.Item2)];

                var client = UnitSet.GetUnit(responseFrame.DestinationMac);
                var device = UnitSet.GetUnit(responseFrame.SourceMac);

                var conversation = ConversationList.Find(client, device);

                if (null == conversation)
                {
                    continue;
                }

                var request = new DiscoveryMessage(requestFrame, conversation, MessageType.Request);
                PackXml(pair.Item1, conversation, requestFrame, MessageType.Request);

                var response = new DiscoveryMessage(responseFrame, conversation, MessageType.Response);
                PackXml(pair.Item2, conversation, responseFrame, MessageType.Response);

                conversation.Add(new RequestResponsePair(request, response, mParser.NetworkTrace, conversation,
                                                         ContentType.WSDiscovery));
            }
        }
Example #6
0
        private void lVUnits_MouseClick(object sender, MouseEventArgs e) // TODO
        {
            if (MouseButtons.Right != e.Button)
            {
                return;
            }

            ListView lVSender = sender as ListView;

            if (null == lVSender)
            {
                return;
            }

            var selectedUnits = (from int index in lVSender.SelectedIndices
                                 select UnitSet.GetUnitAt(index)).ToList();

            if (selectedUnits.All(item => UnitType.Client == item.Type) && selectedUnits.Count > 1)
            {
                var menu = new ContextMenuStrip();
                menu.Items.Add("Merge");
                menu.Items[0].Click += (o, args) => new SystemCreatorForm(selectedUnits.Cast <Client>()).ShowDialog();
                menu.Show(sender as Control, e.Location);
            }
            else if (selectedUnits.All(item => UnitType.System == item.Type))
            {
                var menu = new ContextMenuStrip();
                menu.Items.Add("Split");
                menu.Items[0].Click += (o, args) => selectedUnits.Cast <ClientSystem>().ToList().ForEach(UnitSet.Split);
                menu.Show(sender as Control, e.Location);
            }
        }
Example #7
0
        /// <summary>
        ///   Called when selected index of lVUnits changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lVUnits_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (0 == lVUnits.SelectedIndices.Count)
            {
                ClearDeviceInfo();
                btnBrowseFeatureList.Enabled = false;
                mSelectedUnitIndex           = -1;
                return;
            }

            mSelectedUnitIndex = lVUnits.SelectedIndices[0];
            var selectedUnit = UnitSet.GetUnitAt(mSelectedUnitIndex) as BaseUnit;

            if (null == selectedUnit)
            {
                return;
            }

            bool isDevice = UnitType.Device == selectedUnit.Type;

            btnBrowseFeatureList.Enabled = isDevice;
            tBFeatureList.Enabled        = isDevice;

            tBNetworkTrace.Text = selectedUnit.GetTracesString();

            FillClientInfo(selectedUnit as Client);
            FillDeviceInfo(selectedUnit as Device);
        }
Example #8
0
 private void RemoveDeviceSpecificCommands()
 {
     if (UnitSet.GetDevices().Contains(mClient))
     {
         mRequestResponseList.RemoveAll(item => mDeviceSpecificCommands.Contains(item.Request.GetDetails()));
     }
 }
        private static void WriteDevicesList(XmlWriter writer) // TODO remove ???
        {
            writer.WriteStartElement("DeviceUsed");


            foreach (var device in UnitSet.GetDevices())
            {
                writer.WriteStartElement("DeviceInformation");
                writer.WriteElementString("MemberName", device.Manufacturer);
                writer.WriteElementString("ProductName", device.Name);
                writer.WriteElementString("FirmwareVersion", device.FirmwareVersion);

                writer.WriteStartElement("DeviceSupportedProfile");
                for (int i = 0; i < 3; i++)
                {
                    writer.WriteElementString("Profile", String.Empty);
                }
                writer.WriteEndElement();

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
            writer.WriteEndElement();
        }
Example #10
0
        public object calculate(CellExt1 cs, DataSet ds, Env env, string param)
        {
            UnitSet set;

            this.cs  = cs;
            this.ds  = ds;
            this.env = env;
            string str = (string)ConvertTool.getValue(new ExpParse(cs, ds, env, param).calculate());

            if ((str != null) && (str.Trim().Length > 0))
            {
                set = new UnitSet(Escape.removeEscAndQuote(str), true, '&');
            }
            else
            {
                set = new UnitSet("", true, '&');
            }
            string expStr = Escape.unescape(set["dataXml"]);
            object obj2   = ConvertTool.getValue(new ExpParse(cs, ds, env, expStr).calculate());

            this.pDataXml = (string)obj2;
            CellExt       current = cs.Current;
            StringBuilder sb      = new StringBuilder();
            object        obj3    = null;

            try
            {
                obj3 = this.cal(set, sb);
            }
            catch (Exception exception)
            {
                throw new ReportError("统计图计算异常:" + exception.Message.ToString().ToString(), exception);
            }
            return(obj3);
        }
Example #11
0
 private void method_6(string string_0, Report report_0)
 {
     string[] strArray = null;
     if (string_0 != null)
     {
         CellSet cs  = report_0.Cells;
         UnitSet seg = new UnitSet("dddd", ';');
         strArray = string_0.Split(new char[] { ';' });
         for (int i = 0; i < strArray.Length; i++)
         {
             if ((strArray[i] != null) && (strArray[i].Trim().Length > 0))
             {
                 string[] strArray2 = strArray[i].Split(new char[] { ':' });
                 if (!(strArray2[0] == "e_print_rate"))
                 {
                     CSReader._setMainProperty(cs, strArray2[0], strArray2[1], seg);
                 }
                 else
                 {
                     _float = Convert.ToSingle(strArray2[1]);
                 }
             }
         }
     }
 }
Example #12
0
        public static ValidateLogic FirstTestLogic()
        {
            ValidateLogic            VL  = new ValidateLogic();
            DeclareVariableStatement dvs = new DeclareVariableStatement("Times", typeof(INumber));
            SetVariableStatement     svs = new SetVariableStatement(new LongVar("Times"), new LongConst(0));
            Execute initialEx            = new Execute();

            initialEx.Statements.Add(dvs);
            initialEx.Statements.Add(svs);
            SetVariableStatement svs2 = new SetVariableStatement(new LongVar("Times"),
                                                                 new ArithmeticExpression(new LongVar("Times"), null, Operator.PlusOne));
            Execute           ex2      = new Execute(svs2);
            CompareExpression AtLeast2 = new CompareExpression(new LongVar("Times"), new LongConst(2), Operator.GreaterThanOrEqualTo);
            Area ar1 = new Area(null, null, VL);

            VL.Areas.Add(ar1);
            AreaStart ap1 = new AreaStart(ar1);

            VL.StartNode       = initialEx;
            initialEx.NextNode = ap1;

            CharsToIntegerPart stip = new CharsToIntegerPart();

            ar1.StartNode = stip;
            UnitSet us1 = new UnitSet(CharUnits.Comma);

            us1.Units.Add(CharUnits.WhiteSpace);
            stip.NextNode = us1;
            CharsToIntegerPart stip2 = new CharsToIntegerPart();

            us1.NextNode = stip2;
            UnitSet us2 = new UnitSet(CharUnits.WhiteSpace);

            stip2.NextNode = us2;
            CharsToIntegerPart stip3 = new CharsToIntegerPart();

            us2.NextNode   = stip3;
            stip3.NextNode = EndNode.Instance;

            UnitSet us3 = " CH".ToUnitSet();

            us3.Units.Add(CharUnits.AtoZ);
            Status st = new Status();

            ap1.NextNode = us3;
            UnitSet CRLF = "\r\n".ToUnitSet();

            st.Choices.Add(new Choice(CRLF));
            st.Choices.Add(new Choice(EndNode.Instance, AtLeast2));
            us3.NextNode  = st;
            CRLF.NextNode = ex2;
            ex2.NextNode  = ap1;
            //12, 56 70 CHA
            //08, 32 45 CHR
            //98, -3 45 CHD
            return(VL);
        }
        public async Task <InvokeResult> AddUnitSetAsync(UnitSet unitSet, EntityHeader org, EntityHeader user)
        {
            await AuthorizeAsync(unitSet, AuthorizeResult.AuthorizeActions.Create, user, org);

            ValidationCheck(unitSet, Actions.Create);
            await _unitSetRepo.AddUnitSetAsync(unitSet);

            return(InvokeResult.Success);
        }
        public async Task <InvokeResult> UpdateUnitSetAsync(UnitSet unitSet, EntityHeader org, EntityHeader user)
        {
            await AuthorizeAsync(unitSet, AuthorizeResult.AuthorizeActions.Update, user, org);

            ValidationCheck(unitSet, Actions.Update);
            unitSet.LastUpdatedBy   = user;
            unitSet.LastUpdatedDate = DateTime.Now.ToJSONString();
            await _unitSetRepo.UpdateUnitSetAsync(unitSet);

            return(InvokeResult.Success);
        }
Example #15
0
        protected override void HookUI()
        {
            conformanceInfoView.ClientUnderTest = UnitSet.GetClient();

            conformanceInfoView.ResetBindings();

            btnGenetateDoC.Enabled         = CheckIfDoCAvailable();
            btnGenerateFeatureList.Enabled = CheckIfFeatureListAvailable();

            conformanceLogView.Clear();
            conformanceLogView.Refresh();
        }
Example #16
0
        private bool CheckIfDoCAvailable()
        {
            mIsErrataModeEnabled = ConformanceLog.Instance.Errors.Values.Any(item => item.Any());
            btnGenetateDoC.Text  = mIsErrataModeEnabled ? DOC_ERRATA_BTN_CAPTION : DOC_BTN_CAPTION;

            bool isTestingDone = TestCaseSet.Instance.IsTestingDone;

            var deviceSupportedProfiles = UnitSet.GetSupportedProfiles();
            var clientSupportedProfiles = Enum.GetValues(typeof(Profile)).Cast <Profile>().Where(profile => profile.IsSupported());

            return(isTestingDone && (clientSupportedProfiles.Any() || deviceSupportedProfiles.Any()));
        }
Example #17
0
        public void Initialize()
        {
            if (Context.PreferencesChanged)
            {
                Context.AlgorithmsChanged = true;
                Context.Algorithms.Clear();
                UnitSet set1 = new UnitSet(Context.Participants.Where(x => x.Group == MarriageGroup.Group1).Select(x => x.ID));
                UnitSet set2 = new UnitSet(Context.Participants.Where(x => x.Group == MarriageGroup.Group2).Select(x => x.ID));

                Context.StableMarriage     = new StableMarriage(set1, set2, Context.Priorities);
                Context.PreferencesChanged = false;
            }
        }
Example #18
0
        protected EntityHeader <UnitSet> CreateUnitSet()
        {
            var unitSet = new UnitSet()
            {
                Id   = "unitset1",
                Key  = "abc123",
                Name = "MyUnitSet"
            };

            return(new EntityHeader <UnitSet>()
            {
                Id = unitSet.Id, Text = unitSet.Name, Value = unitSet
            });
        }
        private static void WriteClientInfo(XmlWriter writer)
        {
            writer.WriteStartElement("ClientInformation");

            Client client = UnitSet.GetClient();

            writer.WriteElementString("ProductName", client.Name);
            writer.WriteElementString("Brand", String.Empty);
            writer.WriteElementString("Model", String.Empty);
            writer.WriteElementString("Version", String.Empty);
            writer.WriteElementString("ProductType", String.Empty);

            writer.WriteEndElement();
        }
Example #20
0
        protected void FillDevicesList(XElement doc)
        {
            var devices = UnitSet.GetDevices();

            for (int i = 0; i < devices.Count; ++i)
            {
                var device       = devices[i];
                int deviceNumber = i + 1;

                ReplaceElementValue(doc, GetIdWithPostfix(ID_DEVICE_PRODUCT, deviceNumber), device.GetConformanceName());
                ReplaceElementValue(doc, GetIdWithPostfix(ID_DEVICE_MEMBER, deviceNumber), device.Info.Manufacturer ?? String.Empty);
                ReplaceElementValue(doc, GetIdWithPostfix(ID_DEVICE_FIRMWARE, deviceNumber), device.Info.FirmwareVersion ?? String.Empty);
                ReplaceElementValue(doc, GetIdWithPostfix(ID_DEVICE_PROFILE, deviceNumber), String.Join(", ", device.GetSupportedProfiles()));
            }
        }
Example #21
0
        private void btnGenerateFeatureList_Click(object sender, EventArgs e)
        {
            if (null == UnitSet.GetClient())
            {
                DialogHelper.ShowMessage("You must have client to generate Feature List xml");
                return;
            }

            if (!conformanceInfoView.IsInputValid)
            {
                DialogHelper.ShowError(Resources.Message_Some_mandatory_fields_are_invalid);
                return;
            }

            ShowFeatureListDialog();
        }
Example #22
0
        private void tCMain_Selecting(object sender, TabControlCancelEventArgs e)
        {
            if (UnitSet.GetClients().Count <= 1)
            {
                return;
            }

            if (2 == e.TabPageIndex || 3 == e.TabPageIndex)
            {
                DialogHelper.ShowError("Please select only one client for Conformance testing.\r\n" +
                                       "If you need to consider identified clients as a single system, please follow these steps:\r\n" +
                                       "1. Select multiple clients in the list using either Shift or Ctrl\r\n" +
                                       "2. Right click on selection and select Merge option");
                e.Cancel = true;
            }
        }
Example #23
0
        public void TestParse()
        {
            ValidateLogic VL = new ValidateLogic();
            UnitSet       us = new UnitSet(CharUnits.AtoZ);

            us.Units.Add(CharUnits.atoz);
            VL.StartNode = us;
            us.NextNode  = EndNode.Instance;

            string testString = "DJ";

            TinaValidator tv     = new TinaValidator(VL);
            bool          result = tv.Validate(testString.ToObjectList());

            TestContext.WriteLine(result.ToString());
            TestContext.WriteLine(tv.CreateRandomToString());
        }
Example #24
0
        /// <summary>
        ///  Called when item in the lVUnits checked
        /// </summary>
        private void lVUnits_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            if (mIsUnitListUpdating)
            {
                return;
            }

            if (e.Item.Index >= UnitSet.Count)
            {
                return;
            }

            IUnit selectedUnit = UnitSet.GetUnits()[e.Item.Index];

            selectedUnit.IsIgnored = !e.Item.Checked;

            UpdateUnitList();
        }
Example #25
0
        private void WriteDevicesList(XmlWriter writer) // TODO remove ???
        {
            writer.WriteStartElement("DeviceUsed");

            foreach (var device in UnitSet.GetDevices())
            {
                writer.WriteStartElement("DeviceInformation");
                writer.WriteElementString("MemberName", device.Info.Manufacturer);
                writer.WriteElementString("ProductName", device.GetConformanceName());
                writer.WriteElementString("FirmwareVersion", device.Info.FirmwareVersion);

                WriteDeviceSupportedProfiles(device, writer);

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Example #26
0
        public SubReportList(string cfgStr)
        {
            ArgToken token = new ArgToken(cfgStr, ';');
            int      num   = token.countTokens();

            this.arrayList_0 = new ArrayList(num);
            this.arrayList_1 = new ArrayList(num);
            this.arrayList_2 = new ArrayList(num);
            while (token.hasNext())
            {
                string str = token.next();
                if ((str != null) && (str.Trim().Length != 0))
                {
                    UnitSet set = new UnitSet(str, ',');
                    this.addRpt(set["name"], set["type"], smethod_0(set["address"]));
                }
            }
        }
Example #27
0
        /// <summary>
        /// Browse FeatureList button handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBrowseFeatureList_Click(object sender, EventArgs e)
        {
            DialogResult result = oFDFeatureList.ShowDialog();

            if (DialogResult.OK != result)
            {
                return;
            }

            IUnit unit = UnitSet.GetUnitAt(mSelectedUnitIndex);

            var device = unit as Device;

            if (null == device)
            {
                return;
            }

            device.FeatureList = oFDFeatureList.FileName;
            var deviceInfo = new DeviceFeatureListParser(device).GetDeviceInformation();

            if (!String.IsNullOrEmpty(device.Info.Model) && deviceInfo.Model != device.Info.Model)
            {
                var warningResult = DialogHelper.ShowWarning(Resources.Message_Device_Info_Different);

                if (warningResult == DialogResult.Cancel)
                {
                    device.FeatureList = String.Empty;
                    return;
                }
            }

            device.SetInformation(deviceInfo);

            tBFeatureList.Text = device.FeatureList;

            UpdateUnitList();

            lVUnits.Focus();
            lVUnits.Items[mSelectedUnitIndex].Selected = true;
        }
Example #28
0
        /// <summary>
        /// Initializes the population of Species
        /// </summary>
        /// <returns>async Task</returns>
        protected override void Initialization()
        {
            _population = new List <Species <double> >();
            for (int i = 0; i < Settings.Size; i++)
            {
                UnitSet participants1 = new UnitSet(_stableMarriage.Units1.OrderBy(x => _random.Next()));
                UnitSet participants2 = new UnitSet(_stableMarriage.Units2.OrderBy(x => _random.Next()));

                //Randomized solution
                Solution genes   = new Solution(participants1.Zip(participants2, (x, y) => new Tuple <int, int>(x, y)).ToList());
                double   fitness = CalculateFitness(genes);

                _population.Add(new Species <double>()
                {
                    Genes   = genes,
                    Fitness = fitness
                });
            }

            _population.OrderByDescending(x => x.Fitness);
        }
Example #29
0
        private UnitSet GetUnitSet()
        {
            var unitSet = new UnitSet();

            unitSet.CreatedBy       = EntityHeader.Create(Guid.NewGuid().ToId(), "dontcare");
            unitSet.CreationDate    = DateTime.Now.ToJSONString();
            unitSet.LastUpdatedBy   = unitSet.CreatedBy;
            unitSet.LastUpdatedDate = unitSet.CreationDate;
            unitSet.Name            = "MyStateSet";
            unitSet.Key             = "mykey";

            unitSet.Units.Add(new Unit()
            {
                Key = "unit1", Name = "Unit Number One", IsDefault = true, Abbreviation = "s"
            });
            unitSet.Units.Add(new Unit()
            {
                Key = "unit2", Name = "Unit Number Two", IsDefault = false, ConversionType = EntityHeader <ConversionTypes> .Create(ConversionTypes.Factor), Abbreviation = "s2", ConversionFactor = 1.5
            });

            return(unitSet);
        }
Example #30
0
        private void Check()
        {
            ConformanceLog.Instance.Clear();

            foreach (Profile profile in Enum.GetValues(typeof(Profile)))
            {
                var devices = UnitSet.GetDevices(profile);

                bool isProfileSupported = profile.IsSupported();
                if (!isProfileSupported && !devices.Any())
                {
                    ConformanceLog.Instance.AddWarning(profile, "0 devices found");
                    continue;
                }

                Check3Devices(profile, devices);

                if (isProfileSupported && !devices.Any())
                {
                    ConformanceLog.Instance.AddError(profile, "At least one Device Feature List is missing");
                }

                if (Profile.C == profile)
                {
                    if (FeatureStatus.Undefined == Feature.EventHandling.GetInfo().Status)
                    {
                        ConformanceLog.Instance.AddError(profile, "At least one Event Handling Feature Required");
                    }
                }

                CheckMandatoryTests(profile);
                CheckConditionalTests(profile);

                foreach (var device in devices)
                {
                    CheckDeviceSpecificTests(profile, device);
                }
            }
        }
 /// <summary>
 /// Gets a unit set corresponding to the referenced unit set.
 /// </summary>
 public IUnitSet GetUnitSetFor(UnitSetIdentity referencedUnitSet) {
   IUnitSet/*?*/ result = null;
   WeakReference/*?*/ entry;
   lock (GlobalLock.LockingObject) {
     if (this.unitSetCache.TryGetValue(referencedUnitSet, out entry)) {
       if (entry != null) result = entry.Target as IUnitSet;
     }
   }
   List<IUnit> units = new List<IUnit>();
   foreach (UnitIdentity unitId in referencedUnitSet.Units) {
     IUnit unit = this.LoadUnit(unitId);
     if (unit is Dummy) return Dummy.UnitSet;
     units.Add(unit);
   }
   if (result != null && UnitsAreTheSameObjects(units, result.Units))
     return result;
   lock (GlobalLock.LockingObject) {
     if (this.unitSetCache.TryGetValue(referencedUnitSet, out entry)) {
       if (entry != null) result = entry.Target as IUnitSet;
       if (result != null && UnitsAreTheSameObjects(units, result.Units)) return result;
     }
     result = new UnitSet(units);
     this.unitSetCache[referencedUnitSet] = new WeakReference(result);
   }
   return result;
 }
 public IfcUnitAssignment()
 {
     _units = new UnitSet(this);
 }