Ejemplo n.º 1
0
		//[UserConfigurableProperty("Data")]
		//public string Data { get; set; }

		public SignalCreator(IReceptorSystem rsys)
			: base(rsys)
		{
			AddReceiveProtocol("Resend", (Action<dynamic>)(s => Resend()));
			protocolControls = new List<Control>();
			inputProtocolControls = new List<Control>();
		}
Ejemplo n.º 2
0
 public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
 {
     AddReceiveProtocol("ThumbnailImage");
     AddEmitProtocol("SystemShowImage");
     AddEmitProtocol("ViewImage", false);
     AddEmitProtocol("GetImageMetadata", false);
 }
Ejemplo n.º 3
0
 public FeedReader(IReceptorSystem rsys)
     : base(rsys)
 {
     AddReceiveProtocol("RSSFeedUrl", (Action <dynamic>)(s => ProcessUrl(s)));
     AddEmitProtocol("RSSFeedItem");
     AddEmitProtocol("Exception");
 }
Ejemplo n.º 4
0
 public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
 {
     AddReceiveProtocol("Zip5");                         // We can receive a zipcode from some external source.
     AddEmitProtocol("Zip5");                            // We also emit a zipcode because we may be configured to process a zipcode on startup, in which case we need to initiate getting the city, state.
     AddEmitProtocol("WeatherInfo");
     AddEmitProtocol("ExceptionMessage");
 }
Ejemplo n.º 5
0
		public ImageViewer(IReceptorSystem rsys) : base("ImageViewer.xml", true, rsys)
		{
/*
			AddReceiveProtocol("ImageFilename", (Action<dynamic>)(signal =>
				{
					form.IfNull(() => InitializeViewer());
					// TODO: As remarked in VisualizerController, we need computed types that can perform this kind of function for us when we use a getter like "FullyQualifiedFilename"
					Image img = Image.FromFile(Path.Combine(signal.Filename.Path.Value, signal.Filename.Name.Value + signal.Filename.FileExtension.Value));
					MakeWindowFitImage(img);
					pb.Image = img;
				}));
*/
			AddEmitProtocol("Url");

			AddReceiveProtocol("Image", (Action<dynamic>)(signal =>
				{
					form.IfNull(() =>
						{
							InitializeUI();
							form.FormClosing += WhenFormClosing;
							form.SizeChanged += ProportionalResize;
						});
					
					pb.Image = signal.Value;

					string title = signal.Title.Text.Value;

					if (!String.IsNullOrEmpty(title))
					{
						WindowName = title;
						UpdateCaption();
					}
				}));
		}
