コード例 #1
0
        private static string ImplementationForCmdParse()
        {
            //case eCommandType::SET_SIGNAL: OnSET_SIGNALCommand(ParseUInt16(payload, 0), now); break;
            StringBuilder sb = new StringBuilder();

            foreach (MethodInfo mi in typeof(SensactApplication).GetMethods())
            {
                if (mi.GetCustomAttribute <SensactCommandMethod>() == null)
                {
                    continue;
                }
                sb.AppendFormat("\tcase eCommandType::{0}: {1}(", SensactApplication.ExtractCmdName(mi), mi.Name);
                int offset = 0;
                foreach (ParameterInfo pi in mi.GetParameters())
                {
                    sb.Append(CS2CPPParser(pi.ParameterType, ref offset));
                    sb.Append(", ");
                }
                sb.AppendLine("now); break;");
            }
            return(sb.ToString());
        }
コード例 #2
0
        protected void GenerateParseCommand()
        {
            //case eCommandType::SET_SIGNAL: OnSET_SIGNALCommand(ParseUInt16(payload, 0), now); break;
            StringBuilder sb = new StringBuilder();

            foreach (MethodInfo mi in typeof(SensactApplication).GetMethods())
            {
                if (mi.GetCustomAttribute <SensactCommandMethod>() == null)
                {
                    continue;
                }
                sb.AppendFormat("\tcase sensact::eCommandType::{0}: app->{1}(", SensactApplication.ExtractCmdName(mi), mi.Name);
                int offset = 0;
                foreach (ParameterInfo pi in mi.GetParameters())
                {
                    sb.Append(CS2CPPParser(pi.ParameterType, ref offset));
                    sb.Append(", ");
                }
                sb.AppendLine("ctx); break;");
            }
            WriteCommonFile("parseCommand", sb);
            LOG.LogInformation("Successfully created parseCommand");
        }
コード例 #3
0
        private void GenerateSendCommandDeclarations(bool TrueIfVirtualFalseIfOverride)
        {
            StringBuilder sb = new StringBuilder();

            //void OnSTOPCommand(uint8_t *payload, uint8_t payloadLength, SensactContext *ctx) override;
            foreach (MethodInfo m in typeof(SensactApplication).GetMethods())
            {
                if (m.GetCustomAttribute <SensactCommandMethod>() == null)
                {
                    continue;
                }
                sb.Append("\t");
                if (TrueIfVirtualFalseIfOverride)
                {
                    sb.Append("virtual ");
                }
                sb.AppendFormat("void Send{0}Command(sensact::eApplicationID destinationApp", SensactApplication.ExtractCmdName(m));

                foreach (ParameterInfo pi in m.GetParameters())
                {
                    sb.Append(", ");
                    sb.Append(CS2CPPType(pi.ParameterType));
                    sb.Append(" " + pi.Name);
                }
                if (TrueIfVirtualFalseIfOverride)
                {
                    sb.AppendLine(")=0;");
                }
                else
                {
                    sb.AppendLine(") override;");
                }
            }

            if (TrueIfVirtualFalseIfOverride)
            {
                WriteCommonFile("sendCommandDeclarationsVirtual", sb);
            }
            else
            {
                WriteCommonFile("sendCommandDeclarationsOverride", sb);
            }
        }
コード例 #4
0
        protected void GenerateEmptyImplementationForCmdHandler()
        {
            //case eCommandType::SET_SIGNAL: OnSET_SIGNALCommand(ParseUInt16(payload, 0), now); break;
            StringBuilder sb = new StringBuilder();

            foreach (MethodInfo mi in typeof(SensactApplication).GetMethods())
            {
                if (mi.GetCustomAttribute <SensactCommandMethod>() == null)
                {
                    continue;
                }
                sb.AppendFormat("\tvoid cApplication::{0}(", mi.Name);
                foreach (ParameterInfo pi in mi.GetParameters())
                {
                    sb.Append(CS2CPPType(pi.ParameterType));
                    sb.Append(" " + pi.Name + ", ");
                }
                sb.AppendLine("SensactContext *ctx)");
                sb.AppendLine("\t{");
                foreach (ParameterInfo pi in mi.GetParameters())
                {
                    sb.AppendLine("\t\t(void)(" + pi.Name + ");");
                }
                sb.AppendLine("\t\t(void)(ctx);");
                sb.AppendLine("\t\tLOGE(\"Application %s does not support Command " + SensactApplication.ExtractCmdName(mi) + "\", N());");
                sb.AppendLine("\t}");
                sb.AppendLine();
            }
            WriteCommonFile("cmdHandler", sb);
        }
