Example #1
0
        public void LoadSingleBurstDataTest()
        {
            string filePath = Path.GetFullPath(@"Support Files\WLAN Single Burst.tdms");

            SG.Waveform waveform = SG.LoadWaveformFromTDMS(filePath);

            //This value is known empirically from the waveform configuration
            double actualLength = 5.132112e-3;

            Assert.AreEqual(waveform.BurstLength_s, actualLength, 1e-6,
                            "Burst length should be properly calculated for a single-burst waveforms.");

            double papr;

            NIRfsgPlayback.ReadWaveformFileVersionFromFile(filePath, out string waveformVersion);
            if (waveformVersion == "1.0.0")
            {
                NIRfsgPlayback.ReadPeakPowerAdjustmentFromFile(filePath, 0, out papr);
            }
            else
            {
                NIRfsgPlayback.ReadPaprFromFile(filePath, 0, out papr);  //Version 2.0.0 and later
            }
            Assert.AreEqual(waveform.PAPR_dB, papr, .001,
                            "PAPR for a single-burst waveform should match what is reported by RFmx.");
        }
Example #2
0
        public void LoadMultiBurstDataTest()
        {
            string filePath = Path.GetFullPath(@"Support Files\LTE TDD Waveform.tdms");

            SG.Waveform waveform = SG.LoadWaveformFromTDMS(filePath);

            double actualLength = waveform.WaveformData.SampleCount / waveform.SampleRate;

            Assert.AreEqual(waveform.BurstLength_s, actualLength, 1e-9,
                            "Burst length should be properly calculated for multi-burst waveforms.");

            double papr;

            NIRfsgPlayback.ReadWaveformFileVersionFromFile(filePath, out string waveformVersion);
            if (waveformVersion == "1.0.0")
            {
                NIRfsgPlayback.ReadPeakPowerAdjustmentFromFile(filePath, 0, out papr);
            }
            else
            {
                NIRfsgPlayback.ReadPaprFromFile(filePath, 0, out papr);  //Version 2.0.0 and later
            }
            Assert.AreEqual(waveform.PAPR_dB, papr, .001,
                            "PAPR for a multi-burst waveform should match what is reported by RFmx.");
        }
Example #3
0
 /// <summary>
 /// Creates a new RNG instance seeded with the system tick count.
 /// </summary>
 public RNG()
 {
     _root = new SG(Environment.TickCount, 0);
     _tree = new List <SG> {
         _root
     };
 }
        private void UpdateWindow(SG sg)
        {
            if (sg == SG.set)
            {
                if (Path.STgtImg != "")
                {
                    TextBox_TgtImgDir.Text = Path.STgtImg;
                }
                if (Path.SSrcDir != "")
                {
                    TextBox_SecImgDir.Text = Path.SSrcDir;
                }
                if (Path.SDstImg != "")
                {
                    TextBox_DstImgDir.Text = Path.SDstImg;
                }
                CheckBox_SubDir.IsChecked = BUseSubDir;
            }
            else
            {
                Path.STgtImg = TextBox_TgtImgDir.Text;
                Path.SSrcDir = TextBox_SecImgDir.Text;
                Path.SDstImg = TextBox_DstImgDir.Text;
                BUseSubDir   = (bool)CheckBox_SubDir.IsChecked;
            }

            if (Path.SSrcDir != "")
            {
                UpdateWindow_SecImgDir();
            }
        }
Example #5
0
        public async Task <JsonResult> StreamGriddler([FromBody] SG data)
        {
            (Item[][] R, Item[][] C) = (new Item[][] { }, new Item[][] { });

            //inputs
            (R, C) = await Library.Library.GetSourceData(data.sG);

            //outputs
            //Logic.RunAsStream(R, C);
            Logic.RunAsStream(R, C, async(Point Pt) =>
            {
                //signalr
                await HubContext.Clients.All.SendPoint(Pt);
            });

            var RetVal = new
            {
                w = C.Length,
                h = R.Length,
                d = Math.Max(C.Max(m => m.Length), R.Max(m => m.Length)),
                R,
                C
            };

            return(Json(RetVal));
        }
