예제 #1
0
        public void Initialize()
        {
            CorbaUtility.Initialize();
            LogManager.Initialize();

            var ns = MockFactory.CreateNamingService("127.0.0.1", 2809);

            ns.RtObjects = new Dictionary <string, RTObject>()
            {
                { "SampleOut0.rtc", MockFactory.CreateRTObject("SampleOut", "SampleOut0",
                                                               MockFactory.CreateOutPortService("SampleOut0.out", "IDL:RTC.TimedLong:1.0")) },
            };
            NamingServiceManager.Default.AddNamingService(new NamingService(ns));

            SettingHolder.BaseDirectory = TestDataDirectory;

            if (Directory.Exists(TestDataDirectory))
            {
                Directory.Delete(TestDataDirectory, true);
                while (Directory.Exists(TestDataDirectory))
                {
                    //完全に消えるまで待つ
                    Thread.Sleep(10);
                }
            }
        }
예제 #2
0
        public void Initialize()
        {
            CorbaUtility.Initialize();
            LogManager.Initialize();

            var subject = new Subject <byte[]>();

            _observer = subject.AsObservable();

            var ns = MockFactory.CreateNamingService("127.0.0.1", 2809);

            ns.RtObjects = new Dictionary <string, RTObject>()
            {
                { "SampleIn0.rtc", MockFactory.CreateRTObject("SampleIn", "SampleIn0",
                                                              MockFactory.CreateInPortService("SampleIn0.in", "IDL:RTC.TimedLong:1.0",
                                                                                              new DelegateInPortCdr(_ => {
                        subject.OnNext(_);
                        return(PortStatus.PORT_OK);
                    }))) },
            };
            NamingServiceManager.Default.AddNamingService(new NamingService(ns));

            SettingHolder.BaseDirectory = TestDataDirectory;
        }
예제 #3
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            DispatcherHelper.UIDispatcher = Dispatcher;


            NativeTime.BeginPeriod(1);

            CorbaUtility.Initialize();
            LogManager.Initialize();
            SettingHolder.BaseDirectory = Settings.Default.DataDirectory;


            var dir = SettingHolder.BaseDirectory;

            try
            {
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                // データベースファイルが見つからなかった場合は、空のファイルを作成
                var filePath = dir + "RecordDescriptions.db";
                if (!File.Exists(filePath))
                {
                    using (var writer = new BinaryWriter(File.Create(filePath)))
                    {
                        writer.Write(RtStorage.Properties.Resources.RecordDescriptions);
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: ユーザーへのエラー通知が必要
            }

#if !USE_MOCK
            NamingServiceManager.Default.Initialize();
#endif

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
#endif

#if USE_MOCK
            var ns     = MockFactory.CreateNamingService("MockServer", 2809);
            var inport = new DelegateInPortCdr(_ => PortStatus.PORT_OK);
            ns.RtObjects = new Dictionary <string, RTObject>()
            {
                { "SampleIn0.rtc", MockFactory.CreateRTObject("SampleIn", "SampleIn0",
                                                              MockFactory.CreateInPortService("SampleIn0.in", "IDL:RTC/TimedLong:1.0", inport)) },
                { "SampleIn1.rtc", MockFactory.CreateRTObject("SampleIn", "SampleIn1",
                                                              MockFactory.CreateInPortService("SampleIn1.in", "IDL:RTC/TimedLong:1.0", inport)) },
                { "SampleOut0.rtc", MockFactory.CreateRTObject("SampleOut", "SampleOut0",
                                                               MockFactory.CreateOutPortService("SampleOut0.out", "IDL:RTC/TimedLong:1.0")) },
                { "SampleOut1.rtc", MockFactory.CreateRTObject("SampleOut", "SampleOut1",
                                                               MockFactory.CreateOutPortService("SampleOut1.out", "IDL:RTC/TimedLong:1.0")) },
            };

            Observable.Start(() => {
                NamingServiceManager.Default.AddNamingService(new NamingService(ns));
                NamingServiceManager.Default.UpdateAsync();
            });


            var repository = RepositoryFactory.CreateRepository();

            var data = new List <RecordDescription>()
            {
                new RecordDescription()
                {
                    CreatedDateTime = DateTime.Now,
                    TimeSpan        = 10000,
                    NamingName      = "MockServer/ConsoleIn0.rtc",
                    ComponentType   = "ConsoleIn",
                    PortName        = "ConsoleIn0.out",
                    DataType        = "IDL:RTC/TimedLong:1.0",
                    SumSize         = 120000000000,
                    Count           = 10,
                    IsLittleEndian  = 1,
                    IndexFileName   = "Data/hoge.index",
                    DataFileName    = "Data/hoge.data",
                },
                new RecordDescription()
                {
                    CreatedDateTime = DateTime.Now,
                    TimeSpan        = 10000,
                    NamingName      = "MockServer/SampleInOut0.rtc",
                    ComponentType   = "SampleInOut",
                    PortName        = "SampleInOut0.in",
                    DataType        = "IDL:RTC/TimedDouble:1.0",
                    SumSize         = 120,
                    Count           = 10,
                    IsLittleEndian  = 1,
                    IndexFileName   = "Data/hoge.index",
                    DataFileName    = "Data/hoge.data",
                },
                new RecordDescription()
                {
                    CreatedDateTime = DateTime.Now,
                    TimeSpan        = 10000,
                    NamingName      = "MockServer/SampleInOut0.rtc",
                    ComponentType   = "SampleInOut",
                    PortName        = "SampleInOut0.out",
                    DataType        = "IDL:RTC/TimedDouble:1.0",
                    SumSize         = 120,
                    Count           = 10,
                    IsLittleEndian  = 1,
                    IndexFileName   = "Data/hoge.index",
                    DataFileName    = "Data/hoge.data",
                },
                new RecordDescription()
                {
                    CreatedDateTime = DateTime.Now,
                    TimeSpan        = 10000,
                    NamingName      = "MockServer/SampleComp0.rtc",
                    ComponentType   = "SampleComp",
                    PortName        = "SampleComp0.out",
                    DataType        = "IDL:RTC/TimedString:1.0",
                    SumSize         = 120,
                    Count           = 10,
                    IsLittleEndian  = 1,
                    IndexFileName   = "Data/hoge.index",
                    DataFileName    = "Data/hoge.data",
                }
            };

            data.ForEach(repository.Insert);



            // 通信遅延を発生させて、UIがロックしないことを確認する
            //MockProxy<NamingServiceMock>.WaitTime = TimeSpan.FromSeconds(1);
            //MockProxy<MockRecordDescriptionRepository>.WaitTime = TimeSpan.FromSeconds(1);

            // ネーミングサービスに接続できないエラーが発生した場合の挙動を確認する。
            //MockProxy<NamingServiceMock>.ErrorMap.Add("GetObjectNames", new TRANSIENT());

            // ネーミングサービスに登録されていたコンポーネントに接続できない場合の挙動を確認する
            //MockProxy<RTObjectMock>.ErrorMap.Add("get_ports", new TRANSIENT());
            //MockProxy<RTObjectMock>.ErrorMap.Add("get_component_profile", new TRANSIENT());

            //MockProxy<MockRecordDescriptionRepository>.ErrorMap.Add("*", new Exception());
#endif
        }