Example #1
0
        /// <summary>
        /// Reads previous reading and prepares next reading for specified channel
        /// </summary>
        /// <param name="channelToCharge">Channel to prepare</param>
        /// <returns>10 bit value corresponding to relative voltage level on channel</returns>
        public int ReadPreviousAndChargeChannel(Channel channelToCharge)
        {
            if (!IsValidChannel(channelToCharge))
            {
                throw new ArgumentOutOfRangeException(nameof(channelToCharge));
            }

            Span <byte> readBuffer  = stackalloc byte[2];
            Span <byte> writeBuffer = stackalloc byte[2];

            writeBuffer[0] = (byte)((int)channelToCharge << 1);
            _spiDevice.TransferFullDuplex(writeBuffer, readBuffer);

            int previousReading = ((readBuffer[0] & 0b11111) << 5) | (readBuffer[1] & 0b11111);

            if (_endOfConversion != -1)
            {
                // Wait for ADC to report end of conversion or timeout at max conversion time
                _controller.WaitForEvent(_endOfConversion, PinEventTypes.Rising, _conversionTime);
            }
            else
            {
                // Max conversion time (21us) as seen in table on page 10 in TLC1543 documentation
                DelayHelper.Delay(_conversionTime, false);
            }

            return(previousReading);
        }