Example #6
0
 /// <summary>
 /// Creates a new RNG instance with the specified seed.
 /// </summary>
 /// <param name="seed">The seed for the generator.</param>
 public RNG(long seed)
 {
     _root = new SG(seed, 0);
     _tree = new List <SG> {
         _root
     };
 }
Example #7
0
    // Initialize the number of bullets before game starts
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        playerAudio = GetComponent <AudioSource>();
        pellets     = new List <Quaternion>(pelletCount);
        //pooledObjects = new List<GameObject>(amountToPool);

        // Initalize the pellets
        for (int i = 0; i < pelletCount; i++)
        {
            pellets.Add(Quaternion.Euler(Vector3.zero));

            //float xSpread = Random.Range(-1,1);
            //float ySpread = Random.Range(-1,1);
            //float zSpread = Random.Range(-1, 1);
            //normalize the spread vector to keep it conical
            //Vector3 spread = new Vector3(xSpread, ySpread, zSpread).normalized * coneSize;
            //Quaternion rotation = Quaternion.Euler(spread) * BarrelExit.rotation;
            //GameObject obj = (GameObject)Instantiate(objectToPool, BarrelExit.position, rotation);
            //obj.SetActive(false);
            //pooledObjects.Add(obj);
        }

        // Set the gun and ammo to be initially red
        updateGunColorEnum(ColorEnum.Red);
    }
Example #8
0
 private void autoSelectSecurityGroups(XElement SecurityGroupsDNs)
 {
     SGList.ClearSelected();
     if (SecurityGroupsDNs == null)
     {
         return;
     }
     foreach (XElement SGDNs in SecurityGroupsDNs.Elements("SecurityGroupDN"))
     {
         XElement SGs = Config.Current.Element("SecurityGroups");
         if (SGs == null)
         {
             continue;
         }
         foreach (XElement SG in SGs.Elements("SecurityGroup"))
         {
             XElement Name = SG.Element("Name");
             XElement DN   = SG.Element("DistinguishedName");
             if (Name == null || DN == null)
             {
                 continue;
             }
             if (DN.Value == SGDNs.Value)
             {
                 SGList.SelectedItems.Add(Name.Value);
             }
         }
     }
 }
Example #9
0
        private void CommitTestConfiguration(NIRfsg rfsg, RFmxInstrMX instr)
        {
            SG.DownloadWaveform(rfsg, lteTdd10Waveform);
            SG.ConfigureContinuousGeneration(rfsg, lteTdd10Waveform);

            var lteCommonConfig = CommonConfiguration.GetDefault();

            string instrumentModel = rfsg.Identity.InstrumentModel;

            if (Regex.IsMatch(instrumentModel, "NI PXIe-5830"))
            {
                lteCommonConfig.SelectedPorts      = "if1";
                lteCommonConfig.CenterFrequency_Hz = 6.5e9;
            }
            else if (Regex.IsMatch(instrumentModel, "NI PXIe-5831"))
            {
                lteCommonConfig.SelectedPorts      = "rf1/port0";
                lteCommonConfig.CenterFrequency_Hz = 28e9;
            }
            var lte = instr.GetLteSignalConfiguration();

            RFmxLTE.ConfigureCommon(lte, lteCommonConfig);
            RFmxLTE.ConfigureStandard(lte, RFmxLTE.StandardConfiguration.GetDefault());
            RFmxLTE.ConfigureModAcc(lte, RFmxLTE.ModAccConfiguration.GetDefault());

            lte.Commit("");
            rfsg.Utility.Commit();
        }
Example #10
0
 /// <summary>
 /// Creates a new RNG instance with the specified seed and generation.
 /// </summary>
 /// <param name="seed">The seed for the generator.</param>
 /// <param name="generation">The generation to start at.</param>
 public RNG(long seed, long generation)
 {
     _root = new SG(seed, generation);
     _tree = new List <SG> {
         _root
     };
 }
