Ejemplo n.º 1
0
        public void GetVersionTest()
        {
            SerialCommander target = new SerialCommander();
            target.Manager.CurrentSerialSettings.PortName = "COM3";
            target.Manager.CurrentSerialSettings.BaudRate = 115200;
            target.Manager.CurrentSerialSettings.Parity = System.IO.Ports.Parity.None;
            target.Manager.CurrentSerialSettings.DataBits = 8;
            target.Manager.CurrentSerialSettings.StopBits = System.IO.Ports.StopBits.One;
            target.Manager.StartListening();

            //SerialCommand command = new SerialCommand("Firmware Revision Number", ParameterType.String);
            //command.GroupId = "05";
            //command.ParameterId = "02";
            //System.Threading.Thread.Sleep(2000);
            //Assert.IsTrue(target.Read(command));

            //target.LoadSetting();
            target.Retrieve();

            System.Threading.Thread.Sleep(3000);
            System.Diagnostics.Debug.WriteLine(target.Firmware);
            Assert.IsTrue(target.Firmware.Length > 0);
        }
Ejemplo n.º 2
0
 public static bool LoadFromFile(string fileName, out SerialCommander obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Deserializes xml markup from file into an SerialCommander object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output SerialCommander object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out SerialCommander obj, out System.Exception exception)
 {
     exception = null;
     obj = default(SerialCommander);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Ejemplo n.º 4
0
 public static bool Deserialize(string xml, out SerialCommander obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Deserializes workflow markup into an SerialCommander object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output SerialCommander object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out SerialCommander obj, out System.Exception exception)
 {
     exception = null;
     obj = default(SerialCommander);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Initial Windows layout.
        /// </summary>
        private void Initialize()
        {
            this.Title = Properties.Settings.Default.Company + " Studio" + " ver " + GetAssemblyVersion("SerialPortCommander.exe", 3);
            commander = new SerialCommander("BumbleBee");
            commander.LoadSetting(Properties.Settings.Default.Entry);
            MainGrid.DataContext = commander;

            //check the selected mode based on file name loaded
            MenuItem[] menus = new MenuItem[3] { menuModem, menuPager, menuPTX };
            int index = 0;
            string fileName = Properties.Settings.Default.Entry.TrimEnd(
                System.IO.Path.GetExtension(SerialCommander.DEFAULT_FILENAME).ToCharArray());
            fileName = fileName.TrimStart(
                System.IO.Path.GetFileNameWithoutExtension(SerialCommander.DEFAULT_FILENAME).ToCharArray());
            if (fileName.Length > 0) index = Convert.ToInt32(fileName);
            menus[index].IsChecked = true;
        }
Ejemplo n.º 7
0
        public void SaveToFileTest()
        {
            SerialCommander target = new SerialCommander("BumbleBee");

            ParameterGroup group = new ParameterGroup("Initialization LED");
            group.Commands.Add(new SerialCommand("LED Blinking On Period", 100, 65535, "ms"));
            group.Commands.Add(new SerialCommand("LED Blinking Off Period", 100, 65535, "ms"));
            group.Commands.Add(new SerialCommand("Number of LED Blinking", 10, 255));
            group.Commands.Add(new SerialCommand("Fail LED On Period", 20, 65535, "sec"));

            ParameterGroup group2 = new ParameterGroup();
            group2.Commands.Add(new SerialCommand("Startup Delay", 10, 65535, "sec"));
            group2.Commands.Add(new SerialCommand("Temperature Sampling Period", 10, 65535, "sec"));

            ParameterGroup group3 = new ParameterGroup();
            group3.Commands.Add(new SerialCommand("Normal Reporting Period", 10, 65535, "sec"));
            group3.Commands.Add(new SerialCommand("Violation Reporting Period", 5, 65535, "sec"));
            group3.Commands.Add(new SerialCommand("Tag ID", 305419896, ParameterType.Hex));
            group3.Commands.Add(new SerialCommand("Group ID", 39321, ParameterType.Hex));

            ParameterGroup group4 = new ParameterGroup("RF");
            group4.Commands.Add(new SerialCommand("Maximum of RF Retries", 3, 255));
            group4.Commands.Add(new SerialCommand("RF Retry Delay", 500, 655353, "ms"));
            group4.Commands.Add(new SerialCommand("RF Maximum Wait ACK Period", 60, 255, "ms"));

            SerialCommand cmd = new SerialCommand("RF TX Output Power", 4);
            cmd.ParameterOptions.Add(new KeyValuePair<int, string>(0, "-30 dBm"));
            cmd.ParameterOptions.Add(new KeyValuePair<int, string>(1, "-20 dBm"));
            cmd.ParameterOptions.Add(new KeyValuePair<int, string>(2, "-15 dBm"));
            cmd.ParameterOptions.Add(new KeyValuePair<int, string>(3, "-10 dBm"));
            cmd.ParameterOptions.Add(new KeyValuePair<int, string>(4, "0 dBm"));
            cmd.ParameterOptions.Add(new KeyValuePair<int, string>(5, "+5 dBm"));
            cmd.ParameterOptions.Add(new KeyValuePair<int, string>(6, "+7 dBm"));
            cmd.ParameterOptions.Add(new KeyValuePair<int, string>(7, "+10 dBm"));
            group4.Commands.Add(cmd);

            group4.Commands.Add(new SerialCommand("RF TX/RX LED Blinking On Period", 50, 655353, "ms"));
            group4.Commands.Add(new SerialCommand("RF TX/RX LED Blinking Off Period", 50, 655353, "ms"));
            group4.Commands.Add(new SerialCommand("RF TX/RX Number of LED Blinking", 2, 255));
            group4.Commands.Add(new SerialCommand("RF Device Address", 136, 255));

            ParameterGroup group5 = new ParameterGroup();
            group5.Commands.Add(new SerialCommand("Maximum Wait Period To Process PC Command", 15, 255, "sec"));

            SerialCommand cmd2 = new SerialCommand("Power Saving Mode", 1);
            cmd2.ParameterOptions.Add(new KeyValuePair<int, string>(0, "DISABLE"));
            cmd2.ParameterOptions.Add(new KeyValuePair<int, string>(1, "ENABLE"));
            group5.Commands.Add(cmd2);

            target.CommandGroups.Add(group);
            target.CommandGroups.Add(group2);
            target.CommandGroups.Add(group3);
            target.CommandGroups.Add(group4);
            target.CommandGroups.Add(group5);

            string fileName = "current.serial";
            target.SaveToFile(fileName);
            Assert.IsTrue(System.IO.File.Exists(fileName));
        }
Ejemplo n.º 8
0
        public void ProcessOutputsCollectionTest()
        {
            SerialCommander target = new SerialCommander("BumbleBee");
            for (int i = 0; i < 10; i++)
                target.Outputs.Add(i.ToString());

            while (target.Outputs.Count > 0)
            {
                int i = target.Outputs.Count - 1;
                target.Outputs.RemoveAt(i);
            }
        }
Ejemplo n.º 9
0
 public void LoadSettingTest()
 {
     SerialCommander target = new SerialCommander("BumbleBee");
     target.LoadSetting();
     Assert.IsTrue(target.CommandGroups.Count > 0);
 }