public MainWindow()
        {
            Process.Start(@"..\..\Ampelsteuerung.exe");
            InitializeComponent();
            StartAmpelsteuerung();

            mqhandler = new RabbitMQ.RabbitMQHandler();


            dispatchTimer          = new DispatcherTimer();
            dispatchTimer.Tick    += dispatchTimer_Tick;
            dispatchTimer.Interval = new TimeSpan(0, 0, 0, 0, 50);


            ap      = new GUI.AmpelHandler(myCanvas);
            builder = new EnvironmentHandler(myCanvas, ref ap, ref trafficlight);
            oh      = new ObjectHandler(myCanvas, ref builder);
            I_ENV_VKTeilnehmer iTeilnehmer = builder;
            IObject            iObject     = oh;

            th = TrafficHandler.getInstance(ref iTeilnehmer, ref iObject, ref mqhandler);

            th.createNewVerkehrsteilnehmer(210, 155, 4, (int)TrafficObject.Fahrzeugtyp.Car, (int)TrafficObject.Dir.Right, (int)TrafficObject.Dir.Right);
            th.createNewVerkehrsteilnehmer(35, 155, 4, (int)TrafficObject.Fahrzeugtyp.Car, (int)TrafficObject.Dir.Right, (int)TrafficObject.Dir.Right);
            th.createNewVerkehrsteilnehmer(10, 155, 4, (int)TrafficObject.Fahrzeugtyp.Car, (int)TrafficObject.Dir.Right, (int)TrafficObject.Dir.Right);
            th.createNewVerkehrsteilnehmer(280, 145, 4, (int)TrafficObject.Fahrzeugtyp.Car, (int)TrafficObject.Dir.Left, (int)TrafficObject.Dir.Down);
            th.createNewVerkehrsteilnehmer(255, 285, 4, (int)TrafficObject.Fahrzeugtyp.Car, (int)TrafficObject.Dir.Up, (int)TrafficObject.Dir.Up);
            th.createNewVerkehrsteilnehmer(320, 355, 4, (int)TrafficObject.Fahrzeugtyp.Car, (int)TrafficObject.Dir.Right, (int)TrafficObject.Dir.Right);
            th.createNewVerkehrsteilnehmer(255, 655, 4, (int)TrafficObject.Fahrzeugtyp.Car, (int)TrafficObject.Dir.Up, (int)TrafficObject.Dir.Up);
            th.createNewVerkehrsteilnehmer(255, 645, 4, (int)TrafficObject.Fahrzeugtyp.Car, (int)TrafficObject.Dir.Up, (int)TrafficObject.Dir.Up);


            dispatchTimer.Start();
        }
 public ObjectHandler(Canvas mycanvas, ref EnvironmentHandler builder)
 {
     objlist      = new List <Verkehrsteilnehmer>();
     this.builder = builder;
     canvas       = mycanvas;
     canvas.MouseLeftButtonDown += addObstacle;
 }
Beispiel #3
0
        public S3Access()
        {
            S3Config = new AmazonS3Config();
            RegionEndpoint bucketRegion = RegionEndpoint.GetBySystemName(EnvironmentHandler.GetEnvironmentHandler().GetVariable("BucketRegion"));

            S3Config.RegionEndpoint = bucketRegion;

            S3Client = new MyAmazonS3Client(S3Config);
        }