Example #2
0
        /// <summary>
        /// Reads sensor value in Fast Mode 1 (10 clock transfer using !chipSelect)
        /// <remarks>
        /// <br>1 cycle used - gets data on second call of this method</br>
        /// <br>First cycle: Ask for value on the channel</br>
        /// </remarks>
        /// </summary>
        /// <param name="channelNumber">Channel to read</param>
        /// <returns>10 bit value corresponding to relative voltage level on channel</returns>
        public int Read(int channelNumber)
        {
            int value = 0;

            switch (_protocol)
            {
            case CommunicationProtocol.Gpio:
                _digital.Write(_chipSelect, 0);
                for (int i = 0; i < 10; i++)
                {
                    if (i < 4)
                    {
                        // send 4-bit Address
                        if ((channelNumber >> (3 - i) & 0x01) != 0)
                        {
                            _digital.Write(_address, 1);
                        }
                        else
                        {
                            _digital.Write(_address, 0);
                        }
                    }

                    // read 10-bit data
                    value <<= 1;
                    if (_digital.Read(_dataOut) == PinValue.High)
                    {
                        value |= 0x01;
                    }

                    _digital.Write(_inputOutputClock, 1);
                    _digital.Write(_inputOutputClock, 0);
                }
                _digital.Write(_chipSelect, 1);
                break;

            case CommunicationProtocol.SoftSpi:
                writeBuffer = new byte[2] {
                    Convert.ToByte((channelNumber & 0b0000_1111) << 4), 0
                };
                readBuffer = new byte[2];
                var SoftSpi = (SoftwareSpi)_spi;
                SoftSpi.TransferFullDuplex(writeBuffer, readBuffer);
                value  = (readBuffer[0] & 0b1111_1111) << 2;
                value |= (readBuffer[1] & 0b1100_0000) >> 6;
                value &= 0b0011_1111_1111;
                break;

            case CommunicationProtocol.HardSpi:
                writeBuffer = new byte[2] {
                    Convert.ToByte((channelNumber & 0b0000_1111) << 4), 0
                };
                readBuffer = new byte[2];
                var HardSpi = (SpiDevice)_spi;
                HardSpi.TransferFullDuplex(writeBuffer, readBuffer);
                value  = (readBuffer[0] & 0b1111_1111) << 2;
                value |= (readBuffer[1] & 0b1100_0000) >> 6;
                value &= 0b0011_1111_1111;
                break;

            default:
                break;
            }
            DelayHelper.Delay(_conversionTime, false);
            return(value);
        }
        public void VisitTicketLinksTab(TimeTask task)
        {
            var url = string.Format(ConfigurationManager.AppSettings["ResourcePage"], this.TicketId);

            //driver.Navigate().Refresh();
            //driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(60);
            driver.Navigate().GoToUrl(url);



            //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
            //Console.WriteLine("source");
            //Console.WriteLine(driver.PageSource);
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));

            wait.Until(d => d.FindElement(By.ClassName("TitleText")).GetAttribute("innerHTML").Contains(this.TicketId.ToString()));
            Console.WriteLine("working id {0}", driver.FindElement(By.ClassName("TitleText")).GetAttribute("innerHTML"));



            var labelHolders = driver.FindElements(By.ClassName("ValueLabelHolder"));


            string TMString = "";

            string cycle = "";
            //0 es Ticket Falla para ticket de fallas
            var ticketType = labelHolders[1].Text;

            Console.WriteLine("Ticket type {0}", ticketType);
            if (ticketType == "Falla") //falla
            {
                TMString = labelHolders[9].Text;
            }
            else  //solicitud
            {
                TMString = labelHolders[10].Text;
            }
            Console.WriteLine("TM is {0}", TMString);

            driver.FindElement(By.LinkText("Enlaces")).Click();

            //relationship dropdown index is 1
            var spans = driver.FindElements(By.CssSelector("span.DropdownArrow")); //DropdownArrowElement

            var dropDown = driver.FindElements(By.CssSelector("span.DropdownArrow"))[1];


            dropDown.Click();

            DelayHelper.Delay(driver, 10);


            // mouseover dijit_MenuItem_23_text id y 6 down
            Actions action = new Actions(driver);

            action.MoveToElement(driver.FindElement(By.Id("dijit_MenuItem_4_text"))).Perform();
            driver.SwitchTo().ActiveElement().SendKeys(Keys.Down);
            driver.SwitchTo().ActiveElement().SendKeys(Keys.Down);
            driver.SwitchTo().ActiveElement().SendKeys(Keys.Down);
            driver.SwitchTo().ActiveElement().SendKeys(Keys.Down);
            driver.SwitchTo().ActiveElement().SendKeys(Keys.Down);
            driver.SwitchTo().ActiveElement().SendKeys(Keys.Down);


            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
            wait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.Id("dijit_MenuItem_9_text"))));

            var addchildren = driver.FindElement(By.Id("dijit_MenuItem_9_text"));

            addchildren.Click();
            DelayHelper.Delay(driver, 20);



            //#com_ibm_team_workitem_web_ui_internal_view_layout_NameValueLayout_0 > table > tbody > tr:nth-child(3) > td.com-ibm-team-workitem-namevalue-value-td > span > select
            var selections = driver.FindElements(By.ClassName("selectSelect"));

            Console.WriteLine("nro:{0}", selections.Count);
            Console.WriteLine("nro:{0}", selections[0].Text);
            var selector = selections[0];

            var selectElement = new SelectElement(selector);



            wait.Until(d => d.FindElements(By.ClassName("selectSelect")).Count == 2);
            Console.WriteLine(driver.FindElements(By.ClassName("selectSelect"))[1].GetAttribute("innerHTML"));
            wait.Until(d => new SelectElement(d.FindElements(By.ClassName("selectSelect"))[1]).Options.Count == 13);
            Console.WriteLine("done waiting for 13 options");

            Console.WriteLine("*****Selecting tarea option******");
            Console.WriteLine(driver.FindElements(By.ClassName("selectSelect"))[1].GetAttribute("innerHTML"));

            var selectOptions = new SelectElement(driver.FindElements(By.ClassName("selectSelect"))[1]);

            selectOptions.SelectByText("Tarea");

            var wait2 = new WebDriverWait(driver, TimeSpan.FromSeconds(20));

            wait2.Until(d => d.FindElement(By.ClassName("createItemLink")).Text == "Create Linked Tarea...");


            driver.FindElement(By.ClassName("createItemLink")).Click();


            var taskPage = new TaskPage(driver, TMString, task);

            taskPage.CreateTask2();
            taskPage.UpdateTask();
        }