Exemple #1
0
        public Protocol MapFrom(ApplicationProtocol batchProtocol)
        {
            var applicationType  = ApplicationTypes.ByName(batchProtocol.ApplicationType);
            var dosingIntervalId = EnumHelper.ParseValue <DosingIntervalId>(batchProtocol.DosingInterval);
            var simpleProtocol   = _protocolFactory.Create(ProtocolMode.Simple, applicationType).DowncastTo <SimpleProtocol>();

            simpleProtocol.Name = batchProtocol.Name ?? "Protocol";
            simpleProtocol.EndTimeParameter.Value = batchProtocol.EndTime;
            simpleProtocol.Dose.DisplayUnit       = simpleProtocol.Dose.Dimension.Unit(batchProtocol.DoseUnit);
            simpleProtocol.Dose.Value             = simpleProtocol.Dose.Dimension.UnitValueToBaseUnitValue(simpleProtocol.Dose.DisplayUnit, batchProtocol.Dose);
            simpleProtocol.DosingInterval         = DosingIntervals.ById(dosingIntervalId);

            _logger.AddDebug($"Application Type = {applicationType.Name}");
            _logger.AddDebug($"Dosing Interval = {simpleProtocol.DosingInterval.DisplayName}");
            _logger.AddDebug($"Application Dose = {simpleProtocol.Dose.Value} [{simpleProtocol.Dose.DisplayUnit}]");
            _logger.AddDebug($"Application End Time = {simpleProtocol.EndTime}");

            return(simpleProtocol);
        }
        public async Task TestConnect()
        {
            using QuicListener listener = CreateQuicListener();

            using QuicConnection clientConnection = CreateQuicConnection(listener.ListenEndPoint);

            Assert.False(clientConnection.Connected);
            Assert.Equal(listener.ListenEndPoint, clientConnection.RemoteEndPoint);

            ValueTask connectTask = clientConnection.ConnectAsync();
            ValueTask <QuicConnection> acceptTask = listener.AcceptConnectionAsync();

            await new Task[] { connectTask.AsTask(), acceptTask.AsTask() }.WhenAllOrAnyFailed(PassingTestTimeoutMilliseconds);
            QuicConnection serverConnection = acceptTask.Result;

            Assert.True(clientConnection.Connected);
            Assert.True(serverConnection.Connected);
            Assert.Equal(listener.ListenEndPoint, serverConnection.LocalEndPoint);
            Assert.Equal(listener.ListenEndPoint, clientConnection.RemoteEndPoint);
            Assert.Equal(clientConnection.LocalEndPoint, serverConnection.RemoteEndPoint);
            Assert.Equal(ApplicationProtocol.ToString(), clientConnection.NegotiatedApplicationProtocol.ToString());
            Assert.Equal(ApplicationProtocol.ToString(), serverConnection.NegotiatedApplicationProtocol.ToString());
        }