Example #11
0
        public override Task <Empty> AbortGeneration(RfsgServiceTimeout request, ServerCallContext context)
        {
            var rfsg = sessionMap[(IntPtr)request.Session.Handle];

            SG.AbortGeneration(rfsg, request.TimeoutMs);
            return(Task.FromResult(new Empty()));
        }
Example #12
0
 internal V_SG(SeamlessViewsContext Context, SG SG)
     : base(Context)
 {
     _SGKEY             = SG.SGKEY;
     _TITLE             = SG.TITLE;
     _ADULT_RESPONSIBLE = SG.ADULT_RESPONSIBLE;
 }
Example #13
0
        private void ApplyAutomaticLOConfiguration(NIRfsg rfsg, RFmxInstrMX instr)
        {
            SG.InstrumentConfiguration sgConfig = SG.InstrumentConfiguration.GetDefault(rfsg);
            SG.ConfigureInstrument(rfsg, sgConfig);

            RFmxInstr.InstrumentConfiguration instrConfig = RFmxInstr.InstrumentConfiguration.GetDefault();
            RFmxInstr.ConfigureInstrument(instr, instrConfig);
        }
Example #14
0
 void ReplaceFacingNode(SG e, DN replacer)
 {
     if (!replacer.Contains(e))
     {
         return;
     }
     neighbor = neighbor.Select(n => n.Contains(e) ? replacer : n).ToList();
 }
Example #15
0
 DN GetFacingNode(SG e)
 {
     if (!Contains(e))
     {
         return(null);
     }
     return(neighbor.Find(n => n.Contains(e)));
 }
 public void IdleDurationCalculatedCorrectly()
 {
     LoopFiles((fileName, waveform, filePath, fileConfig) =>
     {
         string idle      = fileConfig["TestData"]["IdleDuration"];
         bool idlePresent = bool.Parse(idle);
         SG.DownloadWaveform(sim, waveform);
         waveform.IdleDurationPresent.Should().Be(idlePresent, $"of knowledge of file \"{fileName}\"");
     });
 }
