Пример #1
0
        public static MessageSource make(string motecom)
        {
            //string errsrc = "\nUnable to create or connect to {0}\n";
            MessageSource messageSource = null;

            string[] words = motecom.Split('@');
            string[] args;
            if (words.Length != 2)
            {
                throw new Exception("Could not make MessageSource");
            }

            if (words[0].Equals("serial"))
            {
                args = words[1].Split(':');
                try {
                    messageSource = new SerialSource(args[0], Convert.ToInt32(args[1]));
                } catch (Exception e) {
                    Debug.WriteLine(e.Message);
                    throw new Exception("Could not make serial source (bad port?)");
                }
            }
            else if (words[0].Equals("sf"))
            {
                args = words[1].Split(':');
                try {
                    messageSource = new SFSource();
                    ((SFSource)messageSource).Connect(args[0], Convert.ToInt32(args[1]));
                } catch (Exception e) {
                    Debug.WriteLine(e.Message);
                    throw new Exception("Could not make sf source (bad ip/port?)");
                }
            }
            return(messageSource);
        }
Пример #2
0
    public static MessageSource make(string motecom) {
      //string errsrc = "\nUnable to create or connect to {0}\n";
      MessageSource messageSource = null;
      string[] words = motecom.Split('@');
      string[] args;
      if (words.Length != 2)
        throw new Exception("Could not make MessageSource");

      if (words[0].Equals("serial")) {
        args = words[1].Split(':');
        try {
          messageSource = new SerialSource(args[0], Convert.ToInt32(args[1]));
        } catch (Exception e) {
          Debug.WriteLine(e.Message);
          throw new Exception("Could not make serial source (bad port?)");
        }
      }
      else if (words[0].Equals("sf")) {
        args = words[1].Split(':');
        try {
          messageSource = new SFSource();
          ((SFSource)messageSource).Connect(args[0], Convert.ToInt32(args[1]));
        } catch (Exception e) {
          Debug.WriteLine(e.Message);
          throw new Exception("Could not make sf source (bad ip/port?)");
        }
      }
      return messageSource;
    }