Ejemplo n.º 6
0
        public FeedItemList(IReceptorSystem rsys)
            : base(rsys)
        {
            AddEmitProtocol("URL");
            AddEmitProtocol("DropView");
            AddEmitProtocol("RequireView");
            AddEmitProtocol("DatabaseRecord");

            AddReceiveProtocol("RSSFeedItemDisplay",
                               // cast is required to resolve Func vs. Action in parameter list.
                               (Action <dynamic>)(signal => AddFeedItem(signal)));

            AddReceiveProtocol("Recordset",
                               signal => signal.Schema == "FeedItemPhrases",
                               signal => ProcessFeedItems(signal));

            AddReceiveProtocol("Recordset",
                               signal => signal.Schema == "RSSFeedItemDisplay",
                               signal => ProcessFeedItems(signal));

            AddReceiveProtocol("SearchDateRange",
                               (Action <dynamic>)(signal =>
            {
                SearchDateRange(signal.BeginningDate, signal.EndingDate);
            }));

            InitializeViewer();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Instantiate the receptor from the pre-loaded assembly.
        /// The receptor system instance is passed to the constructor if the IReceptorInstance implementor.
        /// </summary>
        public Receptor Instantiate(IReceptorSystem rsys)
        {
            Type impType;

            try
            {
                impType = assembly.GetTypes().
                          Where(t => t.IsClass).
                          Where(c => c.GetInterfaces().Where(i => i.Name == "IReceptorInstance").Count() > 0).Single();
            }
            catch
            {
                throw new ApplicationException("Unable to locate the receptor assembly " + assemblyName);
            }

            try
            {
                Instance         = Activator.CreateInstance(impType, new object[] { rsys }) as IReceptorInstance;
                Name             = Instance.Name;
                Instance.Enabled = Enabled;
            }
            catch (Exception ex)                // Need to be able to see originating exception.
            {
                throw new ApplicationException("Unable to instantiate the receptor " + Name + "\r\n" + ex.Message);
            }

            Instantiated = true;

            return(this);
        }
Ejemplo n.º 8
0
 public CarrierTabbedListViewer(IReceptorSystem rsys)
     : base(rsys)
 {
     AddEmitProtocol("ExceptionMessage");
     protocolTabPageMap = new Dictionary <string, TabPage>();
     protocolGridMap    = new Dictionary <string, DataGridView>();
 }
Ejemplo n.º 9
0
        public ImageViewer(IReceptorSystem rsys) : base("ImageViewer.xml", true, rsys)
        {
/*
 *                      AddReceiveProtocol("ImageFilename", (Action<dynamic>)(signal =>
 *                              {
 *                                      form.IfNull(() => InitializeViewer());
 *                                      // TODO: As remarked in VisualizerController, we need computed types that can perform this kind of function for us when we use a getter like "FullyQualifiedFilename"
 *                                      Image img = Image.FromFile(Path.Combine(signal.Filename.Path.Value, signal.Filename.Name.Value + signal.Filename.FileExtension.Value));
 *                                      MakeWindowFitImage(img);
 *                                      pb.Image = img;
 *                              }));
 */
            AddEmitProtocol("Url");

            AddReceiveProtocol("Image", (Action <dynamic>)(signal =>
            {
                form.IfNull(() =>
                {
                    InitializeUI();
                    form.FormClosing += WhenFormClosing;
                    form.SizeChanged += ProportionalResize;
                });

                pb.Image = signal.Value;

                string title = signal.Title.Text.Value;

                if (!String.IsNullOrEmpty(title))
                {
                    WindowName = title;
                    UpdateCaption();
                }
            }));
        }
Ejemplo n.º 10
0
		public CarrierTabbedListViewer(IReceptorSystem rsys)
			: base(rsys)
		{
			AddEmitProtocol("ExceptionMessage");
			protocolTabPageMap = new Dictionary<string, TabPage>();
			protocolGridMap = new Dictionary<string, DataGridView>();
		}
Ejemplo n.º 11
0
		public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
		{
			AddReceiveProtocol("Zip5");		// We can receive a zipcode from some external source.
			AddEmitProtocol("Zip5");		// We also emit a zipcode because we may be configured to process a zipcode on startup, in which case we need to initiate getting the city, state.
			AddEmitProtocol("WeatherInfo");
			AddEmitProtocol("ExceptionMessage");
		}
Ejemplo n.º 12
0
		public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
		{
			AddReceiveProtocol("ThumbnailImage", (Action<dynamic>)(signal => ShowImage(signal.Image.Value, signal.SourceImageFilename.Filename)));
			AddEmitProtocol("SystemShowImage");
			AddEmitProtocol("ImageFilename", false);			// Currently, this is emitted by the visualizer.  See TODO below.
			// AddEmitProtocol("GetImageMetadata", false);
		}
Ejemplo n.º 13
0
 public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
 {
     AddReceiveProtocol("ThumbnailImage", (Action <dynamic>)(signal => ShowImage(signal.Image.Value, signal.SourceImageFilename.Filename)));
     AddEmitProtocol("SystemShowImage");
     AddEmitProtocol("ImageFilename", false);                                    // Currently, this is emitted by the visualizer.  See TODO below.
     // AddEmitProtocol("GetImageMetadata", false);
 }
Ejemplo n.º 14
0
        //[UserConfigurableProperty("Data")]
        //public string Data { get; set; }

        public SignalCreator(IReceptorSystem rsys)
            : base(rsys)
        {
            AddReceiveProtocol("Resend", (Action <dynamic>)(s => Resend()));
            protocolControls      = new List <Control>();
            inputProtocolControls = new List <Control>();
        }
Ejemplo n.º 15
0
 public WindowedBaseReceptor(string displayFormFilename, bool showOnStartup, IReceptorSystem rsys)
     : base(rsys)
 {
     this.displayFormFilename = displayFormFilename;
     this.showOnStartup       = showOnStartup;
     LayoutId = Guid.NewGuid();                                  // will be overridden by the persisted LayoutId when the receptor system is loaded.
 }
Ejemplo n.º 16
0
 public WebBrowserReceptor(IReceptorSystem rsys)
     : base("webPageViewer.xml", false, rsys)
 {
     Cef.Initialize();
     AddReceiveProtocol("Url", (Action <dynamic>)(signal => ShowPage(signal.Value)));
     AddReceiveProtocol("Text", (Action <dynamic>)(signal => EmbedSearchString(signal.Value)));
 }
Ejemplo n.º 17
0
 public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
 {
     zipcodeInfoMap = new Dictionary <string, FullInfo>();
     AddReceiveProtocol("WeatherInfo");
     AddReceiveProtocol("Location");
     AddEmitProtocol("TextToSpeech");
 }
Ejemplo n.º 18
0
		public WindowedBaseReceptor(string displayFormFilename, bool showOnStartup, IReceptorSystem rsys)
			: base(rsys)
		{
			this.displayFormFilename = displayFormFilename;
			this.showOnStartup = showOnStartup;
			LayoutId = Guid.NewGuid();			// will be overridden by the persisted LayoutId when the receptor system is loaded.
		}
Ejemplo n.º 19
0
		public WebBrowserReceptor(IReceptorSystem rsys)
			: base("webPageViewer.xml", false, rsys)
		{
			Cef.Initialize();
			AddReceiveProtocol("Url", (Action<dynamic>)(signal => ShowPage(signal.Value)));
			AddReceiveProtocol("Text", (Action<dynamic>)(signal => EmbedSearchString(signal.Value)));
		}
Ejemplo n.º 20
0
 public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
 {
     this.rsys = rsys;
     AddReceiveProtocol("ImageFilename");
     AddEmitProtocol("DebugMessage");
     AddEmitProtocol("ThumbnailImage", false);
     MaxSize = 320;
 }
Ejemplo n.º 21
0
 public BaseReceptor(IReceptorSystem rsys)
 {
     this.rsys        = rsys;
     receiveProtocols = new List <ReceiveQualifier>();
     emitProtocols    = new List <string>();
     gates            = new Dictionary <string, Gate>();
     compositeGates   = new Dictionary <string, CompositeGate>();
 }
Ejemplo n.º 22
0
		public Exceptions(IReceptorSystem rsys)
			: base(rsys)
		{
			AddReceiveProtocol("Exception",
				// cast is required to resolve Func vs. Action in parameter list.
				(Action<dynamic>)(signal => ShowException(signal)));

			InitializeUI();
		}
Ejemplo n.º 23
0
        public Exceptions(IReceptorSystem rsys)
            : base(rsys)
        {
            AddReceiveProtocol("Exception",
                               // cast is required to resolve Func vs. Action in parameter list.
                               (Action <dynamic>)(signal => ShowException(signal)));

            InitializeUI();
        }
Ejemplo n.º 24
0
		public DayGreeter(IReceptorSystem rsys)						   
			: base(rsys)
		{
			AddEmitProtocol("Text");
			AddEmitProtocol("RSSFeedUrl");
			AddReceiveProtocol("RSSFeedItem", (Action<dynamic>)(s => ProcessFeedItem(s)));

			groups = new Dictionary<string, StringBuilder>();
		}
Ejemplo n.º 25
0
		public FeedReader(IReceptorSystem rsys)
			: base(rsys)
		{
			AddReceiveProtocol("RSSFeedUrl", (Action<dynamic>)(s => ProcessUrl(s)));
			AddReceiveProtocol("RSSFeedRefresh", (Action<dynamic>)(s => AcquireFeed(lastFeedUrl)));
			AddEmitProtocol("RSSFeedItem");
			AddEmitProtocol("ExceptionMessage");
			AddEmitProtocol("LoggerMessage");
		}
Ejemplo n.º 26
0
		int currentCaveNumber = -1;			// No starting cave.

		public PlayerReceptor(IReceptorSystem rsys)
			: base(rsys)
		{
			AddReceiveProtocol("HW_Player");
			AddReceiveProtocol("HW_GameState");
			AddEmitProtocol("HW_MoveTo");
			AddEmitProtocol("HW_ShootInto");

			rnd = new Random();

			form = new Form();
			form.Text = "Hunt The Wumpus";
			form.Location = new Point(600, 100);
			form.Size = new Size(320, 130);
			form.StartPosition = FormStartPosition.Manual;

			moveButtons = new Button[3] { new Button(), new Button(), new Button() };
			shootButtons = new Button[3] { new Button(), new Button(), new Button() };

			moveButtons.ForEachWithIndex((b, idx) =>
				{
					b.Visible = false;
					b.Location = new Point(10 + idx * 100, 15);
					b.Size = new Size(80, 25);
					b.Click += OnMove;
					form.Controls.Add(b);
				});

			shootButtons.ForEachWithIndex((b, idx) =>
			{
				b.Visible = false;
				b.Location = new Point(10 + idx * 100, 50);
				b.Size = new Size(80, 25);
				b.Click += OnShoot;
				form.Controls.Add(b);
			});

			lblPlayerIsDead = new Label();
			lblPlayerIsDead.Text = "You are dead!";
			lblPlayerIsDead.Location = new Point(10, 15);
			lblPlayerIsDead.Size = new Size(300, 15);
			lblPlayerIsDead.TextAlign = ContentAlignment.MiddleCenter;
			lblPlayerIsDead.Visible = false;


			lblPlayerWins = new Label();
			lblPlayerWins.Text = "The Wumpus is dead!";
			lblPlayerWins.Location = new Point(10, 15);
			lblPlayerWins.Size = new Size(300, 15);
			lblPlayerWins.TextAlign = ContentAlignment.MiddleCenter;
			lblPlayerWins.Visible = false;

			form.Controls.Add(lblPlayerIsDead);
			form.Controls.Add(lblPlayerWins);

			form.Show();
		}
Ejemplo n.º 27
0
 public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
 {
     zipcodeInfoMap = new Dictionary <string, FullInfo>();
     AddReceiveProtocol("WeatherInfo");
     AddReceiveProtocol("USLocation");
     AddEmitProtocol("Announce");
     AddEmitProtocol("Text");
     AddEmitProtocol("ExceptionMessage");
 }
Ejemplo n.º 28
0
		public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
		{
			zipcodeInfoMap = new Dictionary<string, FullInfo>();
			AddReceiveProtocol("WeatherInfo");
			AddReceiveProtocol("USLocation");
			AddEmitProtocol("Announce");
			AddEmitProtocol("Text");
			AddEmitProtocol("ExceptionMessage");
		}
Ejemplo n.º 29
0
 public WeatherRadarScraper(IReceptorSystem rsys) : base(rsys)
 {
     // AddEmitProtocol("ImageFilename");
     AddEmitProtocol("WebImage");
     AddEmitProtocol("Url");
     AddEmitProtocol("ExceptionMessage");
     AddReceiveProtocol("WebPageHtml", (Action <dynamic>)(signal => ProcessPage(signal.Url.Value, signal.Html.Value)));
     AddReceiveProtocol("Refresh", (Action <dynamic>)(signal => GetRadarImage()));
 }
Ejemplo n.º 30
0
		public WeatherRadarScraper(IReceptorSystem rsys) : base(rsys)
		{
			// AddEmitProtocol("ImageFilename");
			AddEmitProtocol("WebImage");
			AddEmitProtocol("Url");
			AddEmitProtocol("ExceptionMessage");
			AddReceiveProtocol("WebPageHtml", (Action<dynamic>)(signal => ProcessPage(signal.Url.Value, signal.Html.Value)));
			AddReceiveProtocol("Refresh", (Action<dynamic>)(signal => GetRadarImage()));
		}
Ejemplo n.º 31
0
 public ThumbnailCreator(IReceptorSystem rsys) : base(rsys)
 {
     this.rsys = rsys;
     AddReceiveProtocol("ImageFilename", (Action <dynamic>)(signal => ProcessImage(signal.Filename)));
     AddReceiveProtocol("Image", (Action <dynamic>)(signal => ProcessInMemoryImage(signal.Value)));
     AddEmitProtocol("ThumbnailImage");
     AddEmitProtocol("ExceptionMessage");
     MaxSize = 320;
 }
Ejemplo n.º 32
0
		public ThumbnailCreator(IReceptorSystem rsys) : base(rsys)
		{
			this.rsys = rsys;
			AddReceiveProtocol("ImageFilename", (Action<dynamic>)(signal => ProcessImage(signal.Filename)));
			AddReceiveProtocol("Image", (Action<dynamic>)(signal => ProcessInMemoryImage(signal.Value)));
			AddEmitProtocol("ThumbnailImage");
			AddEmitProtocol("ExceptionMessage");
			MaxSize = 320;
		}
Ejemplo n.º 33
0
        public DayGreeter(IReceptorSystem rsys)
            : base(rsys)
        {
            AddEmitProtocol("Text");
            AddEmitProtocol("RSSFeedUrl");
            AddReceiveProtocol("RSSFeedItem", (Action <dynamic>)(s => ProcessFeedItem(s)));

            groups = new Dictionary <string, StringBuilder>();
        }
Ejemplo n.º 34
0
 public FeedReader(IReceptorSystem rsys)
     : base(rsys)
 {
     AddReceiveProtocol("RSSFeedUrl", (Action <dynamic>)(s => ProcessUrl(s)));
     AddReceiveProtocol("RSSFeedRefresh", (Action <dynamic>)(s => AcquireFeed(lastFeedUrl)));
     AddEmitProtocol("RSSFeedItem");
     AddEmitProtocol("ExceptionMessage");
     AddEmitProtocol("LoggerMessage");
 }
Ejemplo n.º 35
0
        public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
        {
            speechSynth = new SpeechSynthesizer();
            speechSynth.SpeakCompleted += OnSpeakCompleted;
            speechSynth.Rate            = -2;  // -4;
            speechQueue = new Queue <string>();

            AddReceiveProtocol("TextToSpeech");
            AddReceiveProtocol("Text");
        }
Ejemplo n.º 36
0
		public CaveConfigurationReceptor(IReceptorSystem rsys)
			: base(rsys)
		{
			idToIndexMap = new Dictionary<Guid, int>();
			pits = new List<int>();
			bats = new List<int>();
			AddReceiveProtocol("HW_WhereAmI");
			AddEmitProtocol("HW_YouAre");
			rnd = new Random();
		}
Ejemplo n.º 37
0
 public CaveConfigurationReceptor(IReceptorSystem rsys)
     : base(rsys)
 {
     idToIndexMap = new Dictionary <Guid, int>();
     pits         = new List <int>();
     bats         = new List <int>();
     AddReceiveProtocol("HW_WhereAmI");
     AddEmitProtocol("HW_YouAre");
     rnd = new Random();
 }
Ejemplo n.º 38
0
        public ApodScraper(IReceptorSystem rsys) : base(rsys)
        {
            // AddEmitProtocol("ImageFilename");
            AddEmitProtocol("Image", false);
            AddEmitProtocol("Url");
            AddEmitProtocol("ExceptionMessage");
            AddReceiveProtocol("WebPageHtml", (Action <dynamic>)(signal => ProcessPage(signal.Url.Value, signal.Html.Value)));

            // (new string[] { "RequireTable", "ScrapeWebpage", "ImageFilename", "DatabaseRecord", "DebugMessage", "APOD", "HaveImageMetadata" }).ForEach(p => AddEmitProtocol(p));
        }
Ejemplo n.º 39
0
 public BaseReceptor(IReceptorSystem rsys)
 {
     this.rsys                   = rsys;
     receiveProtocols            = new List <ReceiveQualifier>();
     emitProtocols               = new List <EmittedProtocol>();
     cachedEmitProtocolConfig    = new Dictionary <string, bool>();
     cachedReceiveProtocolConfig = new Dictionary <string, bool>();
     gates          = new Dictionary <string, Gate>();
     compositeGates = new Dictionary <string, CompositeGate>();
     Enabled        = true;
 }
Ejemplo n.º 40
0
		public ApodScraper(IReceptorSystem rsys) : base(rsys)
		{
			// AddEmitProtocol("ImageFilename");
			AddEmitProtocol("WebImage");
			AddEmitProtocol("Url");
			AddEmitProtocol("ExceptionMessage");
			AddReceiveProtocol("Date", (Action<dynamic>)(signal => GetImageForDate(new DateTime(signal.Year, signal.Month, signal.Day))));
			AddReceiveProtocol("WebPageHtml", (Action<dynamic>)(signal => ProcessPage(signal.Url.Value, signal.Html.Value)));

			// (new string[] { "RequireTable", "ScrapeWebpage", "ImageFilename", "DatabaseRecord", "DebugMessage", "APOD", "HaveImageMetadata" }).ForEach(p => AddEmitProtocol(p));
		}
Ejemplo n.º 41
0
		public CaveReceptor(IReceptorSystem rsys)
			: base(rsys)
		{
			AddReceiveProtocol("HW_YouAre", (signal) => signal.ID == id);
			AddReceiveProtocol("HW_MoveTo", (signal) => signal.FromCaveNumber == caveNumber || signal.NewCaveNumber == caveNumber);
			AddReceiveProtocol("HW_ShootInto", (signal) => signal.CaveNumber == caveNumber);
			AddEmitProtocol("HW_WhereAmI");
			AddEmitProtocol("HW_Player");
			AddEmitProtocol("Text");
			caveNeighbors = new int[3];
			rnd = new Random();
		}
Ejemplo n.º 42
0
 public CaveReceptor(IReceptorSystem rsys)
     : base(rsys)
 {
     AddReceiveProtocol("HW_YouAre", (signal) => signal.ID == id);
     AddReceiveProtocol("HW_MoveTo", (signal) => signal.FromCaveNumber == caveNumber || signal.NewCaveNumber == caveNumber);
     AddReceiveProtocol("HW_ShootInto", (signal) => signal.CaveNumber == caveNumber);
     emitProtocols.Add("HW_WhereAmI");
     emitProtocols.Add("HW_Player");
     emitProtocols.Add("Text");
     caveNeighbors = new int[3];
     rnd           = new Random();
 }
Ejemplo n.º 43
0
		public static List<string> PopulateProtocolComboBox(ComboBox cbProtocols, IReceptorSystem rsys, string protocolName)
		{
			List<string> types = rsys.SemanticTypeSystem.SemanticTypes.Keys.ToList();
			types.Sort();
			cbProtocols.DataSource = types;

			if (!String.IsNullOrEmpty(protocolName))
			{
				cbProtocols.SelectedItem = protocolName;
			}

			return types;
		}
Ejemplo n.º 44
0
        public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
        {
            intervalMap = new Dictionary <string, IntervalTimer>();

            AddReceiveProtocol("IntervalTimerConfiguration",
                               (Action <dynamic>)(s => IntervalTimerConfiguration(s)));
            AddReceiveProtocol("Recordset",
                               s => s.Schema == "LastEventDateTime",
                               s => LastEventDateTimeRecordset(s));

            AddEmitProtocol("RequireTable");
            AddEmitProtocol("DatabaseRecord");
            AddEmitProtocol("TimerEvent");
        }
Ejemplo n.º 45
0
        public static List <string> PopulateProtocolComboBox(ComboBox cbProtocols, IReceptorSystem rsys, string protocolName)
        {
            List <string> types = rsys.SemanticTypeSystem.SemanticTypes.Keys.ToList();

            types.Sort();
            cbProtocols.DataSource = types;

            if (!String.IsNullOrEmpty(protocolName))
            {
                cbProtocols.SelectedItem = protocolName;
            }

            return(types);
        }
Ejemplo n.º 46
0
		public LinkedInInterface(IReceptorSystem rsys)
			: base(rsys)
		{
			groups = new Dictionary<string, LinkedInGroup>();
			posts = new Dictionary<string, LinkedInGroupPost>();
			postGroup = new Dictionary<string, LinkedInGroup>();
			LoadConfiguration();
			InitializeClient();
			AddEmitProtocol("ExceptionMessage");
			AddEmitProtocol("LinkedInGroup");
			AddEmitProtocol("LinkedInPost");
			AddEmitProtocol("LinkedInComment");
			AddReceiveProtocol("QueryPosts", (Action<dynamic>)(signal => GetPosts(signal.LinkedInGroup.Id)));
			AddReceiveProtocol("QueryComments", (Action<dynamic>)(signal => GetComments(signal.LinkedInPost.Id)));			 
		}
Ejemplo n.º 47
0
        public Alchemy(IReceptorSystem rsys)
            : base(rsys)
        {
            AddEmitProtocol("AlchemyEntity");
            AddEmitProtocol("AlchemyKeyword");
            AddEmitProtocol("AlchemyConcept");
            AddEmitProtocol("Exception");

            // TODO: Temporary, for demo purposes only
            AddEmitProtocol("RequireTable");

            AddReceiveProtocol("URL",
                               // cast is required to resolve Func vs. Action in parameter list.
                               (Action <dynamic>)(signal => ParseUrl(signal)));
        }
Ejemplo n.º 48
0
 public LinkedInInterface(IReceptorSystem rsys)
     : base(rsys)
 {
     groups    = new Dictionary <string, LinkedInGroup>();
     posts     = new Dictionary <string, LinkedInGroupPost>();
     postGroup = new Dictionary <string, LinkedInGroup>();
     LoadConfiguration();
     InitializeClient();
     AddEmitProtocol("ExceptionMessage");
     AddEmitProtocol("LinkedInGroup");
     AddEmitProtocol("LinkedInPost");
     AddEmitProtocol("LinkedInComment");
     AddReceiveProtocol("QueryPosts", (Action <dynamic>)(signal => GetPosts(signal.LinkedInGroup.Id)));
     AddReceiveProtocol("QueryComments", (Action <dynamic>)(signal => GetComments(signal.LinkedInPost.Id)));
 }
Ejemplo n.º 49
0
		public Alchemy(IReceptorSystem rsys)
			: base(rsys)
		{
			AddEmitProtocol("AlchemyEntity");
			AddEmitProtocol("AlchemyKeyword");
			AddEmitProtocol("AlchemyConcept");
			AddEmitProtocol("Exception");

			// TODO: Temporary, for demo purposes only
			AddEmitProtocol("RequireTable");

			AddReceiveProtocol("URL",
				// cast is required to resolve Func vs. Action in parameter list.
				(Action<dynamic>)(signal => ParseUrl(signal)));

		}
Ejemplo n.º 50
0
		public TextDisplay(IReceptorSystem rsys) : base("TextViewer.xml", true, rsys)
		{
			ShowAll = true;

			AddReceiveProtocol("Text", (Action<dynamic>)(signal =>
				{
					form.IfNull(() =>
						{
							InitializeUI();
							UpdateFormLocationAndSize();
						});

					string text = signal.Value;

					if (!String.IsNullOrEmpty(text))
					{
						// TODO: This is a real kludge for indicating that we want to clear the text in the textbox!
						if (text.StartsWith("!"))
						{
							tb.Clear();
							text = text.Substring(1);
						}

						tb.AppendText(text.StripHtml());
						tb.AppendText("\r\n");
					}
				}));

			AddReceiveProtocol("Html", (Action<dynamic>)(signal =>
			{
				form.IfNull(() =>
				{
					InitializeUI();
					UpdateFormLocationAndSize();
				});

				string text = signal.Value;

				if (!String.IsNullOrEmpty(text))
				{
					tb.AppendText(text);
					tb.AppendText("\r\n");
				}
			}));

		}
Ejemplo n.º 51
0
        public TextDisplay(IReceptorSystem rsys) : base("TextViewer.xml", true, rsys)
        {
            ShowAll = true;

            AddReceiveProtocol("Text", (Action <dynamic>)(signal =>
            {
                form.IfNull(() =>
                {
                    InitializeUI();
                    UpdateFormLocationAndSize();
                });

                string text = signal.Value;

                if (!String.IsNullOrEmpty(text))
                {
                    // TODO: This is a real kludge for indicating that we want to clear the text in the textbox!
                    if (text.StartsWith("!"))
                    {
                        tb.Clear();
                        text = text.Substring(1);
                    }

                    tb.AppendText(text.StripHtml());
                    tb.AppendText("\r\n");
                }
            }));

            AddReceiveProtocol("Html", (Action <dynamic>)(signal =>
            {
                form.IfNull(() =>
                {
                    InitializeUI();
                    UpdateFormLocationAndSize();
                });

                string text = signal.Value;

                if (!String.IsNullOrEmpty(text))
                {
                    tb.AppendText(text);
                    tb.AppendText("\r\n");
                }
            }));
        }
Ejemplo n.º 52
0
		public FeedItemList(IReceptorSystem rsys)
			: base(rsys, "feedItemList.xml")
		{
			MaxRecords = "40";			// The default.
			Categories = new List<string>();

			AddReceiveProtocol("RSSFeedItem", (Action<dynamic>)(signal => ShowSignal(signal)));
			
			// TODO: This update the combobox for each category received -- can we have some way of putting all the records into a collection?
			AddReceiveProtocol("BookmarkCategory", (Action<dynamic>)(signal => UpdateCategoryList(signal)));

			AddEmitProtocol("ExceptionMessage");
			AddEmitProtocol("UrlVisited");
			AddEmitProtocol("RSSFeedItemDisplayed");
			AddEmitProtocol("RSSFeedBookmark");
			AddEmitProtocol("Query");
			AddEmitProtocol("Announce");

			rowStateByUrl = new Dictionary<string, ItemStates>();
		}
Ejemplo n.º 53
0
		// Other optional property overides...

		/// <summary>
		/// Constructor called when the class is instantiated.
		/// Do not make any assumptions about the existence of other receptors at this point.
		/// Typically, all we do here is register emitted and received protocols.
		/// </summary>
		public YourReceptor(IReceptorSystem rsys)
			: base(rsys)
		{
			// Protocols emitted by this receptor
			 AddEmitProtocol("[protocol name]");

			// Protocols received by this receptor
			 AddReceiveProtocol("[protocol name]",
				 // Qualifier:
				 signal =>
				 {
					 // Put any qualifiers here to filter specific signals based on signal data.
					 // Replace the "return true" with a bool result.
					 return true;
				 },
				 // Action:
				signal =>
				{
					// Put any actions, method calls, etc., when the qualified signal is received.
				});
		}
Ejemplo n.º 54
0
		public NlpViewer(IReceptorSystem rsys)
			: base(rsys)
		{
			InitializeViewer();
			AddEmitProtocol("DatabaseRecord");
			AddEmitProtocol("DropView");
			AddEmitProtocol("RequireView");

			AddReceiveProtocol("SearchDateRange",
				(Action<dynamic>)(signal =>
			{
				SearchDateRange(signal.BeginningDate, signal.EndingDate);
			}));

			// Don't forgot, explicit cast is required for some reason to differentiate between Action<dyanmic> and Func<bool, dynamic>
			AddReceiveProtocol("Recordset",
				signal => signal.Schema == "AlchemyPhrases" && signal.Tag == "Entities",
				signal => ProcessEntityPhrases(signal));

			AddReceiveProtocol("Recordset",
				signal => signal.Schema == "AlchemyPhrases" && signal.Tag == "Keywords",
				signal => ProcessKeywordPhrases(signal));

			AddReceiveProtocol("Recordset",
				signal => signal.Schema == "AlchemyPhrases" && signal.Tag == "Concepts",
				signal => ProcessConceptPhrases(signal));

			AddReceiveProtocol("Recordset",
				signal => signal.Schema == "AlchemyResultTypeRecord",
				signal =>
				{
					// Save our name to ID mapping of result types.
					foreach(dynamic row in signal.Records)
					{
						resultTypeIDMap[row.Name] = row.ID;
					}

					LoadPhrases();
				});
		}
Ejemplo n.º 55
0
		public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
		{
			ShowAll = true;

			speechSynth = new SpeechSynthesizer();
			speechSynth.SpeakCompleted += OnSpeakCompleted;
			speechSynth.Rate = -2; // -4;
			speechQueue = new Queue<string>();

			AddReceiveProtocol("Text", (Action<dynamic>)(signal =>
				{
					string msg = signal.Value;
					msg = msg.StripHtml();
					Speak(msg);
				}));

			// Specific protocol for announcements.
			AddReceiveProtocol("Announce", (Action<dynamic>)(signal =>
			{
				string msg = signal.Text.Value;
				msg = msg.StripHtml();
				Speak(msg);
			}));
		}
Ejemplo n.º 56
0
		/// <summary>
		/// Instantiate the receptor from the pre-loaded assembly.
		/// The receptor system instance is passed to the constructor if the IReceptorInstance implementor.
		/// </summary>
		public Receptor Instantiate(IReceptorSystem rsys)
		{
			Type impType;

			try
			{
				impType = assembly.GetTypes().
						Where(t => t.IsClass).
						Where(c => c.GetInterfaces().Where(i => i.Name == "IReceptorInstance").Count() > 0).Single();
			}
			catch
			{
				throw new ApplicationException("Unable to locate the receptor assembly " + assemblyName);
			}

			try
			{
				Instance = Activator.CreateInstance(impType, new object[] { rsys }) as IReceptorInstance;
				Name = Instance.Name;
				Instance.Enabled = Enabled;
			}
			catch(Exception ex)	// Need to be able to see originating exception.
			{
				throw new ApplicationException("Unable to instantiate the receptor " + Name + "\r\n" + ex.Message);
			}

			Instantiated = true;

			return this;
		}
Ejemplo n.º 57
0
		public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
		{
			AddReceiveProtocol("Url");
		}
Ejemplo n.º 58
0
		public TextFileLoader(IReceptorSystem rsys)
			: base(rsys)
		{
			AddEmitProtocol("Text");
		}
Ejemplo n.º 59
0
		public BaseReceptor(IReceptorSystem rsys)
		{
			this.rsys = rsys;
			receiveProtocols = new List<ReceiveQualifier>();
			emitProtocols = new List<EmittedProtocol>();
			cachedEmitProtocolConfig = new Dictionary<string, bool>();
			cachedReceiveProtocolConfig = new Dictionary<string, bool>();
			gates = new Dictionary<string, Gate>();
			compositeGates = new Dictionary<string, CompositeGate>();
			Enabled = true;
		}
Ejemplo n.º 60
0
		public ReceptorDefinition(IReceptorSystem rsys) : base(rsys)
		{
			// Other protocols might be added in the future.
			AddReceiveProtocol("ThumbnailImage", (Action<dynamic>)(signal => SaveImage(signal.Image.Value, signal.ImageFilename.Filename)));
			AddEmitProtocol("ExceptionMessage");
		}