public void Configure(Dictionary <string, object> dict) { foreach (string item in dict.Keys) { object val = dict[item]; if (!ControlInput.InputHandles.ContainsKey(item)) { throw logger.Error(new SettingException(item, val, $"No input handle named {item}")); } ControlInputHandle handle = ControlInput.InputHandles[item]; Signal origin; try { origin = new Signal(val); handle.SetOpenLoopInput(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 input setter.")); } } }
public override void Check() { int inputRowNo = InPortList[0].RowNo; int inputColNo = InPortList[0].ColNo; if (inputRowNo < 0 && inputColNo < 0) { if (rowNo < 0 && colNo < 0) { rowNo = 0; colNo = 0; } else { InPortList[0].RowNo = rowNo; InPortList[0].ColNo = colNo; } } else if (rowNo < 0 && colNo < 0) { rowNo = inputRowNo; colNo = inputColNo; } else if (inputColNo != colNo) { throw logger.Error(new ModelException(this, $"Column number inconsistent, got {inputColNo}, but {colNo} expected.")); } else if (inputRowNo != rowNo) { throw logger.Error(new ModelException(this, $"Row number inconsistent, got {inputRowNo}, but {rowNo} expected.")); } handle = ControlInput.CreateInput(varName ?? Name, rowNo, colNo); OutPortList[0].SetShape(rowNo, colNo); }
public override void SetHandleName(string handleName) { base.SetHandleName(handleName); if (!ControlInput.InputHandles.ContainsKey(handleName)) { throw logger.Error(new SettingException(handleName, null, $"No control input handle named {handleName}")); } handle = ControlInput.InputHandles[handleName]; }