internal static bool AreNonVisibleSearchThreatsDetected(InstrumentState instrumentState) { if (instrumentState?.Blips == null) { return(false); } if (instrumentState.SearchMode) { return(false); } foreach (var thisBlip in instrumentState.Blips) { if (thisBlip == null || thisBlip.Lethality == 0 || thisBlip.Visible) { continue; } var symbolId = thisBlip.SymbolID; if (symbolId >= 5 && symbolId <= 17 || symbolId >= 19 && symbolId <= 26 || symbolId == 30 || symbolId >= 54 && symbolId <= 56) { return(true); } } return(false); }
internal static bool AreNonVisiblePriorityThreatsDetected(InstrumentState instrumentState) { if (instrumentState?.Blips == null) { return(false); } if (!instrumentState.PriorityMode) { return(false); } var trackingOwnshipCount = 0; var visibleCount = 0; foreach (var thisBlip in instrumentState.Blips) { if (thisBlip == null || thisBlip.Lethality == 0) { continue; } trackingOwnshipCount++; if (thisBlip.Visible) { visibleCount++; } } return(visibleCount == 5 && trackingOwnshipCount > visibleCount); }
/// <summary> /// /// </summary> /// <param name="state"></param> /// <param name="statusCode"></param> /// <param name="statusMessageValuesCount"></param> /// <param name="statusMessageValues"></param> /// <returns></returns> public bool reportStatus(string state, string statusCode, int statusMessageValuesCount, string[] statusMessageValues) { bool resultOk = true; // Basic integrity check on the supplied data if (statusMessageValuesCount != statusMessageValues.GetLength(0)) { resultOk = false; } // Convert the supplied Instrument Control state string to a corresponding value // type. InstrumentState instrumentState = InstrumentState.ESTOP; try { if (resultOk) { instrumentState = (InstrumentState)Enum.Parse(typeof(InstrumentState), state); } } catch { resultOk = false; } if (resultOk && ReportStatus != null) { ReportStatus(instrumentState, statusCode, statusMessageValues); } return(resultOk); }
public void Render(DrawingContext drawingContext, InstrumentState instrumentState) { CreateRWRRenderer(instrumentState.RwrInfo); if (_rwrRenderer != null) { _rwrRenderer.InstrumentState = instrumentState; _rwrRenderer.Render(drawingContext); } }
public void Render(DrawingContext drawingContext, InstrumentState instrumentState, bool formatForVectorDisplay = false) { CreateRWRRenderer(instrumentState.RwrInfo, formatForVectorDisplay); if (_rwrRenderer != null) { _rwrRenderer.InstrumentState = instrumentState; _rwrRenderer.Render(drawingContext); } }
public void Update(Instrument instrument) { Exchange = instrument.Exchange; PriceLifetime = instrument.PriceLifetime; OverlapTime = instrument.OverlapTime; RecalculationInterval = instrument.RecalculationInterval; Volume = instrument.Volume; Markup = instrument.Markup; State = instrument.State; }
public void SetInstrument(int instrument) { if (!_instrumentsByChannel.TryGetValue(instrument, out var state)) { state = new InstrumentState { Instrument = instrument }; _instruments.Add(state); _instrumentsByChannel.Add(instrument, state); } _currentInstrument = state; }
public bool SuspendResume(string[] originCodes, bool resume, out Guid[] affectInstrumentIds) { affectInstrumentIds = null; List <Guid> affectInstrumentIdList = new List <Guid>(); try { string sql = "SELECT ID,IsPriceEnabled,IsAutoEnablePrice FROM Instrument WHERE OriginCode=@originCode"; List <InstrumentState> updateItems = new List <InstrumentState>(); foreach (string originCode in originCodes) { DataAccessHelper.ExecuteReader(sql, CommandType.Text, delegate(SqlDataReader reader) { while (reader.Read()) { InstrumentState instrumentState = new InstrumentState() { InstrumentId = (Guid)reader["ID"], IsPriceEnabled = (bool)reader["IsPriceEnabled"], IsAutoEnablePrice = (bool)reader["IsAutoEnablePrice"] }; if (instrumentState.IsPriceEnabled == resume && instrumentState.IsAutoEnablePrice == resume) { continue; } instrumentState.IsPriceEnabled = instrumentState.IsPriceEnabled == resume ? null : (bool?)resume; instrumentState.IsAutoEnablePrice = instrumentState.IsAutoEnablePrice == resume ? null : (bool?)resume; updateItems.Add(instrumentState); } }, new SqlParameter("@originCode", originCode)); } if (updateItems.Count > 0) { Token token = new Token(Guid.Empty, UserType.System, AppType.Manager); if (Global.StateServer.UpdateInstrument(token, this.GetInstrumentUpdateXmlNode(updateItems, affectInstrumentIdList))) { affectInstrumentIds = affectInstrumentIdList.ToArray(); return(true); } } } catch (Exception ex) { AppDebug.LogEvent("ManagerCallback.SuspendResume", string.Format("originCodes:{0},resume:{1}\r\n{2}", string.Join(",", originCodes), resume, ex.ToString()), EventLogEntryType.Error); } return(false); }
private InstrumentState GetInstrumentState() { const float RADIANS_PER_DEGREE = 0.01745329252F; var instrumentState = new InstrumentState { bearing = _rwrObjectBearingInputSignals.OrderBy(x => x.Index).Select(x => (float)(x.State * RADIANS_PER_DEGREE)).ToArray(), ChaffCount = (float)_chaffCountInputSignal.State, FlareCount = (float)_flareCountInputSignal.State, lethality = _rwrObjectLethalityInputSignals.OrderBy(x => x.Index).Select(x => (float)x.State).ToArray(), missileActivity = _rwrObjectMissileActivityFlagInputSignals.OrderBy(x => x.Index).Select(x => (x.State ? 1u: 0u)).ToArray(), missileLaunch = _rwrObjectMissileLaunchFlagInputSignals.OrderBy(x => x.Index).Select(x => (x.State ? 1u : 0u)).ToArray(), newDetection = _rwrObjectNewDetectionFlagInputSignals.OrderBy(x => x.Index).Select(x => (x.State ? 1u : 0u)).ToArray(), RwrInfo = Encoding.Default.GetBytes(_rwrInfoInputSignal.State ?? string.Empty), RwrObjectCount = (int)_rwrSymbolCountInputSignal.State, RWRsymbol = _rwrObjectSymbolIDInputSignals.OrderBy(x => x.Index).Select(x => (int)x.State).ToArray(), selected = _rwrObjectSelectedFlagInputSignals.OrderBy(x => x.Index).Select(x => (x.State ? 1u: 0u)).ToArray(), yaw = (float)(_magneticHeadingDegreesInputSignal.State * RADIANS_PER_DEGREE) }; return(instrumentState); }
public void Render(Graphics destinationGraphics, Rectangle destinationRectangle, InstrumentState instrumentState, bool formatForVectorDisplay = false) { CreateRWRRenderer(instrumentState.RwrInfo, formatForVectorDisplay); if (_rwrRenderer != null) { _rwrRenderer.InstrumentState = instrumentState; _rwrRenderer.Render(destinationGraphics, destinationRectangle); } }
//Status Updates private void UpdateStatus() { MlrServ.State State; if (Victor.IsServerUpAndRunning()) { //way more then three options here State = InstrumentServ.GetState() as MlrServ.State; if (State.IsIdle()) { CurrentStatus = InstrumentState.Ready; lblStatus.Text = "Status: Machine Ready"; lblStatus.ForeColor = Color.Black; } else if (State.IsConnected() && State.IsWaiting()) { //check this CurrentStatus = InstrumentState.NotReady; lblStatus.Text = "Status: Not ready yet, waiting for the next plate"; lblStatus.ForeColor = Color.Blue; } else if (State.IsRunning()) { CurrentStatus = InstrumentState.NotReady; lblStatus.Text = "Status: Running"; lblStatus.ForeColor = Color.Blue; } else if (State.IsUnloading()) { CurrentStatus = InstrumentState.NotReady; lblStatus.Text = "Status: Unloading"; lblStatus.ForeColor = Color.Blue; } else if (State.IsLoading()) { CurrentStatus = InstrumentState.NotReady; lblStatus.Text = "Status: Loading"; lblStatus.ForeColor = Color.Blue; } else if (State.IsError()) { CurrentStatus = InstrumentState.Busted; lblStatus.Text = "Status: Error"; lblStatus.ForeColor = Color.Red; txtErrors.Text += "ERROR REPORTED AT: " + System.DateTime.Now.ToString() + "\n"; txtErrors.Text += InstrumentServ.GetLastErrorText() + "\n"; } else { CurrentStatus = InstrumentState.Busted; lblStatus.Text = "Status: Busted"; lblStatus.ForeColor = Color.Red; } } }
private void RunProtocol(int ProtocolID, string PlateName) { counter = 0; //int ProtocolID = 2000103;//This is my OD Protocol //returns true if successful, false otherwise try { //First have to make sure the machine is working UpdateStatus(); if (CurrentStatus != InstrumentState.Ready) {//if the instrument isn't ready, try for 10 seconds to make it ready, then abort for (int i = 0; i < 20; i++) { UpdateStatus(); if (CurrentStatus == InstrumentState.Ready) { break; } Thread.Sleep(500); } //if this fails, return false if (CurrentStatus != InstrumentState.Ready) { LastCommandResult = new CommandResult("Instrument Status Was Never Ready"); PulseObject(); return; } } //Onwards with the protocol MlrServ.AssayRunDefinitionClass AssayRunDef = new AssayRunDefinitionClass(); AssayRunDef.ProtocolID = ProtocolID; AssayRunDef.LoadFirstPlate = true; AssayRunDef.Notes = NextPlateName; //Create new m_Assay (and run if in demo mode) m_Assay = InstrumentServ.NewAssay(AssayRunDef as AssayRunDefinition) as Assay; //Check that the object was created if (m_Assay == null) { txtErrors.Text += "\nUnable to start new m_Assay (" + InstrumentServ.GetLastErrorText() + ")"; LastCommandResult = new CommandResult("Was unable to start assay"); PulseObject(); return; } } catch { txtErrors.Text += "\nUnexplained Error During Reading"+DateTime.Now.ToString()+"\n"; LastCommandResult = new CommandResult("Unexplained Error"); PulseObject(); CurrentStatus = InstrumentState.Busted; return; } return; }
/// <summary> /// Startup, object called from calling thread to indicate a failure to load /// </summary> /// <param name="FailedToLoad"></param> public VictorForm(BooleanReferenceType FailedToLoad) { lock (this) { try { isInitialized = false; //MessageBox.Show(Thread.CurrentThread.Name); InitializeComponent(); del_RunParameterizedProtocol = RunDifferentProtocol; StartVictor(); isInitialized = true; FailedToLoad.FailedToLoad = false; FailedToLoad.ErrorMessage = null; FailedToLoad.thrown = null; } catch (Exception thrown) { FailedToLoad.FailedToLoad = true; FailedToLoad.ErrorMessage = thrown.Message; FailedToLoad.thrown = thrown; this.txtErrors.Text += thrown.Message; this.CurrentStatus = InstrumentState.Busted; isInitialized = false; Application.ExitThread(); } } }
static InstrumentState() { Saving = new InstrumentState() { State = 1, Name = "保存" }; PassedNotYet = new InstrumentState() { State = 2, Name = "未入网" }; Applying = new InstrumentState() { State = 3, Name = "申请入网中" }; Passed = new InstrumentState() { State = 4, Name = "已入网" }; Rejected = new InstrumentState() { State = 5, Name = "驳回修改" }; States = new Dictionary<int, InstrumentState>(); States.Add(Saving.State, Saving); States.Add(PassedNotYet.State, PassedNotYet); States.Add(Applying.State, Applying); States.Add(Passed.State, Passed); States.Add(Rejected.State, Rejected); }
public bool SwitchPriceState(string[] originCodes, bool enable, out Guid[] affectInstrumentIds) { affectInstrumentIds = null; List <Guid> affectInstrumentIdList = new List <Guid>(); try { string sql = "SELECT ID,IsPriceEnabled FROM Instrument WHERE OriginCode=@originCode"; List <InstrumentState> updateItems = new List <InstrumentState>(); foreach (string originCode in originCodes) { DataAccessHelper.ExecuteReader(sql, CommandType.Text, delegate(SqlDataReader reader) { while (reader.Read()) { InstrumentState instrumentState = new InstrumentState { InstrumentId = (Guid)reader["ID"], IsPriceEnabled = (bool)reader["IsPriceEnabled"] }; if (instrumentState.IsPriceEnabled == enable) { continue; } instrumentState.IsPriceEnabled = enable; updateItems.Add(instrumentState); } }, new SqlParameter("@originCode", originCode)); } if (updateItems.Count > 0) { XmlDocument doc = new XmlDocument(); XmlNode instruments = doc.CreateNode(XmlNodeType.Element, "Instruments", null); XmlAttribute attribute; foreach (InstrumentState instrumentState in updateItems) { XmlNode instrument = doc.CreateNode(XmlNodeType.Element, "Instrument", null); attribute = doc.CreateAttribute("ID"); attribute.Value = instrumentState.InstrumentId.ToString(); instrument.Attributes.Append(attribute); attribute = doc.CreateAttribute("IsPriceEnabled"); attribute.Value = XmlConvert.ToString(instrumentState.IsPriceEnabled.Value); instrument.Attributes.Append(attribute); instruments.AppendChild(instrument); affectInstrumentIdList.Add(instrumentState.InstrumentId); } Token token = new Token(Guid.Empty, UserType.System, AppType.Manager); if (Global.StateServer.UpdateInstrument(token, instruments)) { affectInstrumentIds = affectInstrumentIdList.ToArray(); return(true); } } } catch (Exception ex) { AppDebug.LogEvent("ManagerCallback.SwitchPriceState", string.Format("originCodes:{0},enable:{1}\r\n{2}", string.Join(",", originCodes), enable, ex.ToString()), EventLogEntryType.Error); } return(false); }
public void Render(Graphics destinationGraphics, Rectangle destinationRectangle, InstrumentState instrumentState) { CreateRWRRenderer(instrumentState.RwrInfo); if (_rwrRenderer != null) { _rwrRenderer.InstrumentState = instrumentState; _rwrRenderer.Render(destinationGraphics, destinationRectangle); } }
static InstrumentState() { Saving = new InstrumentState() { State = 1, Name = "保存" }; PassedNotYet = new InstrumentState() { State = 2, Name = "未入网" }; Applying = new InstrumentState() { State = 3, Name = "申请入网中" }; Passed = new InstrumentState() { State = 4, Name = "已入网" }; Rejected = new InstrumentState() { State = 5, Name = "驳回修改" }; ApplyModifying = new InstrumentState() { State = 6, Name = "申请修改" }; ApplyDeleting = new InstrumentState() { State = 7, Name = "申请删除" }; ApproveModifying = new InstrumentState() { State = 8, Name = "通过修改" }; ApproveDeleting = new InstrumentState() { State = 9, Name = "通过删除" }; UnapproveModify = new InstrumentState() { State = 10, Name = "拒绝修改" }; UnapproveDelete = new InstrumentState() { State = 11, Name = "拒绝删除" }; States = new Dictionary<int, InstrumentState>(); States.Add(Saving.State, Saving); States.Add(PassedNotYet.State, PassedNotYet); States.Add(Applying.State, Applying); States.Add(Passed.State, Passed); States.Add(Rejected.State, Rejected); States.Add(ApplyModifying.State, ApplyModifying); States.Add(ApplyDeleting.State, ApplyDeleting); States.Add(ApproveModifying.State, ApproveModifying); States.Add(ApproveDeleting.State, ApproveDeleting); States.Add(UnapproveModify.State, UnapproveModify); States.Add(UnapproveDelete.State, UnapproveDelete); }
public void SetQuitOnInstrumentState(InstrumentState state) { UseAdditionalFinishCondition(new DynamicConstraint <IInstrument>("InstrumentState==" + state, Instrument, i => i.State == state)); //SetQuitCondition(() => _instrument.State == status); }
public void SetPauseUntilInstrumentState(InstrumentState state) { AddContinueCondition(new DynamicConstraint <IInstrument>("InstrumentState==" + state, Instrument, i => i.State == state)); //SetPauseCondition(_instrument, i => i.State == status); }