public async Task <ActionResult <Subcommand> > PostSubcommand(Subcommand subcommand)
        {
            _context.Subcommands.Add(subcommand);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSubcommand", new { id = subcommand.Id_subcommand }, subcommand));
        }
        public async Task <IActionResult> PutSubcommand(int id, Subcommand subcommand)
        {
            if (id != subcommand.Id_subcommand)
            {
                return(BadRequest());
            }

            _context.Entry(subcommand).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubcommandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
0
        public void ReturnᅠSuccessᅠvalidationᅠresponse(string projectName)
        {
            Subcommand.SetResolvedName(projectName);

            Validate().Should().NotBeNull().And.BeOfType <ValidationResult>();
            Validate().IsValid.Should().BeTrue();
            Validate().Message.Should().BeEmpty();
        }
Пример #4
0
#pragma warning restore xUnit1019 // MemberData must reference a member providing a valid data type
        public void Returnᅠinvalidᅠvalidationᅠresponseᅠwithᅠerrorᅠmessage(string projectName, string errorMessage)
        {
            Subcommand.SetResolvedName(projectName);

            Validate().Should().NotBeNull().And.BeOfType <ValidationResult>();
            Validate().IsValid.Should().BeFalse();
            Validate().Message.Should().Be(errorMessage);
        }
Пример #5
0
        public void CallCorrectClassWithGoodInputs(string[] parameters, Subcommand expectedSubcommand)
        {
            var restParams = parameters.Skip(1).ToArray();

            Assert.IsTrue(ParameterResolver.DelegateToSubcommands(_factoryMock.Object, parameters).Success);
            var expectedCommandMock = expectedSubcommand == Subcommand.Sln ? _slnMock : _opcuaAppMock;

            expectedCommandMock.Verify(c => c.Execute(restParams), Times.Once);
        }
Пример #6
0
            protected override Tuple <T1, T2>[] Read(long count, RedisReader reader)
            {
                var array = new Tuple <T1, T2> [count / 2];

                for (int i = 0; i < count; i += 2)
                {
                    array[i / 2] = Subcommand.Parse(reader);
                }
                return(array);
            }
    //Separate method, you need to decide access modifier and parameters as per your requirement
    public DataFormatter Build()
    {
        Command       cmd2 = new Command(Commands.CommandsEnum.Run);
        DataFormatter df2  = new DataFormatter();

        df2._Command = cmd2;
        Subcommand scmd2 = new Subcommand();

        scmd2.Action         = Action;
        scmd2.ID             = ID;
        scmd2.NewValueString = NewText;
        scmd2.Type           = Type;
        df2._Subcommand      = scmd2;
        return(df2);
    }
Пример #8
0
        internal static byte[] ToBytes(this Subcommand subcommand)
        {
            var result = RedisConstants.RefCount;

            if (subcommand == Subcommand.IdleTime)
            {
                result = RedisConstants.IdleTime;
            }
            else if (subcommand == Subcommand.Encoding)
            {
                result = RedisConstants.ObjEncoding;
            }

            return(result);
        }
Пример #9
0
    public static Report ReadSPI(int addr, byte size, IntPtr handle)
    {
        var sc = new Subcommand(SubcommandType.SPIFlashRead)
                 .PackInt32(addr)
                 .PackByte(size);

        var report = new Report(sc.Send(handle), DateTime.Now);

        report.Seek(15);
        if (report.ReadInt32() != addr || report.ReadByte() != size)
        {
            Debug.Log(string.Format("Invalid SPI report: {0}", Helper.ByteArrayToString(report.dataBuffer)));
            return(null);
        }

        return(report);
    }
Пример #10
0
    public static void SetMCUMode(byte mode, IntPtr handle)
    {
        bool mcuReady = false;

        while (!mcuReady)
        {
            var result = new Subcommand(SubcommandType.SetNFCOrIRMCUConfiguration)
                         .PackByte(0x21)
                         .PackByte(0x00)
                         .PackByte(mode).Send(handle);
            if (result[0] == 0x21)
            {
                if (result[15] == 0x01 && result[22] == 0x01)                 // MCU state is Standby
                {
                    mcuReady = true;
                }
            }
        }
    }
Пример #11
0
    public static void RequestMCUModeStatus(IntPtr handle)
    {
        bool mcuReady = false;

        while (!mcuReady)
        {
            var result = new Subcommand(SubcommandType.BluetoothManualPairing).Send(handle);
            if (result[0] == 0x31)
            {
                //if (result[49] == 0x01 && result[56] == 0x06) // MCU state is Initializing
                // *(u16*)result[52]LE x04 in lower than 3.89fw, x05 in 3.89
                // *(u16*)result[54]LE x12 in lower than 3.89fw, x18 in 3.89
                // result[56]: mcu mode state
                if (result[49] == 0x01 && result[56] == 0x01)                 // MCU state is Standby
                {
                    mcuReady = true;
                }
            }
        }
    }
        /// <summary>
        /// Todo: document this
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public DataFormatter Build(string command)
        {
            Enum.TryParse <Commands.CommandsEnum>(command, out enumResult);
            Command       cmd2 = new Command(enumResult);
            DataFormatter df2  = new DataFormatter();

            df2._Command = cmd2;
            Subcommand scmd2 = new Subcommand();

            scmd2.Action         = Action;
            scmd2.ID             = ID;
            scmd2.NewValueString = NewText;
            scmd2.Type           = Type;
            df2._Subcommand      = scmd2;
            Action  = "";
            ID      = "";
            NewText = "";
            Type    = "";
            return(df2);
        }
Пример #13
0
 public Task<RedisResponse> ObjectAsync(Subcommand subcommand, params string[] args)
 {
     var request = ComposeRequest(RedisConstants.Object, subcommand.ToBytes(), args);
     return ExecuteRedisCommand(request);
 }
Пример #14
0
        public Task <RedisResponse> ObjectAsync(Subcommand subcommand, params string[] args)
        {
            var request = ComposeRequest(RedisConstants.Object, subcommand.ToBytes(), args);

            return(ExecuteRedisCommand(request));
        }