public static IntState DataToShared(DALayer.Entities.IntState data) { IntState shared = new IntState(); shared.interactionId = data.interactionId; shared.receiver = data.receiver != null?DataToShared(data.receiver) : null; shared.receiverId = data.receiverId; shared.requester = DataToShared(data.requester); shared.winnerId = data.winnerId; switch (data.state) { case DALayer.Enum.InteractionState.EXECUTING: shared.state = SharedEntities.Enum.InteractionState.EXECUTING; break; case DALayer.Enum.InteractionState.FINISH: shared.state = SharedEntities.Enum.InteractionState.EXECUTING; break; case DALayer.Enum.InteractionState.FINISHING: shared.state = SharedEntities.Enum.InteractionState.FINISHING; break; } return(shared); }
private static void fillList() { //wait list ready m_runningLIst = PrefetchList.getNextReadyList(); if (m_runningLIst == ListNumber.Undefine) { m_layersFinishid = PrefetchList.m_lastListReady; if (m_layersFinishid) { m_state = IntState.Wait; } return; } m_layersFinishid = false; m_stopWatch.Restart(); if (m_runningLIst == ListNumber.list1) { NativeMethods.PCI_Execute_List_1(); } else { NativeMethods.PCI_Execute_List_2(); } m_currenlList = (Int32)PrefetchList.getLayerNumber(m_runningLIst); ; m_state = IntState.Work; }
void IJob.Execute(IJobExecutionContext context) { JobDataMap dataMap = context.JobDetail.JobDataMap; string tenantId = dataMap.GetString("tenantId"); int interactionId = System.Int32.Parse(dataMap.GetString("interactionId")); init(tenantId);//Set Up api tenant //current = new Ataque.Clases.Ataque();//we must do this trought refelection searching by interaction.intName Interaction interaction = api.getInteractionHandler().GetInteraction(interactionId); if (interaction.intName.Equals("Ataque")) { current = new Ataque.Clases.Ataque(); } else if (interaction.intName.Equals("Comercio")) { current = new Comercio.Clases.Comercio(); } IntState intState = api.getIntStateHandler().GetIntStateByInteraction(interactionId); requester = GetIntFromMeta(intState.requester); if (intState.receiverId == -1) { receiver = GetIntFromMeta(intState.receiver); } else { receiver = GetIntFromId(intState.receiverId); } if (intState.state == SharedEntities.Enum.InteractionState.EXECUTING)//look for interaction state { int round = 1; List <IInteractionable> list = current.exec(requester, receiver); ApplyChanges(list); IntState state = GetIntState(interactionId, receiver, requester); state.state = SharedEntities.Enum.InteractionState.FINISHING; api.getIntStateHandler().SaveIntState(state); float time = 1; IInteractionable i = list.Where(c => c.mustSend() || c.getReturn()).OrderByDescending(c => c.getReturn()).FirstOrDefault(); if (i != null) { IDestacamento des = i.GetFlota().OrderByDescending(c => c.GetVelocidad()).FirstOrDefault(); time = GetDistanceBetweenColony(requester.GetID(), receiver.GetID()) / des.GetVelocidad(); } Scheduler.Scheduler.ScheduleInteraction(interactionId, time, tenantId, round); // testExec(interactionId); } else { List <IInteractionable> list = current.finalize(requester, receiver); IntState state = GetIntState(interactionId, receiver, requester); state.state = SharedEntities.Enum.InteractionState.FINISH; api.getIntStateHandler().SaveIntState(state); ApplyChanges(list); } }
private IntState GetEventDrivenCountEditor(K key) { IntState contains; if (!_eventDrivenCount.TryGetValue(key, out contains)) { contains = new IntState(0); _eventDrivenCount[key] = contains; } return(contains); }
private static void processStopRequest() { NativeMethods.PCI_Stop_Execution(); NativeMethods.PCI_Write_Port(0xC, 0x000); NativeMethods.PCI_Write_DA_List((UInt16)0); fileLoader.m_mut.WaitOne(); //lock file loader thread fileLoader.resetFile(); PrefetchList.resetList(); m_runningLIst = ListNumber.Undefine; fileLoader.m_mut.ReleaseMutex(); m_inputSignals &= ~(IntSignals.Reset); m_state = IntState.Wait; // after reset always to wait State. }
private static void initCard(object sender, CardEventArgs e) { fileLoader.m_mut.WaitOne(); m_mut.WaitOne(); fileLoader.m_cs = e.cs; NativeMethods.debugInit(); fileLoader.debugInit(); bool rInit = NativeMethods.PCI_Init_Scan_Card_Ex((UInt16)e.cs.num); bool rLoad = NativeMethods.PCI_Load_Corr_N(e.cs.corrFilePatch, e.cs.num); bool rSetAct = NativeMethods.PCI_Set_Active_Card((UInt16)e.cs.num); bool setGain = NativeMethods.PCI_Set_Gain(e.cs.gainX, e.cs.gainY, 0, 0, (UInt16)e.cs.num); bool rSetMode = NativeMethods.PCI_Set_Mode(e.cs.mode); NativeMethods.PCI_Stop_Execution(); bool rOsc = NativeMethods.PCI_Write_Port(0xC, 0x010);// NativeMethods.PCI_Write_Port_List(0xC, 0x00); //NativeMethods.PCI_Write_DA_List((UInt16)10); dbg = e.cs.debug; bool openScript = fileLoader.openJobfile(e.cs.scriptPath); PrefetchList.resetList(); m_state = IntState.Wait; m_isIntiialize = rInit && rSetAct && rSetMode && rOsc && openScript; MessageBox.Show(string.Format(" {0, -25} -- {1, -10} \n {2,-25} -- {4, -10} ({3}) \n {5,-25} -- {6, -10} \n {7, -25} -- {8, -10} \n {9,-25} -- {10, -10} \n {11,-25} -- {12, -10} ({13}) \n {14, -25} -- {15, -10}", "Init", rInit.ToString(), "Load correction", e.cs.corrFilePatch, rLoad.ToString(), "Set mode", rSetMode.ToString(), "Set active card", rSetAct.ToString(), "Oscillator on", rOsc.ToString(), "Open script", openScript.ToString(), e.cs.scriptPath, "Set gain", setGain.ToString()), (m_isIntiialize ? "Инициализация прошла успешно!" : "Ошибка при инициализации"), MessageBoxButtons.OK, m_isIntiialize ? MessageBoxIcon.Information : MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000); m_layersFinishid = false; if (!m_isIntiialize) { NativeMethods.PCI_Write_Port(0xC, 0x000); } fileLoader.m_mut.ReleaseMutex(); m_mut.ReleaseMutex(); }
public static void processSignals() { NativeMethods.readStatus(ref m_cardStatus); if (m_isIntiialize) { PrefetchList.stepExecution(); } IntSignals s = m_inputSignals; switch (m_state) { case IntState.Wait: WaitState(); if ((s & IntSignals.Run) != 0) { m_inputSignals &= ~IntSignals.Run; m_state = IntState.WaitListReady; } if ((s & (IntSignals.Reset)) != 0) { processStopRequest(); } break; case IntState.WaitListReady: fillList(); if ((s & (IntSignals.Reset)) != 0) { processStopRequest(); } break; case IntState.Work: WorkState(); if ((s & (IntSignals.Reset)) != 0) { processStopRequest(); } break; } }
private static void WorkState() { if (m_cardStatus.scanComlete) //wait until escan comlete { bool finish = PrefetchList.isOneListOnLayer(m_runningLIst); PrefetchList.setFree(m_runningLIst); m_state = finish ? IntState.Wait : IntState.WaitListReady; m_stopWatch.Stop(); m_timeExecutinLayer = m_stopWatch.Elapsed; } if (PrefetchList.getNextReadyList() == ListNumber.Undefine) { m_layersFinishid = PrefetchList.m_lastListReady; } }
private IntState GetIntState(int interactionId, IInteractionable receiver, IInteractionable requester) { IntState state = new IntState(); state.interactionId = interactionId; if (!current.GetConfig().isRecNeedRecursos() && !current.GetConfig().isRecNeedFloat()) { state.receiverId = receiver.GetID(); state.receiver = null; } else { state.receiverId = -1; } state.receiver = GetInteractionableMeta(receiver); state.winnerId = requester.Won() ? requester.GetID() : (receiver.Won() ? receiver.GetID() : -1); state.requester = GetInteractionableMeta(requester); return(state); }
private void Update() { if (daying != 1) { State = IntState.Idle; Move(); if (touching == 0) { damageRate += Time.deltaTime; if (damageRate > 1.0f) { damageRate = 0; unit.ReciveDamage(); } } if (lives == 0) { daying = 1; State = IntState.Die; Invoke("Die", 1); } } }
internal void start() { List <IInteractionable> list = current.initialize(requester, receiver); int interactionId = InsertInteraction(requester.GetID(), receiver.GetID()); ApplyChanges(list); IntState state = GetIntState(interactionId, receiver, requester); api.getIntStateHandler().SaveIntState(state); float time = 1; IInteractionable i = list.Where(c => c.mustSend()).FirstOrDefault(); if (i != null) { /// calculo tiempos IDestacamento des = i.GetFlota().OrderByDescending(c => c.GetVelocidad()).FirstOrDefault(); time = GetDistanceBetweenColony(requester.GetID(), receiver.GetID()) / des.GetVelocidad(); } int round = 0; Scheduler.Scheduler.ScheduleInteraction(interactionId, time, tenantId, round); }
public void SaveIntState(IntState state) { BsonDocument doc = SharedToData(state).ToBsonDocument(); ctx.SaveCurrent(doc); }