public IStarterViewModel CreateStarterViewModel(IStarter starter) { IStarterViewModel starterViewModel = _container.Resolve <IStarterViewModel>(); starterViewModel.Model = starter; return(starterViewModel); }
public List <IStarter> CreateStarters(IDeviceContext deviceContext, byte[] configDataBytes) { List <IStarter> starters = new List <IStarter>(); int chanelCount = 8; int starterCounter = 0; deviceContext.SchemeTable = new DefaultSchemeTable(); for (int channelNumber = 0; channelNumber < chanelCount; channelNumber++) { var addressOfOutput = channelNumber * 12; var relayNumber = (ushort)configDataBytes[addressOfOutput + 3]; if (relayNumber > 0) { starterCounter++; if (starterCounter > 3) { break; } IStarter starter = _container.Resolve <IStarter>(); starter.SetLogger(LogManager.GetLogger(deviceContext.DeviceName)); InitializeStarter(starter, deviceContext, relayNumber, channelNumber, configDataBytes); starters.Add(starter); } } return(starters); }
protected override int ExecCommandOnNode(Guid guidCmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { Debug.Assert(this.ProjectMgr != null, "The Dynamic FileNode has no project manager"); if (this.ProjectMgr == null) { throw new InvalidOperationException(); } if (guidCmdGroup == GuidList.guidIronStudioCmdSet) { switch (cmd) { case CommonConstants.SetAsStartupFileCmdId: // Set the StartupFile project property to the Url of this node this.ProjectMgr.SetProjectProperty(CommonConstants.StartupFile, this.Url); break; case CommonConstants.StartDebuggingCmdId: case CommonConstants.StartWithoutDebuggingCmdId: CommonProjectPackage package = (CommonProjectPackage)_project.Package; IStarter starter = (IStarter)_project.GetService(typeof(IStarter)); if (starter != null) { starter.StartFile(_project, this.Url, cmd == CommonConstants.StartDebuggingCmdId); } break; } return(VSConstants.S_OK); } return(base.ExecCommandOnNode(guidCmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut)); }
public string CreateMenu() { IStarter starter = _cateringTeamFactory.GetStarter(); IMainCourse mainCourse = _cateringTeamFactory.GetMainCourse(); IDessert dessert = _cateringTeamFactory.GetDessert(); menu = new Menu(starter, mainCourse, dessert); return(menu.GetMenu()); }
/// <summary> /// This method retrieves an instance of a service that /// allows to start a project or a file with or without debugging. /// </summary> public IStarter /*!*/ GetStarter() { if (_starter == null) { _starter = CreateStarter(); ContractUtils.Requires(_starter != null, "GetStarter should return an instance of IStarter"); } return(_starter); }
public bool Delete(IStarter starter) { var item = from st in this.Conn.Table <Starter>() where st.Startnummer == starter.Startnummer select st; var count = this.Conn.Delete(item); return(count > 0); }
public List <IStarter> CreateStarters(IDeviceContext deviceContext, byte[] configDataBytes) { List <IStarter> starters = new List <IStarter>(); int chanelCount = 8; int starterCounter = 0; deviceContext.SchemeTable = new DefaultSchemeTable(); int baseAddress = 0x3004; int startAddressKuOutput = 0x3020; int startAddressKuOutputInv = 0x3024; int offsetKuOutput = (startAddressKuOutput - baseAddress) * 2; int offsetInvKuOutput = (startAddressKuOutputInv - baseAddress) * 2; for (int channelNumber = 0; channelNumber < chanelCount; channelNumber++) { int inversionBytesCorrection = ((channelNumber % 2 == 0) || channelNumber == 0) ? 1 : -1; var dataValueKuOutput = configDataBytes[offsetKuOutput + channelNumber + inversionBytesCorrection]; var dataValueInvKuOutput = configDataBytes[offsetInvKuOutput + channelNumber + inversionBytesCorrection]; if (dataValueInvKuOutput == 0 && dataValueKuOutput == 0) { continue; } bool isChannelWithShedule = false; int offset = 0; if ((channelNumber == 0) || (channelNumber % 2 == 0)) { offset = 1 + channelNumber; } else { offset = channelNumber - 1; } byte channelLightningMode = configDataBytes[2 * (int)((0x3028 - baseAddress)) + offset]; isChannelWithShedule = channelLightningMode != 0; if (isChannelWithShedule) { starterCounter++; IStarter starter = _container.Resolve <IStarter>(); starter.SetLogger(LogManager.GetLogger(deviceContext.DeviceName)); InitializeStarter(starter, deviceContext, channelNumber, configDataBytes, channelLightningMode, baseAddress); starters.Add(starter); } } return(starters); }
public override int DebugLaunch(uint flags) { IStarter starter = _project.Package.GetStarter(); __VSDBGLAUNCHFLAGS launchFlags = (__VSDBGLAUNCHFLAGS)flags; if ((launchFlags & __VSDBGLAUNCHFLAGS.DBGLAUNCH_NoDebug) == __VSDBGLAUNCHFLAGS.DBGLAUNCH_NoDebug) { //Start project with no debugger starter.StartProject(_project, false); } else { //Start project with debugger starter.StartProject(_project, true); } return(VSConstants.S_OK); }
/// <summary> /// Constructor /// </summary> /// <param name="factory">Task Factories</param> /// <param name="starter">Task Starter</param> public RoleTaskManager(IEnumerable <ITaskFactory <T> > factories, IStarter starter) { if (null == factories) { throw new ArgumentNullException("factories"); } this.factories = factories.Where(f => f != null); if (this.factories.Count() == 0) { throw new ArgumentException("No valid factories available."); } if (null == starter) { throw new ArgumentNullException("starter"); } this.starter = starter; }
public Menu(IStarter s, IMainCourse mc, IDessert d) { _starter = s; _mainCourse = mc; _dessert = d; }
private bool IsActiveModule(IStarter starter) { return(_engine.Application.ModuleCatalog.IsActiveModuleAssembly(starter.GetType().Assembly)); }
private void InitializeStarter(IStarter starter, IDeviceContext deviceContext, int relayNumber, int channelNumber, byte[] data) { channelNumber++; int starterNumber; if (uint.Parse(deviceContext.ChannelNumberOfStarter1) == channelNumber) { starterNumber = 1; } else if (uint.Parse(deviceContext.ChannelNumberOfStarter2) == channelNumber) { starterNumber = 2; } else if (uint.Parse(deviceContext.ChannelNumberOfStarter3) == channelNumber) { starterNumber = 3; } else { return; } starter.StarterNumber = starterNumber; starter.ChannelNumber = channelNumber; if (deviceContext.SchemeTable.GetStarterRow(starterNumber) != null) { return; } var row = new DefaultStarterRow(); row.StarterId = starterNumber; if (starterNumber == 1) { row.StarterDescription = deviceContext.Starter1Description; } else if (starterNumber == 2) { row.StarterDescription = deviceContext.Starter2Description; } else if (starterNumber == 3) { row.StarterDescription = deviceContext.Starter3Description; } starter.StarterDescription = row.StarterDescription; deviceContext.SchemeTable.AddStarterRow(row); var addressOfLightingMode = (channelNumber - 1) * 12; var lightingModeValueValue = (ushort)(data[addressOfLightingMode] * 256 + data[addressOfLightingMode + 1]); if (LightingValueNameDictionary.ContainsKey(lightingModeValueValue)) { starter.StarterLightingMode = LightingValueNameDictionary[lightingModeValueValue]; } else { starter.StarterLightingMode = LightingModeEnum.UNDEFINED; } // Маска реле неисправности канала var address = (channelNumber - 1) * 12; var faultValue = (ushort)(data[address + 4] * 256 + data[address + 5]); for (int i = 0; i < _maskRelayFaultCanal.Length; i++) { var mask = _maskRelayFaultCanal[i]; if ((faultValue & mask) > 0) { deviceContext.SchemeTable.AddResistorRow(new DefaultResistorRow { ResistorId = i + 1, ResistorDiskret = i, ResistorModul = 1, ParentStarterId = starterNumber, ResistorDescription = String.Empty }); } } }
public Engine() { _starter = new ElectricStarter { Battery = new Battery() }; }
private void InitializeStarter(IStarter starter, IDeviceContext deviceContext, int channelNumber, byte[] data, byte lightingModeValue, int baseAddress) { channelNumber++; int starterNumber; if (uint.Parse(deviceContext.ChannelNumberOfStarter1) == channelNumber) { starterNumber = 1; } else if (uint.Parse(deviceContext.ChannelNumberOfStarter2) == channelNumber) { starterNumber = 2; } else if (uint.Parse(deviceContext.ChannelNumberOfStarter3) == channelNumber) { starterNumber = 3; } else { return; } starter.StarterNumber = starterNumber; starter.ChannelNumber = channelNumber; if (deviceContext.SchemeTable.GetStarterRow(starterNumber) != null) { return; } var row = new DefaultStarterRow(); row.StarterId = starterNumber; if (starterNumber == 1) { row.StarterDescription = deviceContext.Starter1Description; } else if (starterNumber == 2) { row.StarterDescription = deviceContext.Starter2Description; } else if (starterNumber == 3) { row.StarterDescription = deviceContext.Starter3Description; } starter.StarterDescription = row.StarterDescription; deviceContext.SchemeTable.AddStarterRow(row); if (LightingValueNameDictionary.ContainsKey(lightingModeValue)) { starter.StarterLightingMode = LightingValueNameDictionary[lightingModeValue]; } else { starter.StarterLightingMode = LightingModeEnum.UNDEFINED; } ; ushort offsetAddress = 0x4; for (int modulIndex = 0; modulIndex < 8; modulIndex++) { int offsetModule = 0; if ((modulIndex == 0) || (modulIndex % 2 == 0)) { offsetModule = 1 + modulIndex; } else { offsetModule = modulIndex - 1; } var faultValue = data[(2 * (0x3040 - baseAddress) + (channelNumber - 1) * offsetAddress * 2) + offsetModule]; for (int i = 0; i < _maskRelayFaultCanal.Length; i++) { var mask = _maskRelayFaultCanal[i]; if ((faultValue & mask) > 0) { deviceContext.SchemeTable.AddResistorRow(new DefaultResistorRow { ResistorId = i + 8 * (i + 1) * modulIndex, ResistorDiskret = i, ResistorModul = 1 + modulIndex, ParentStarterId = starterNumber, ResistorDescription = String.Empty }); } } } }
/// <summary> /// This method retrieves an instance of a service that /// allows to start a project or a file with or without debugging. /// </summary> /*!*/ public IStarter GetStarter() { if (_starter == null) { _starter = CreateStarter(); ContractUtils.Requires(_starter != null, "GetStarter should return an instance of IStarter"); } return _starter; }
/// <summary> /// Loads a Sphere Studio project into the IDE. /// </summary> /// <param name="fileName">The filename of the project.</param> /// <param name="usePluginWarning">Whether to show a warning if required plugins are missing.</param> public void OpenProject(string fileName, bool usePluginWarning = true) { if (string.IsNullOrEmpty(fileName)) { return; } Project pj = SphereStudio.Ide.Project.Open(fileName); IStarter starter = PluginManager.Get <IStarter>(pj.User.Engine); ICompiler compiler = PluginManager.Get <ICompiler>(pj.Compiler); if (usePluginWarning && (starter == null || compiler == null)) { var answer = MessageBox.Show( string.Format("One or more plugins required to work on '{0}' are either disabled or not installed. Please open Configuration Manager and check your plugins.\n\nCompiler required:\n{1}\n\nIf you continue, data may be lost. Open this project anyway?", pj.Name, pj.Compiler), "Proceed with Caution", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (answer == DialogResult.No) { return; } } if (!CloseCurrentProject()) { return; } Core.Project = pj; RefreshProject(); if (LoadProject != null) { LoadProject(null, EventArgs.Empty); } HelpLabel.Text = @"Game project loaded successfully!"; StartVisible = true; string[] docs = Core.Project.User.Documents; foreach (string s in docs) { if (string.IsNullOrWhiteSpace(s)) { continue; } try { OpenFile(s, true); } catch (Exception) { } } // if the form is not visible, don't try to mess with the panels. // it will be done in Form_Load. if (Visible) { if (Core.Project.User.StartHidden) { StartVisible = false; } DocumentTab tab = GetDocument(Core.Project.User.ActiveDocument); if (tab != null) { tab.Activate(); } } Text = string.Format("{3} - {0} {1} {2}", Versioning.Name, Versioning.Version, Environment.Is64BitProcess ? "x64" : "x86", Project.Name); UpdateEngineList(); UpdateControls(); }
public virtual void ParseRawBytesToDeviceState(byte[] rawBytes, IRuntimeDevice runtimeDevice) { runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.ACKNOWLEDGE_VALUE] .Value = runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.ACKNOWLEDGE_VALUE] .Formatter.Format(rawBytes); bool state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.MANAGEMENT_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsManagementDefect = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.MANAGEMENT_CHAINS_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsManagementChainsDefect = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.FUSES_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsFusesDefect = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.PROTECTION_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsProtectionDefect = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.POWER_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsNoPowerDefect = state; if (runtimeDevice.DeviceMomento.State.SchemeTable == null) { return; } var resitors = runtimeDevice.ResistorsOnDevice; foreach (var resistor in resitors) { try { var stateRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + resistor.ModuleNumber + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + resistor.ResistorNumber + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR).Formatter.Format(rawBytes); var failRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + resistor.ModuleNumber + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + resistor.ResistorNumber + AddressesStrings.SPLITTER_STR + AddressesStrings.FAIL_STR).Formatter.Format(rawBytes); resistor.IsOnState = (bool)stateRes; resistor.IsDefectState = (bool)failRes; } catch (Exception e) { Console.WriteLine(e); } } if (runtimeDevice.DeviceCustomItems.IsCascadeEnabled) { var cascades = runtimeDevice.DeviceCustomItems.Cascades; foreach (var cascade in cascades) { var cascadeRow = runtimeDevice.DeviceMomento.State.CustomDeviceSchemeTable.CascadeIndicatorsTable.GetObjectByTag( cascade.SignalDescription); var stateRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + cascadeRow.ResistorModule + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + (cascadeRow.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR).Formatter.Format(rawBytes); cascade.SignalState = (bool)stateRes; } } if (runtimeDevice.DeviceCustomItems.IsIndicatorsEnabled) { var indicators = runtimeDevice.DeviceCustomItems.Indicators; foreach (var indicator in indicators) { var indicatorRow = runtimeDevice.DeviceMomento.State.CustomDeviceSchemeTable.IndicatorsTable.GetObjectByTag( indicator.SignalDescription); var stateRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + indicatorRow.ResistorModule + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + (indicatorRow.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR).Formatter.Format(rawBytes); indicator.SignalState = (bool)stateRes; } } if (runtimeDevice.DeviceCustomItems.IsSignalsEnabled) { var signals = runtimeDevice.DeviceCustomItems.Signals; foreach (var signal in signals) { var signalRow = runtimeDevice.DeviceMomento.State.CustomDeviceSchemeTable.SignalsTable.GetObjectByTag( signal.SignalDescription); var stateRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + signalRow.ResistorModule + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + (signalRow.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR).Formatter.Format(rawBytes); signal.SignalState = (bool)stateRes; } } var deviceStarterRows = runtimeDevice.DeviceMomento.State.SchemeTable.GetChannelsEnumerable(); foreach (var deviceStarterRow in deviceStarterRows) { IStarter starter = runtimeDevice.StartersOnDevice.FirstOrDefault( (st => st.StarterNumber == deviceStarterRow.StarterId)); state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.STARTER_STATE_PATTERN + starter.ChannelNumber] .Formatter.Format(rawBytes); starter.IsStarterOn = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.STARTER_IS_MANUAL_MODE_PATTERN + starter.ChannelNumber] .Formatter.Format(rawBytes); starter.IsInManualMode = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.STARTER_IS_REPAIR + starter.ChannelNumber] .Formatter.Format(rawBytes); starter.IsInRepairState = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.STARTER_MANAGEMENT_CONTROL + starter.ChannelNumber] .Formatter.Format(rawBytes); starter.ManagementFuseState = state; } }
public bool Add(IStarter starter) { var count = this.Conn.Insert(starter); return(count > 0); }