Example #1
0
 private void SetStartingValues(ISV isv)
 {
     if (isv != null)
     {
         SetInputs(isv);
     }
 }
Example #2
0
        /// <summary>
        /// Creates a program set with a single program on a single zone.
        /// </summary>
        public ProgramSet(ZoneProgram program, Zone zone, ISV isv, string setName, dynamic startingParameters = null)
        {
            Name        = setName;
            ProgramName = program.Name;
            Sync        = false;

            Zones = zone.Listify();
            zone.Stop(true);
            //ZoneScaffolder.Instance.RunZone(zone, "", isv); -- TODO: Why aren't we using this? This seems to be better than the next line
            zone.Run(program, isv, startingParameters: startingParameters);
        }
Example #3
0
        public ISV ToISV()
        {
            var inputStartingValues = new ISV();

            this.ToList().ForEach(input =>
            {
                if (input.Value != null)
                {
                    inputStartingValues.Add(input.Name, input.Value);
                }
            });
            return(inputStartingValues);
        }
Example #4
0
        /// <summary>
        /// Starts the zone program.
        /// </summary>
        /// <param name="isv">Starting values for the program.</param>
        /// <param name="sync">Whether or not to start the program in sync with a SyncContext.</param>
        /// <param name="syncContext">If this parameter is supplied when sync=true, this method will use the supplied SyncContext to
        /// sync this program with. If sync=true and this parameter is not supplied, this method will use the already assigned
        /// SyncContext to sync this program with.</param>
        /// <param name="startingParameters">Parameters to be passed into the StartCore method.</param>
        public void Start(ISV isv = null, bool sync = false, SyncContext syncContext = null, dynamic startingParameters = null)
        {
            if (State == ProgramState.Stopped)
            {
                //set starting values
                SetStartingValues(isv);

                //if sync, or if synccontext is not null
                if (sync || syncContext != null)
                {
                    //if synccontext is not null
                    if (syncContext != null)
                    {
                        //sync with provided synccontext
                        syncContext.Sync(this);
                    }
                    //else there should already be a synccontext attached (from a previous sync)
                    else
                    {
                        //throw error if that(^^^^^^^)'s not the case
                        if (SyncContext == null)
                        {
                            throw new Exception("If Start is called with LiveSync, either a Sync Context must be passed in with it or one must be set before calling Start.");
                        }

                        //otherwise, sync with existing synccontext
                        SyncContext.Sync(this);
                    }
                }
                else
                {
                    //subclass processing - passing in starting parameters
                    StartCore(startingParameters);                     //isSyncRequested);

                    //set program state
                    State = ProgramState.Started;
                }
            }
            else
            {
                throw new Exception("Program is already started.");
            }
        }
Example #5
0
 public void SetInputs(ISV isv)
 {
     ZonePrograms.Parallelize(zp => zp.SetInputs(isv));
 }
Example #6
0
 /// <summary>
 /// Batch set inputs.
 /// </summary>
 /// <param name="isv"></param>
 public void SetInputs(ISV isv)
 {
     isv.Keys.ToList().ForEach(key => SetInput(key, isv[key]));
 }