Beispiel #4
0
        /// <summary>
        /// Entry point for the BlogPost Handler.
        /// </summary>
        /// <param name="blogPost">The Incoming BlogPost</param>
        /// <param name="context">The Lambda event context</param>
        /// <returns></returns>
        public BlogPost FunctionHandler(BlogPost blogPost, ILambdaContext context)
        {
            // not using a separate logic layer because this _is_ the logic layer
            LambdaLogger.Log("BlogPostHandler Lambda Started");

            // Config/Initialization
            EnvironmentHandler env = EnvironmentHandler.GetEnvironmentHandler();

            string bucketName         = env.GetVariable("BucketName");
            string bucketRegionString = env.GetVariable("BucketRegion");
            string postsDirectory     = env.GetVariable("PostsDirectory");
            string imagesDirectory    = env.GetVariable("ImagesDirectory");
            string metaDirectory      = env.GetVariable("MetaDirectory");

            // get blog post
            BlogPostS3Access blogPostAccess = new BlogPostS3Access(bucketName, bucketRegionString);

            blogPostAccess.Logger = context.Logger;

            var blogPostResponse = blogPostAccess.GetBlogPost(blogPost);

            blogPostResponse.Wait();
            blogPost = blogPostResponse.Result;

            if (blogPost.Metadata != null)
            {
                // get related posts
                TagFileS3Access tagFileAccess = new TagFileS3Access();
                tagFileAccess.Logger = context.Logger;
                var relatedPostsResponse = tagFileAccess.GetBlogPostIdsFromTags(blogPost.Metadata.Tags);
                relatedPostsResponse.Wait();
                blogPost.RelatedPosts = relatedPostsResponse.Result;

                // remove all related posts which are the current post
                blogPost.RelatedPosts.RemoveAll(b => b.Id == blogPost.Id);

                // populate related posts objects
                for (int i = 0; i < blogPost.RelatedPosts.Count; i++)
                {
                    var relatedPostResponse = blogPostAccess.GetBlogPost(blogPost.RelatedPosts[i]);
                    relatedPostResponse.Wait();
                    blogPost.RelatedPosts[i] = relatedPostResponse.Result;

                    // remove Markdown identifiers in the teaser content text, as it shows up
                    // as a related post
                    blogPost.RelatedPosts[i].Content = StringHelper.StripMarkdownIdentifiers(blogPost.RelatedPosts[i].Content);
                }
            }
            else
            {
                return(null);
            }

            return(blogPost);
        }
Beispiel #5
0
        public ExeResult UserLogin(SYS_UserAccountParam param)
        {
            string ipAddress  = EnvironmentHandler.GetNetCardIP();
            string macAddress = EnvironmentHandler.GetNetCardMAC(ipAddress);

            param.ClientIP    = ipAddress;
            param.MacAddress  = macAddress;
            param.HardSN      = EnvironmentHandler.GetHardSN();
            param.PartnerCode = MySession.PartnerCode;
            //string usedQuoteAgent = ManagerAppConfig.GetAppConfig(Constant.EnableQuoteAgent);
            //param.IsSearchByNew = string.IsNullOrEmpty(usedQuoteAgent) || usedQuoteAgent == "1";

            MySession.ClientIP   = ipAddress;
            MySession.MacAddress = macAddress;
            return(WCFBLL.Execute("ZNLCRM.BLL.Account.SYS_UserAccountBLL", "UserLogin", param));
        }
        public void SanityTest_IdOfOne_ReturnsTrue()
        {
            // Invoke the lambda function and confirm the string was upper cased.
            var function = new Function();
            var context  = new TestLambdaContext();

            EnvironmentHandler.GetEnvironmentHandler().SetVariable("bucketRegion", "test");
            EnvironmentHandler.GetEnvironmentHandler().SetVariable("BucketName", "test");
            EnvironmentHandler.GetEnvironmentHandler().SetVariable("BucketRegion", "test");
            EnvironmentHandler.GetEnvironmentHandler().SetVariable("PostsDirectory", "test");
            EnvironmentHandler.GetEnvironmentHandler().SetVariable("ImagesDirectory", "test");
            EnvironmentHandler.GetEnvironmentHandler().SetVariable("MetaDirectory", "test");


            var idOfOne = function.FunctionHandler(new BlogPost(1), context);

            Assert.AreEqual(idOfOne, new BlogPost(1));
        }
Beispiel #7
0
        public async Task <BlogPost> GetBlogPost(BlogPost blogPost)
        {
            var environmentHandler = EnvironmentHandler.GetEnvironmentHandler();

            // get post contents
            string keyName = blogPost.Id.ToString();

            var content = await GetBlogPostContent(blogPost, environmentHandler.GetVariable("PostsDirectory"), keyName); //TODO remove keyName since its the id of the blogpost

            blogPost.Content = content;

            // get post metadata
            var metadata = await GetBlogPostMetadata(blogPost, environmentHandler.GetVariable("MetaDirectory"), keyName);

            blogPost.Metadata = metadata;

            return(blogPost);
        }