Exemple #3
0
        public async Task TestConnect()
        {
            using QuicListener listener = CreateQuicListener();
            IPEndPoint listenEndPoint = listener.ListenEndPoint;

            using QuicConnection clientConnection = CreateQuicConnection(listenEndPoint);

            Assert.False(clientConnection.Connected);
            Assert.Equal(listenEndPoint, clientConnection.RemoteEndPoint);

            ValueTask      connectTask      = clientConnection.ConnectAsync();
            QuicConnection serverConnection = await listener.AcceptConnectionAsync();

            await connectTask;

            Assert.True(clientConnection.Connected);
            Assert.True(serverConnection.Connected);
            Assert.Equal(listenEndPoint, serverConnection.LocalEndPoint);
            Assert.Equal(listenEndPoint, clientConnection.RemoteEndPoint);
            Assert.Equal(clientConnection.LocalEndPoint, serverConnection.RemoteEndPoint);
            Assert.Equal(ApplicationProtocol.ToString(), clientConnection.NegotiatedApplicationProtocol.ToString());
            Assert.Equal(ApplicationProtocol.ToString(), serverConnection.NegotiatedApplicationProtocol.ToString());
        }
        private async Task ContactTracker()
        {
            Log.LogInformation("Contacting tracker");

            try
            {
                var request = new AnnounceRequest(
                    localPeerId,
                    Remaining,
                    Description.InfoHash);

                var result = await Tracker.Announce(request);

                Log.LogInformation($"{result.Peers.Count} peers available");

                ApplicationProtocol.PeersAvailable(result.Peers);
            }
            catch (System.Net.Http.HttpRequestException)
            {
                // Cannot connect to tracker
                State = DownloadState.Error;
            }
        }
        private void exportToFolder(string exportFolder)
        {
            var defaultIndividual = _defaultIndividualRetriever.DefaultHuman();
            var batchSimulation   = new Simulation();

            batchSimulation.Individual = new Individual
            {
                Age        = defaultIndividual.Age,
                Height     = defaultIndividual.MeanHeight,
                Species    = defaultIndividual.Species.Name,
                Population = defaultIndividual.Population.Name,
            };

            batchSimulation.Compounds.Add(new Compound {
                Name = "Standard Molecule", Lipophilicity = 3, FractionUnbound = 0.1, MolWeight = 4E-7, SolubilityAtRefpH = 9999, RefpH = 7
            });
            var intrevanousBolus = new ApplicationProtocol {
                CompoundName = "Standard Molecule", ApplicationType = CoreConstants.Application.Name.IntravenousBolus, Dose = 1, DoseUnit = "mg/kg", DosingInterval = DosingIntervals.Single.ToString()
            };


            batchSimulation.Configuration = new SimulationConfiguration {
                Model = CoreConstants.Model.FourComp
            };
            batchSimulation.ApplicationProtocols.Add(intrevanousBolus);
            var fourCompIvBolusMgPerKg = configurationFrom(batchSimulation);

            batchSimulation.Configuration = new SimulationConfiguration {
                Model = CoreConstants.Model.TwoPores
            };
            var twoPore = configurationFrom(batchSimulation);

            batchSimulation.ApplicationProtocols.Clear();
            intrevanousBolus.DoseUnit = "mg";
            batchSimulation.ApplicationProtocols.Add(intrevanousBolus);
            batchSimulation.Configuration = new SimulationConfiguration {
                Model = CoreConstants.Model.FourComp
            };
            var fourCompIvBolusMg = configurationFrom(batchSimulation);


            twoPore.SpatialStructure.Name  = "Human 2 Pores";
            twoPore.PassiveTransports.Name = "2 Pores Passive Transports";

            fourCompIvBolusMgPerKg.SpatialStructure.Name  = "Human Standard";
            fourCompIvBolusMgPerKg.PassiveTransports.Name = "Standard Passive Transports";
            fourCompIvBolusMgPerKg.EventGroups.Name       = "IV Bolus";
            fourCompIvBolusMgPerKg.Molecules.Name         = "Standard Molecule";
            fourCompIvBolusMgPerKg.Observers.Name         = "Standard Observer";


            fourCompIvBolusMg.EventGroups.Name = "IV Bolus (mg)";

            var defaultCompound = fourCompIvBolusMgPerKg.Molecules.First();

            defaultCompound.Name = string.Empty;
            defaultCompound.Parameter(CoreConstants.Parameter.LIPOPHILICITY).Value     = double.NaN;
            defaultCompound.Parameter(CoreConstants.Parameter.MOLECULAR_WEIGHT).Value  = double.NaN;
            defaultCompound.Parameter(CoreConstants.Parameter.FractionUnbound).Value   = double.NaN;
            defaultCompound.Parameter(CoreConstants.Parameter.SolubilityAtRefpH).Value = double.NaN;

            _moBiExportTask.UpdateObserverForAllFlag(fourCompIvBolusMgPerKg.Observers);

            var buildingBlocks = new IBuildingBlock[]
            {
                twoPore.SpatialStructure, twoPore.PassiveTransports,
                fourCompIvBolusMgPerKg.SpatialStructure, fourCompIvBolusMgPerKg.PassiveTransports, fourCompIvBolusMgPerKg.EventGroups, fourCompIvBolusMgPerKg.Molecules, fourCompIvBolusMgPerKg.Observers,
                fourCompIvBolusMg.EventGroups
            };

            buildingBlocks.Each(bb => saveToPKML(bb, exportFolder));
        }