コード例 #5
0
        protected void GenerateSendCommandImplementation()
        {
            StringBuilder sb = new StringBuilder();

            foreach (MethodInfo mi in typeof(SensactApplication).GetMethods())
            {
                if (mi.GetCustomAttribute <SensactCommandMethod>() == null)
                {
                    continue;
                }
                sb.AppendFormat("\tvoid cApplicationHost::Send{0}Command(sensact::eApplicationID destinationApp", SensactApplication.ExtractCmdName(mi));
                foreach (ParameterInfo pi in mi.GetParameters())
                {
                    sb.Append(", ");
                    sb.Append(CS2CPPType(pi.ParameterType));
                    sb.Append(" " + pi.Name);
                }
                sb.AppendLine(")");
                sb.AppendLine("\t{");
                sb.AppendLine("\t\tuint8_t buffer[8];");
                int offset = 0;
                foreach (ParameterInfo pi in mi.GetParameters())
                {
                    sb.AppendLine("\t\t" + CS2CPPWriter(pi, ref offset));
                }
                sb.AppendFormat("\t\tthis->SendApplicationCommandToMessageBus(destinationApp, sensact::eCommandType::{0}, buffer, {1});", SensactApplication.ExtractCmdName(mi), offset);
                sb.AppendLine();
                sb.AppendLine("\t}");
            }
            WriteCommonFile("sendCommandImplementation", sb);
            LOG.LogInformation("Successfully created sendCommandImplementation");
        }
コード例 #6
0
        //	virtual void OnSET_RGBWCommand(uint8_t R, uint8_t G, uint8_t B, uint8_t W, Time_t now);
        //static bool CreateSET_RGBWCommand(uint8_t R, uint8_t G, uint8_t B, uint8_t W, uint8_t buffer, uint8_t* lenght);

        private static string HeaderForCommands()
        {
            StringBuilder sb = new StringBuilder();

            //void OnSTOPCommand(uint8_t *payload, uint8_t payloadLength, Time_t now) override;
            foreach (MethodInfo m in typeof(SensactApplication).GetMethods())
            {
                if (m.GetCustomAttribute <SensactCommandMethod>() == null)
                {
                    continue;
                }
                sb.Append("\tvirtual void " + m.Name + "(");
                foreach (ParameterInfo pi in m.GetParameters())
                {
                    sb.Append(CS2CPPType(pi.ParameterType));
                    sb.Append(" " + pi.Name + ", ");
                }
                sb.Append("Time_t now)");
                sb.AppendLine(";");
                sb.AppendFormat("\tstatic bool Send{0}Command(eApplicationID destinationApp, ", SensactApplication.ExtractCmdName(m));
                foreach (ParameterInfo pi in m.GetParameters())
                {
                    sb.Append(CS2CPPType(pi.ParameterType));
                    sb.Append(" " + pi.Name + ", ");
                }
                sb.AppendLine("Time_t now);");
                sb.AppendLine();
            }
            return(sb.ToString());
        }
コード例 #7
0
        private static string ImplementationForCmdSend()
        {
            StringBuilder sb = new StringBuilder();

            foreach (MethodInfo mi in typeof(SensactApplication).GetMethods())
            {
                if (mi.GetCustomAttribute <SensactCommandMethod>() == null)
                {
                    continue;
                }
                sb.AppendFormat("\tbool cApplication::Send{0}Command(eApplicationID destinationApp, ", SensactApplication.ExtractCmdName(mi));
                foreach (ParameterInfo pi in mi.GetParameters())
                {
                    sb.Append(CS2CPPType(pi.ParameterType));
                    sb.Append(" " + pi.Name + ", ");
                }
                sb.AppendLine("Time_t now)");
                sb.AppendLine("\t{");
                sb.AppendLine("\t\tuint8_t buffer[8];");
                int offset = 0;
                foreach (ParameterInfo pi in mi.GetParameters())
                {
                    sb.AppendLine("\t\t" + CS2CPPWriter(pi, ref offset));
                }
                sb.AppendFormat("\t\treturn cMaster::SendCommandToMessageBus(now, destinationApp, eCommandType::{0}, buffer, {1});", SensactApplication.ExtractCmdName(mi), offset);
                sb.AppendLine();
                sb.AppendLine("\t}");
            }
            return(sb.ToString());
        }