コード例 #1
0
        public static void PrepareForCall(this HierarchicalVariableScope scope, ICommandSpecification command, RoomieCommandInterpreter interpreter)
        {
            var givenValues = scope.Local.FindGivenValues();
            var missingArguments = scope.FindMissingArguments(command.Arguments);

            if (missingArguments.Length > 0)
            {
                throw new MissingArgumentsException(missingArguments);
            }

            var defaultedValues = scope.ApplyDefaults(command.Arguments);

            if (interpreter.Engine.PrintCommandCalls)
            {
                var call = BuilCommandCall(command.Group + "." + command.Name, givenValues, defaultedValues);
                interpreter.WriteEvent(call);
            }

            var mistypedArguments = scope.FindMistypedArguments(command.Arguments);

            if (mistypedArguments.Any())
            {
                foreach (var argument in mistypedArguments)
                {
                    interpreter.WriteEvent(argument.Type.ValidationMessage(argument.Name));
                }

                throw new MistypedArgumentException(mistypedArguments);
            }
        }
コード例 #2
0
ファイル: ListEvents.cs プロジェクト: Mavtak/roomie
        internal static void WriteHistory(IEnumerable<IEvent> history, RoomieCommandInterpreter interpreter)
        {
            var headers = new[] {"Time Stamp", "Entity", "Type", "Source", ""};
            var tableBuilder = new TextTable(new int[]
                {
                    Math.Max(history.Max(x => x.TimeStamp.ToLocalTime().ToString().Length), headers[0].Length),
                    Math.Max(history.Max(x => ((x.Entity == null || x.Entity.Name == null) ? string.Empty : x.Entity.Name).Length), headers[1].Length),
                    Math.Max(history.Max(x => ((x.Type == null) ? string.Empty : x.Type.Name).Length), headers[2].Length),
                    Math.Max(history.Max(x => ((x.Source == null || x.Source.Name == null) ? string.Empty : x.Source.Name).Length), headers[3].Length),
                    ExtraLength(history)
                });

            interpreter.WriteEvent(tableBuilder.StartOfTable(headers));

            foreach (var @event in history)
            {
                var extra = GetExtra(@event);

                var line = tableBuilder.ContentLine(
                    @event.TimeStamp.ToLocalTime().ToString(),
                    (@event.Entity == null) ? string.Empty : @event.Entity.Name,
                    (@event.Type == null) ? string.Empty : @event.Type.Name,
                    (@event.Source == null) ? string.Empty : @event.Source.Name,
                    extra
                    );

                interpreter.WriteEvent(line);
            }

            interpreter.WriteEvent(tableBuilder.EndOfTable());
        }
コード例 #3
0
ファイル: RoomieThread.cs プロジェクト: Mavtak/roomie
 public RoomieThread(RoomieEngine engine, string name, HierarchicalVariableScope parentScope)
 {
     Engine = engine;
     Id = Guid.NewGuid().ToString();
     Name = name;
     _interpreter = new RoomieCommandInterpreter(this, parentScope ?? Engine.GlobalScope);
     _workQueue = new ParallelWorkQueue();
 }
コード例 #4
0
ファイル: RoomieThread.cs プロジェクト: Mavtak/roomie
 public RoomieThread(RoomieEngine engine, string name, HierarchicalVariableScope parentScope)
 {
     Engine       = engine;
     Id           = Guid.NewGuid().ToString();
     Name         = name;
     _interpreter = new RoomieCommandInterpreter(this, parentScope ?? Engine.GlobalScope);
     _workQueue   = new ParallelWorkQueue();
 }
コード例 #5
0
        public static void PrepareForCall(this HierarchicalVariableScope scope, ICommandSpecification command, RoomieCommandInterpreter interpreter)
        {
            var givenValues      = scope.Local.FindGivenValues();
            var missingArguments = scope.FindMissingArguments(command.Arguments);

            if (missingArguments.Length > 0)
            {
                throw new MissingArgumentsException(missingArguments);
            }

            var defaultedValues = scope.ApplyDefaults(command.Arguments);

            if (interpreter.Engine.PrintCommandCalls)
            {
                var call = BuilCommandCall(command.Group + "." + command.Name, givenValues, defaultedValues);
                interpreter.WriteEvent(call);
            }

            var mistypedArguments = scope.FindMistypedArguments(command.Arguments);

            if (mistypedArguments.Any())
            {
                foreach (var argument in mistypedArguments)
                {
                    interpreter.WriteEvent(argument.Type.ValidationMessage(argument.Name));
                }

                throw new MistypedArgumentException(mistypedArguments);
            }
        }
コード例 #6
0
 private void ListValue(RoomieCommandInterpreter interpreter, ZWaveDevice device, byte i)
 {
     var parameter = device.BackingObject.ConfigurationParameters[i];
     interpreter.WriteEvent(i + ": " + parameter.Value);
 }
コード例 #7
0
 internal RoomieCommandContext(RoomieCommandInterpreter interpreter, HierarchicalVariableScope scope, IScriptCommand originalCommand)
 {
     Interpreter     = interpreter;
     Scope           = scope;
     OriginalCommand = originalCommand;
 }
コード例 #8
0
ファイル: RoomieCommandContext.cs プロジェクト: Mavtak/roomie
 internal RoomieCommandContext(RoomieCommandInterpreter interpreter, HierarchicalVariableScope scope, IScriptCommand originalCommand)
 {
     Interpreter = interpreter;
     Scope = scope;
     OriginalCommand = originalCommand;
 }