예제 #1
0
        public override JObject classToJson(AbstractNodeClass nodeClass)
        {
            DataSourceNodeClass sourceClass = nodeClass as DataSourceNodeClass;

            JObject root = new JObject();

            AddOwnType(root);
            AddName(root, nodeClass.Name);
            AddDescription(root, nodeClass.Description);
            AddDisplayName(root, nodeClass.DisplayName);
            AddOutput(root, nodeClass.OutputType);
            AddMainClass(root, nodeClass.MainClass);
            AddNeededClasses(root, nodeClass.NeedsOtherClasses);
            AddExtras(root, nodeClass.NeededExtras);
            AddConfig(root, nodeClass.Configuration);
            AddProxyProperties(root, nodeClass.ProxyProperties);
            AddUserCreated(root, nodeClass.UserCreated);
            AddCreator(root, nodeClass.Creator);

            AddDataMethod(root, sourceClass.DataMethod);
            AddStartMethod(root, sourceClass.StartMethod);
            AddStopMethod(root, sourceClass.StopMethod);

            return(root);
        }
예제 #2
0
        public override void CreateCode(Node node, CodeExtension codeExtension)
        {
            DataSourceNodeClass nodeClass = node.Class as DataSourceNodeClass;

            codeExtension.AddSensor(node as DataSource);
            codeExtension.AddExtras(nodeClass.NeededExtras);

            codeExtension.AddImport(nodeClass.OutputType.Name);
            codeExtension.AddImport(nodeClass.MainClass);


            //Add the proxy methods to the Imports:
            nodeClass.ProxyProperties
            .Select(p => p.PropertyType.Name)
            .ForEach(codeExtension.AddImport);


            //We have a special case: Only a DataSource:
            if (codeExtension.RootNode == node)
            {
                string code = " private void transform0(){\n"
                              + "     data = sensor0." + nodeClass.DataMethod + "();\n"
                              + " }\n";

                codeExtension.AddCodeStep(code);
            }
        }
예제 #3
0
        /// <summary>
        /// Builds the Data for the Sensor output.
        /// </summary>
        public string BuildInitCode()
        {
            string initVarCode       = "";
            string initVarConfigCode = "";

            for (int i = 0; i < nextSensor; i++)
            {
                DataSource          sensor = sensors[i];
                DataSourceNodeClass clazz  = sensor.Class as DataSourceNodeClass;

                initVarCode += string.Format("       sensor{0} = new {1}(context);\n", i, DataType.MinimizeToClass(sensor.Class.MainClass));

                //Build the Config part:
                foreach (DataConfigElement element in sensor.Configuration)
                {
                    if (string.IsNullOrWhiteSpace(element.Value))
                    {
                        continue;
                    }
                    initVarConfigCode += string.Format("    sensor{0}.configure(\"{2}\", \"{3}\");\n",
                                                       i, element.Key, element.Value);
                }
            }

            for (int i = 0; i < nextTrans; i++)
            {
                Transformation          transformation = transformationOuts[i];
                TransformationNodeClass clazz          = transformation.Class as TransformationNodeClass;
                if (clazz.IsStatic)
                {
                    continue;
                }

                initVarCode += string.Format("       trans{0} = new {1}();\n", i, DataType.MinimizeToClass(transformation.Class.MainClass));

                //Build the Config part:
                foreach (DataConfigElement element in transformation.Configuration)
                {
                    if (string.IsNullOrWhiteSpace(element.Value))
                    {
                        continue;
                    }
                    initVarConfigCode += string.Format("    sensor{0}.configure(\"{2}\", \"{3}\");\n",
                                                       i, element.Key, element.Value);
                }
            }

            return(initVarCode + "\n" + initVarConfigCode);
        }
예제 #4
0
        /// <summary>
        /// Builds the Data for the Stop method.
        /// </summary>
        public string BuildStopCode()
        {
            string stopCode = "";

            for (int i = 0; i < nextSensor; i++)
            {
                DataSource          sensor = sensors[i];
                DataSourceNodeClass clazz  = sensor.Class as DataSourceNodeClass;

                string stopMethod = clazz.StopMethod;
                if (!string.IsNullOrWhiteSpace(stopMethod))
                {
                    stopCode += string.Format("       sensor{0}.{1}();\n", i, stopMethod);
                }
            }

            return(stopCode);
        }
예제 #5
0
 public DataSource(DataSourceNodeClass nodeClass)
 {
     this.Name  = nodeClass.DisplayName;
     this.Class = nodeClass;
 }