Example #17
0
            public override string ToString()
            {
                string msg = "";

                for (int i = 0; i < Characters.Count; i++)
                {
                    if (Characters[i] is SystemGroup SG && SG.Action == System.RUBY)
                    {
                        msg += SG.ToRubyString();
                    }
Example #18
0
        void SetNeighborWhenFlip(SG e, DN trgt)
        {
            var pair = trgt.GetFacingNode(e);

            if (pair != null)
            {
                this.neighbor.Add(pair);
                pair.ReplaceFacingNode(e, this);
            }
        }
Example #19
0
        private void ApplyNoLOSharingConfiguration(NIRfsg rfsg, RFmxInstrMX instr)
        {
            SG.InstrumentConfiguration sgConfig = SG.InstrumentConfiguration.GetDefault(rfsg);
            sgConfig.LOSharingMode = LocalOscillatorSharingMode.None;
            SG.ConfigureInstrument(rfsg, sgConfig);

            RFmxInstr.InstrumentConfiguration instrConfig = RFmxInstr.InstrumentConfiguration.GetDefault();
            instrConfig.LOSharingMode = LocalOscillatorSharingMode.None;
            RFmxInstr.ConfigureInstrument(instr, instrConfig);
        }
Example #20
0
        public async Task <JsonResult> GetTreeTest([FromBody] SG data)
        {
            (Item[][] R, Item[][] C) = (new Item[][] { }, new Item[][] { });

            //inputs
            (R, C) = await Library.Library.GetSourceData(data.sG);

            Tree Tree = Logic.CreateTree2(R, C);

            return(Json(Tree.Root));
        }
Example #21
0
 public void Do()
 {
     if (SG.CanGenerate())
     {
         ISP.Print(SG.Result);
     }
     else
     {
         IFP.Print();
     }
 }
Example #22
0
        void SetNeighbors(DN trgt, V2 p1, V2 p2)
        {
            var edge = new SG(p1, p2);
            var pair = GetFacingNode(edge);

            if (pair != null)
            {
                trgt.neighbor.Add(pair);
                pair.ReplaceFacingNode(edge, trgt);
            }
        }
Example #23
0
        public override Task <Empty> ConfigureContinuousGeneration(RfsgServiceGenerationConfiguration request, ServerCallContext context)
        {
            var      rfsg = sessionMap[(IntPtr)request.Session.Handle];
            Waveform wfm  = new Waveform()
            {
                Name = request.WaveformName,
            };

            SG.ConfigureContinuousGeneration(rfsg, wfm, request.MarkerEventExportTerminal);
            return(Task.FromResult(new Empty()));
        }
Example #24
0
            public override DynamicMetaObject FallbackGetMember(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
            {
                if (target != null && errorSuggestion == null)
                {
                    string     exceptionMessage = SG.GetString(SR.DynamicPropertyNotDefined, target.LimitType, this.Name);
                    Expression throwExpression  = Expression.Throw(Expression.Constant(new InvalidOperationException(exceptionMessage)), typeof(object));

                    errorSuggestion = new DynamicMetaObject(throwExpression, target.Restrictions);
                }

                return(errorSuggestion);
            }
Example #25
0
        bool FindNodes(SG s, out DN n1, out DN n2)
        {
            var o = nodes.FindAll(n => n.Contains(s));

            if (o.Count == 2)
            {
                n1 = o[0]; n2 = o[1]; return(true);
            }
            else
            {
                n1 = n2 = default;   return(false);
            }
        }
        public bool Intersects(SG e, out d3 p, out bool isOnEdge)
        {
            if (!CramersLow(e.a, normalize(e.b - e.a), out d3 d, out p))
            {
                isOnEdge = default;
                return(false);
            }
            bool f1 = d.x >= 0 && d.x <= 1 && d.y >= 0 && d.y <= 1 && d.x + d.y <= 1;
            bool f2 = d.z >= 0 && d.z <= length(e.b - e.a);

            isOnEdge = d.x == 0 || d.x == 1 || d.y == 0 || d.y == 1 || d.x + d.y == 1;
            return(f1 && f2);
        }
Example #27
0
        /// <summary>Scales the envelope waveform data based on the settings in <paramref name="trackerConfig"/>, and downloads the waveform to the envelope generator.</summary>
        /// <param name="envVsg">The open RFSG session to configure.</param>
        /// <param name="envelopeWaveform">The envelope waveform created by <see cref="CreateDetroughEnvelopeWaveform(Waveform, DetroughConfiguration)"/> or
        /// <see cref="CreateLookUpTableEnvelopeWaveform(Waveform, LookUpTableConfiguration)"/> that is to be generated.</param>
        /// <param name="trackerConfig">The common settings pertaining to the tracker that is used to modulate the power supply voltage.</param>
        /// <returns>The envelope waveform with data scaled according to the tracker configuration.</returns>
        public static Waveform ScaleAndDownloadEnvelopeWaveform(NIRfsg envVsg, Waveform envelopeWaveform, TrackerConfiguration trackerConfig)
        {
            // grab the raw envelope so we can use linq to get statistics on it
            ComplexSingle.DecomposeArray(envelopeWaveform.Data.GetRawData(), out float[] envelope, out _);

            // scale envelope to adjust for tracker gain and offset
            for (int i = 0; i < envelope.Length; i++)
            {
                envelope[i] = (float)((envelope[i] - trackerConfig.OutputOffset_V) / trackerConfig.Gain_VperV);
            }

            // clone an envelope waveform to return to the user - want unique waveforms per tracker configuration
            Waveform scaledEnvelopeWaveform = envelopeWaveform;

            scaledEnvelopeWaveform.Data = envelopeWaveform.Data.Clone();
            WritableBuffer <ComplexSingle> scaledEnvelopeWaveformBuffer = scaledEnvelopeWaveform.Data.GetWritableBuffer();

            // populate cloned waveform with scaled waveform data
            for (int i = 0; i < envelope.Length; i++)
            {
                scaledEnvelopeWaveformBuffer[i] = ComplexSingle.FromSingle(envelope[i]);
            }

            // get peak of the waveform
            float absolutePeak = envelope.Max(i => Math.Abs(i)); // applies the absolute value function to each element and returns the max

            // scale waveform to peak voltage
            for (int i = 0; i < envelope.Length; i++)
            {
                envelope[i] = envelope[i] / (absolutePeak); // brings waveform down to +/- 1 magnitude
            }
            // set instrument properties
            envVsg.IQOutPort[""].Level  = 2.0 * absolutePeak; // gain is interpreted as peak-to-peak
            envVsg.IQOutPort[""].Offset = 0.0;                // set offset to 0 since this is done in DSP not in HW on the 5820 and only clips the waveform further

            // create another waveform that we can use to download the scaled envelope to the instrument
            Waveform instrEnvelopeWaveform = envelopeWaveform;

            instrEnvelopeWaveform.Data = envelopeWaveform.Data.Clone();
            WritableBuffer <ComplexSingle> instrEnvelopeWaveformBuffer = instrEnvelopeWaveform.Data.GetWritableBuffer();

            // populate cloned waveform with scaled waveform data
            for (int i = 0; i < envelope.Length; i++)
            {
                instrEnvelopeWaveformBuffer[i] = ComplexSingle.FromSingle(envelope[i]);
            }

            SG.DownloadWaveform(envVsg, instrEnvelopeWaveform); // download optimized waveform

            return(scaledEnvelopeWaveform);                     // return the waveform as it will appear coming out of the front end of the envelope generator
        }
Example #28
0
 public override void Single()
 {
     if (GeneTestSetup.Instance.IsSimulated)
     {
     }
     else
     {
         SG.ResetInterface();
         SG.Freq         = Freq;
         SG.PowerLevel   = PowerLevel;
         SG.OutputEnable = OutputEnable;
         (SG as InstruDriver).Wait(3000);
     }
 }
Example #29
0
        public void TriangleTest()
        {
            var t1 = new TR(new f2(0, 0), new f2(1, 0), new f2(0, 1));
            var s1 = new SG(new f2(0, 0), new f2(0, 1));
            var s2 = new SG(new f2(0, 1), new f2(1, 0));
            var s3 = new SG(new f2(1, 0), new f2(0, 0));

            Assert.IsTrue(t1.Contains(s1));
            Assert.IsTrue(t1.Contains(s2));
            Assert.IsTrue(t1.Contains(s3));
            Assert.IsTrue(t1.RemainingPoint(s3).Equals(t1.c));
            Assert.IsTrue(t1.RemainingPoint(s2).Equals(t1.a));
            Assert.IsTrue(t1.RemainingPoint(s1).Equals(t1.b));
        }
Example #30
0
        public override Task <Empty> ConfigureInstrument(RfsgServiceInstrumentConfiguration request, ServerCallContext context)
        {
            var rfsg        = sessionMap[(IntPtr)request.Session.Handle];
            var instrConfig = new SG.InstrumentConfiguration()
            {
                CarrierFrequency_Hz      = request.CarrierFrequencyHz,
                DutAverageInputPower_dBm = request.DutAverageInputPowerDBm,
                ExternalAttenuation_dB   = request.ExternalAttenuationDB,
                ReferenceClockSource     = request.ReferenceClockSource,
                SelectedPorts            = request.SelectedPorts,
                LOSharingMode            = (LocalOscillatorSharingMode)request.LOSharingMode
            };

            SG.ConfigureInstrument(rfsg, instrConfig);
            return(Task.FromResult(new Empty()));
        }
Example #31
0
        // SEARCH PAGE RESULTS NEXT PAGE
        public bool? getAuthorsNextPage(string this_url, ref SG.Author author, ref string next_url)
        {
            setts = setRecords.ReadSettings();
            int maxResults = setts.GSMaxResults;
            int num = author.getNumberOfPapers();
            if (num >= maxResults) return false;

            // CONNECTIONS
            if (this_url == null) return false;
            HtmlWeb web = new HtmlWeb();

            try
            {
                doc = web.Load(this_url);
            }
            catch (Exception e) {
                return null;
            }

            //Console.WriteLine(doc.DocumentNode.InnerHtml);

            string xpath = "//div[@class=\"gs_ri\"]";
            string title, titleLink, authors, publication, publisher, cited_by_url, summary;
            int year, rank = author.getNumberOfPapers() + 1, no_of_citations;
            HtmlNodeCollection searchResults = doc.DocumentNode.SelectNodes(xpath);
            if (searchResults == null)
            {
                if (checkForCaptcha())
                {
                    Console.WriteLine("Captcha problem ...");
                    return null;
                }
                Console.WriteLine("No results ...");
                return false;
            }
            else
            {
                //Console.WriteLine(url);
                foreach (HtmlNode n in searchResults)
                {

                    // TITLE AND TITLE LINK
                    HtmlNode child = n.SelectSingleNode(".//*[@class=\"gs_rt\"]");
                    title = child.InnerText;
                    titleLink = "";
                    HtmlNode url_node = child.SelectSingleNode(".//a");
                    if (url_node != null)
                    {
                        titleLink = url_node.GetAttributeValue("href", "");
                        if (!titleLink.Equals(""))
                        {
                            //titleLink = "http://scholar.google.com" + titleLink;
                            titleLink = titleLink.Replace("amp;", "");
                        }
                    }
                    // AUTHORS AND PUBLICATION
                    child = n.SelectSingleNode(".//*[@class=\"gs_a\"]");
                    authors = "";
                    publication = "";
                    publisher = "";
                    year = 1970;
                    if (child != null)
                    {
                        string[] names = child.InnerText.Split('-');
                        if (names.Length == 1) authors = names[0];
                        else if (names.Length == 2)
                        {
                            authors = names[0];
                            bool flag = false;
                            names[1].Trim();
                            try { year = Convert.ToInt32(names[1]); }
                            catch (FormatException fe) { flag = true; }
                            if (flag)
                            {
                                string[] p = names[1].Split(',');
                                try { year = Convert.ToInt32(p[1]); }
                                catch (Exception e) { }
                                publication = p[0];
                            }
                        }
                        else
                        {
                            authors = names[0];
                            publisher = names[2];
                            bool flag = false;
                            names[1].Trim();
                            try { year = Convert.ToInt32(names[1]); }
                            catch (FormatException fe) { flag = true; }
                            if (flag)
                            {
                                string[] p = names[1].Split(',');
                                try { year = Convert.ToInt32(p[1]); }
                                catch (Exception e) { }
                                publication = p[0];
                            }
                        }
                    }

                    // SUMMARY
                    child = n.SelectSingleNode(".//*[@class=\"gs_rs\"]");
                    summary = "";
                    if (child != null)
                    {
                        summary = child.InnerText;
                    }

                    // CITATION STUFF
                    no_of_citations = 0;
                    cited_by_url = "";
                    child = n.SelectSingleNode(".//*[@class=\"gs_fl\"]");
                    if (child != null) child = child.FirstChild;
                    if (child != null)
                    {
                        string text = child.InnerText;

                        try
                        {
                            text = text.Replace("Cited by", "");
                            text = text.Trim();
                            no_of_citations = Convert.ToInt32(text);
                        }
                        catch (Exception e) { }

                        cited_by_url = no_of_citations != 0 ? child.GetAttributeValue("href", "") : "";
                        if (!cited_by_url.Equals(""))
                        {
                            cited_by_url = "http://scholar.google.com" + cited_by_url;
                            cited_by_url = cited_by_url.Replace("amp;", "");
                        }

                    }

                    publisher.Trim();
                    publication.Trim();
                    if (num == maxResults) return false;
                    SG.Paper paper = new SG.Paper(title, titleLink, authors, summary, year, publication, publisher, no_of_citations, cited_by_url, rank);
                    author.addPaper(paper);
                    num++;
                    rank++;
                }

                //NEXT PAGE URL
                HtmlNode bottom = doc.DocumentNode.SelectSingleNode(".//*[@id=\"gs_n\"]//table//td[@align=\"left\"]//a");
                if (bottom != null)
                {
                    string url = bottom.GetAttributeValue("href", "");
                    if (!url.Equals(""))
                    {
                        url = "http://scholar.google.com" + url;
                        url = url.Replace("amp;", "");
                        next_url = url;
                    }
                    else next_url = null;
                }
                else next_url = null;

            }
            return true;
        }
Example #32
0
        // SUGGESTIONS FROM NEXT PAGE
        public bool getAuthSuggestionsNextPage(string this_url,ref SG.AuthSuggestion suggestions,ref string next_URL)
        {
            if (this_url == null) return false;

            List<string> names = new List<string>();
            List<string> links = new List<string>();

            names = suggestions.getSuggestions();
            links = suggestions.getSuggestionsURL();
            /*
            if (latestSearch.Equals("default") || (!latestSearch.Equals(authName)))
            {
                loadHtmlDocument(authName);
            }

            // DID U MEAN TAG
            string xpath = "//*[@class=\"gs_med\"]";
            HtmlNode dymNode = doc.DocumentNode.SelectSingleNode(xpath);

            if (dymNode != null)
            {
                Console.WriteLine("\nDID YOU MEAN TAG ");
                Console.WriteLine(dymNode.InnerText);
            }
            */

            // CONNECTIONS
            HtmlWeb web = new HtmlWeb();
            try
            {
                doc = web.Load(this_url);
            }
            catch (Exception e) { return false; }

            string profiles_url = null;
            string xpath = "//*[@class=\"cit-dark-large-link\"]";
            //string xpath = "//*[@class=\"\"]";
            HtmlNodeCollection profileNode = doc.DocumentNode.SelectNodes(xpath);
            if (profileNode != null)
            {
                foreach (HtmlNode urlNode in profileNode)
                {
                    //HtmlNode urlNode = node.SelectSingleNode(".//a");
                    if (urlNode != null)
                    {
                        profiles_url = urlNode.GetAttributeValue("href", "");
                        names.Add(urlNode.InnerText);
                        if (!profiles_url.Equals(""))
                        {
                            profiles_url = "http://scholar.google.com" + profiles_url;
                            profiles_url = profiles_url.Replace("amp;", "");
                        }
                        links.Add(profiles_url);
                    }
                }
            }
            else return false;

            //NEXT PAGE URL EXTRACTION
            HtmlNode next = doc.DocumentNode.SelectSingleNode("//*[@class=\"g-section cit-dgb\"]//tr/td[2]/a[2]");
            if (next != null)
            {
                next_URL = next.Attributes["href"].Value;
                next_URL = "http://scholar.google.com" + next_URL;
                next_URL = next_URL.Replace("amp;", "");
            }
            else next_URL = null;

            return true;
        }
Example #33
0
 /// <summary>
 /// 测试数据连接
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void OnTestConnect(SG.Interfaces.IButtonInfo sender)
 {
     if(txtServer.Text==string.Empty)
     {
         Msg.Warning("请输入服务器名!");
         txtServer.Focus();
     }
     if(txtUserName.Text==string.Empty)
     {
         Msg.Warning("请输入用户名!");
         txtUserName.Focus();
     }
     string sType = txtDbType.GetColumnValue("Sign").ToString();  //tblDataType.Rows[txtDbType.SelectionLength]["Sign"].ToString();
     if (bllComDataBaseTool.TestConnection(sType, txtServer.Text, lookUpDataBase.Text, txtUserName.Text, txtPwd.Text))
     {
         Msg.ShowInformation("测试成功!");
         IsTestOK = true;
     }
     else
     {
         Msg.Warning("测试失败!");
         IsTestOK = false;
     }
 }
        public bool getAuthStatisticsNext(string authid, ref SG.Author auth)
        {
            Request requestPaper = new Request();
            requestPaper.AppID = "c49b4e59-08dd-4f27-a53b-53cc72f169af";
            int stIndex, EndIndex;

            stIndex = auth.getNumberOfPapers() + 1;
            EndIndex = auth.getNumberOfPapers() + 100;

            requestPaper.ResultObjects = ObjectType.Publication;
            requestPaper.AuthorID = Convert.ToUInt32(authid);
            requestPaper.StartIdx = Convert.ToUInt32(stIndex);
            requestPaper.EndIdx = Convert.ToUInt32(EndIndex);

            List<SG.Paper> papers = generatePaper(requestPaper, 100, auth.getNumberOfPapers());

            for (int i = 0; i < papers.Count; i++)
            {
                auth.addPaper(papers[i]);
            }

            if (papers.Count < 100)
                return false;
            else
                return true;
        }
Example #35
0
		/// <summary>
		/// Creates a new RNG instance seeded with the system tick count.
		/// </summary>
		public SPRNG()
		{
			_root = new SG(Environment.TickCount, 0);
			_tree = new List<SG> { _root };
		}
Example #36
0
		/// <summary>
		/// Creates a new RNG instance with the specified seed and generation.
		/// </summary>
		/// <param name="seed">The seed for the generator.</param>
		/// <param name="generation">The generation to start at.</param>
		public SPRNG(long seed, long generation)
		{
			_root = new SG(seed, generation);
			_tree = new List<SG> { _root };
		}
Example #37
0
		/// <summary>
		/// Creates a new RNG instance with the specified seed.
		/// </summary>
		/// <param name="seed">The seed for the generator.</param>
		public SPRNG(long seed)
		{
			_root = new SG(seed, 0);
			_tree = new List<SG> { _root };
		}
        public bool getJournalsNext(string journalName, string ISSN, string keywords, ref SG.Journal journ)
        {
            Request requestJournal = new Request();
            requestJournal.AppID = "c49b4e59-08dd-4f27-a53b-53cc72f169af";
            //Response response;
            int stIndex, EndIndex;
            stIndex = journ.getNumberOfPapers() + 1;
            EndIndex = journ.getNumberOfPapers() + 100;

            requestJournal.ResultObjects = ObjectType.Publication;
            requestJournal.JournalQuery = journalName;

            //requestJournal.FulltextQuery = keywords;

            requestJournal.StartIdx = Convert.ToUInt32(stIndex);
            requestJournal.EndIdx = Convert.ToUInt32(EndIndex);

            List<SG.Paper> papers = generatePaper(requestJournal, 100, journ.getNumberOfPapers());

            for (int i = 0; i < papers.Count; i++)
            {
                journ.addPaper(papers[i]);
            }

            if (papers.Count < 100)
                return false;
            else
                return true;
        }
 public override bool Update(SG.Common.UpdateType updateType)
 {
     return true;
 }
Example #40
0
 public bool? getAuthStatisticsNextPage(string authUrl, ref SG.Author author)
 {
     bool isOK = true;
     setts = setRecords.ReadSettings();
     int maxResults = setts.GSMaxResults;
     int num = author.getNumberOfPapers();
     if (num < 0) return false;
     if (num % 100 != 0) return false;
     if (num >= maxResults) return false;
     authUrl += ("&pagesize=100&cstart=" + num);
     GSAuthScraper authScraper = new GSAuthScraper(authUrl, num, ref isOK);
     if (!isOK) return null;
     List<SG.Paper> papers = authScraper.getPapersOfCurrentPage();
     if (papers == null) return null;
     if (papers.Count == 0) return false;
     foreach (SG.Paper paper in papers)
     {
         if (num == maxResults) return false;
         author.addPaper(paper);
         num++;
     }
     return true;
 }