Beispiel #1
0
 public Pv2ClientRxParam(IPv2ClientParamsInterface paramSvc, TParamType param)
 {
     _paramSvc  = paramSvc;
     _param     = param;
     _subscribe = _paramSvc.CurrentAndThenOnUpdated
                  .Filter <TParamType, TParamValue, TValue>(param)
                  .Subscribe(this);
 }
Beispiel #2
0
        public static bool ReadBool(this IPv2ClientParamsInterface src, Pv2ParamType param)
        {
            if (param is not Pv2BoolParamType type)
            {
                throw new Exception($"Wrong type: want {nameof(Pv2BoolParamType)}. Got {param.GetType().Name}");
            }
            var item = src.Read(param);

            return(type.GetValue(item));
        }
Beispiel #3
0
        public static async Task <bool> WriteBool(this IPv2ClientParamsInterface src, Pv2ParamType param, bool value,
                                                  CancellationToken cancel = default)
        {
            if (param is not Pv2BoolParamType type)
            {
                throw new Exception($"Wrong type: want {nameof(Pv2BoolParamType)}. Got {param.GetType().Name}");
            }
            var result = await src.Write(param, (_, val) => type.SetValue(val, value), cancel).ConfigureAwait(false);

            return(type.GetValue(result));
        }
Beispiel #4
0
        public static void CreateParams(out IPv2ClientParamsInterface clientParams,
                                        out IPv2ServerParamsInterface serverParams, IEnumerable <Pv2ParamType> paramsList)
        {
            var cfg    = new InMemoryConfiguration();
            var server = CreateServer(out var port);
            var client = CreateClient(port);

            clientParams = new Pv2ClientParamsInterface(client, Pv2CfgDescriptionEmptyStore.Default, cfg);
            serverParams = new Pv2ServerParamsInterface(server, cfg, paramsList);
            WaitUntilConnect(client);
        }