Example #1
0
 public void Configure(Dictionary <string, object> dict)
 {
     foreach (string item in dict.Keys)
     {
         object val = dict[item];
         if (!State.StateHandles.ContainsKey(item))
         {
             throw logger.Error(new SettingException(item, val, $"No state handle named {item}"));
         }
         StateHandle handle = State.StateHandles[item];
         Signal      origin;
         try
         {
             origin = new Signal(val);
             handle.SetStateVariable(origin);
         }
         catch (LigralException)
         {
             throw logger.Error(new SettingException(item, val));
         }
         catch (System.InvalidCastException)
         {
             throw logger.Error(new SettingException(item, val, $"Invalid type {val.GetType()} in state setter."));
         }
     }
 }
Example #2
0
 public override void SetHandleName(string handleName)
 {
     base.SetHandleName(handleName);
     if (!State.StateHandles.ContainsKey(handleName))
     {
         throw logger.Error(new SettingException(handleName, null, $"No state handle named {handleName}"));
     }
     handle = State.StateHandles[handleName];
 }
Example #3
0
 public static StateHandle CreateState(string name, int rowNo, int colNo, Signal initial)
 {
     name = name ?? $"State{StatePool.Count}";
     if (StateHandles.ContainsKey(name))
     {
         throw logger.Error(new LigralException($"State handle {name} has already existed."));
     }
     else
     {
         var handle = new StateHandle(name, rowNo, colNo, initial);
         StateHandles.Add(name, handle);
         return(handle);
     }
 }