Exemple #6
0
        private void ProccessJson(WorkSocket workSocket, byte[] payLoad)
        {
            ApplicationProtocol ap = MakeJson.getApplicationProtocol(payLoad);

            updateInfo(ap.type + ":" + ap.content, MyConfig.INT_UPDATEUI_TXBOX);
            switch (ap.type)
            {
            case AppProtocol.json_type_req_local_check:
                CheckPsw(workSocket, ap.content);
                break;

            case AppProtocol.json_type_req_local_open_shadow:
                if (serverWorkStatus == MyConfig.SERVER_WORK_STATUS_FREE)
                {
                    CreateShadowContainer(workSocket, ap.content + "|" + orientation);
                }
                else
                {
                    SendMsgToClient(workSocket, AppProtocol.json_type_notify_back_shadow_open_fail, "服务端被占用");
                }
                break;

            case AppProtocol.json_type_req_local_close_shadow:
                closeShadowForm(workSocket);
                break;

            case AppProtocol.json_type_req_local_open_mouse:
                if (serverWorkStatus == MyConfig.SERVER_WORK_STATUS_FREE)
                {
                    startMouseMode(workSocket);
                }
                else
                {
                    SendMsgToClient(workSocket, AppProtocol.json_type_notify_back_shadow_open_fail, "服务端被占用");
                }
                break;

            case AppProtocol.json_type_req_local_close_mouse:
                closeMouseMode(workSocket);
                break;

            case AppProtocol.json_type_req_local_repeat_conn:
                repeatConn(workSocket, ap.content);
                break;

            case AppProtocol.json_type_req_local_refresh_screen:
                deskWidth  = Int32.Parse(ap.content.Split('|')[0]);
                deskHeight = Int32.Parse(ap.content.Split('|')[1]);
                break;

            case AppProtocol.json_type_cmd_mouse_event_move:
                MoveMouse(ap.content);
                break;

            case AppProtocol.json_type_cmd_mouse_event_esc:
                ClickMouse(ap.type);
                break;

            case AppProtocol.json_type_cmd_mouse_event_l_down:
                ClickMouse(ap.type);
                break;

            case AppProtocol.json_type_cmd_mouse_event_l_up:
                ClickMouse(ap.type);
                break;

            case AppProtocol.json_type_cmd_mouse_event_r_down:
                ClickMouse(ap.type);
                break;

            case AppProtocol.json_type_cmd_mouse_event_r_up:
                ClickMouse(ap.type);
                break;

            case AppProtocol.json_type_cmd_mouse_event_page_up:
                ClickMouse(ap.type);
                break;

            case AppProtocol.json_type_cmd_mouse_event_page_down:
                ClickMouse(ap.type);
                break;
            }
        }
Exemple #7
0
 public void Visit(ApplicationProtocol protocol)
 {
     _coreObject = _protocolMapper.MapFrom(protocol);
 }
Exemple #8
0
 public ProtocolStack(ApplicationProtocol applicationProtocol, IList <ModifierProtocol> modifierProtocols)
 {
     this._applicationProtocol = applicationProtocol;
     this._modifierProtocols   = Collections.unmodifiableList(modifierProtocols);
 }
Exemple #9
0
 public virtual Builder Application(ApplicationProtocol applicationProtocol)
 {
     this.ApplicationProtocol = applicationProtocol;
     return(this);
 }