Beispiel #8
0
        // what is the wisdom of my base object retrieval class getting things as strings?
        public virtual async Task <TagFile> GetTagFile()
        {
            // use GetObject to retrieve the TagFile
            string tagFileContents = await GetObject(new GetObjectRequest
            {
                BucketName = EnvironmentHandler.GetEnvironmentHandler().GetVariable("BucketName"),
                Key        = TagFileS3Access.TagFileName
            });

            // parse string into TagFile
            // each line is one entry
            string[] lines = tagFileContents.Split("\n", StringSplitOptions.RemoveEmptyEntries);

            if (tagFileContents == string.Empty)
            {
                throw new TagFileException("Exception - Empty TagFile.");
            }

            TagFile tagFile = new TagFile();

            for (int i = 0; i < lines.Length; i++)
            {
                var line = lines[i];

                // parse each line - split on '-'; LHS is tag, RHS is array of ids
                string[] lineContents = line.Split('-');

                if (lineContents.Length != 2)
                {
                    throw new TagFileException($"there is an issue with tagfile format on line {i}.");
                }

                List <string> ids = lineContents[1].Split(',').ToList();

                tagFile.AddEntry(lineContents[0], new SortedSet <string>(ids));
            }

            return(tagFile);
        }
Beispiel #9
0
        public void Load(string romPath)
        {
            if (AudioSampleBatchPassthroughHandler == null)
            {
                _audioSampleBatchHandler = new AudioSampleBatchHandler(audioSampleBatchCallback);
            }
            else
            {
                _audioSampleBatchHandler = AudioSampleBatchPassthroughHandler;
            }

            if (InputStatePassthroughHandler == null)
            {
                _inputStateHandler = new InputStateHandler(inputStateCallback);
            }
            else
            {
                _inputStateHandler = InputStatePassthroughHandler;
            }

            if (VideoFramePassthroughHandler == null)
            {
                _videoRefreshHandler = new VideoRefreshHandler(videoRefreshCallback);
            }
            else
            {
                _videoRefreshHandler = VideoFramePassthroughHandler;
            }

            _audioSampleHandler = new AudioSampleHandler(audioSampleCallback);
            _environmentHandler = new EnvironmentHandler(environmentCallback); // options for passing through some commands need to be done here
            _inputPollHandler   = new InputPollHandler(inputPollCallback);

            _setEnvironment(_environmentHandler);
            _setVideoRefresh(_videoRefreshHandler);
            _setInputPoll(_inputPollHandler);
            _setInputState(_inputStateHandler);
            _setAudioSample(_audioSampleHandler);
            _setAudioSampleBatch(_audioSampleBatchHandler);

            _init();

            byte[] romBytes        = File.ReadAllBytes(romPath);
            IntPtr romBytesPointer = Marshal.AllocHGlobal(romBytes.Length);

            Marshal.Copy(romBytes, 0, romBytesPointer, romBytes.Length);
            GameInfo gameInfo = new GameInfo()
            {
                Path = romPath, Data = romBytesPointer, Size = (uint)romBytes.Length, Meta = null
            };

            _loadGame(ref gameInfo);
            Marshal.FreeHGlobal(romBytesPointer);

            _systemInfo = new SystemInfo();
            _getSystemInfo(out _systemInfo);
            _systemInfo.LibraryName     = Marshal.PtrToStringAnsi(_systemInfo.LibraryNameAddress);
            _systemInfo.LibraryVersion  = Marshal.PtrToStringAnsi(_systemInfo.LibraryVersionAddress);
            _systemInfo.ValidExtensions = Marshal.PtrToStringAnsi(_systemInfo.ValidExtensionsAddress);

            _systemAVInfo = new SystemAVInfo();
            _getSystemAVInfo(out _systemAVInfo);

            _framePeriodNanoseconds = (long)(1000000000 / _systemAVInfo.Timing.FPS);

            StateSize   = (int)_serializeSize();
            _ramAddress = _getMemoryData(MemoryType.RAM);
            _ramSize    = (int)_getMemorySize(MemoryType.RAM);
        }