public PumpStatusInfo(byte[] data) { if (data.Length != 10) { Logger.Instance().Error("PumpStatusInfo实例化失败,没有10个字节!"); } else { m_Chanel = data[0]; m_Head[0] = data[1]; m_Head[1] = data[2]; m_Length = data[3]; //m_PID =(ProductID)data[3]; m_Pump2PC = data[5]; m_MessageID = data[6]; m_AppDC = data[7]; if (Enum.IsDefined(typeof(PumpStatus), data[8])) { m_PumpStatus = (PumpStatus)data[8]; } else { m_PumpStatus = PumpStatus.Off; } m_CheckCode = data[9]; } }
/// <summary> /// /// </summary> /// <param name="bs"></param> /// <returns></returns> static internal LYR001StatusData Parse(byte[] bs) { if (bs == null) { throw new ArgumentNullException("bs"); } if (bs.Length < 3) { throw new ArgumentException("bs.Length must >= 3"); } BitArray list = new BitArray(bs); PumpStatus cm1 = GetPumpStatus(list, 0, 3); PumpStatus cm2 = GetPumpStatus(list, 1, 4); PumpStatus cm3 = GetPumpStatus(list, 2, 5); PumpStatus rm1 = GetPumpStatus(list, 6, 8); PumpStatus rm2 = GetPumpStatus(list, 7, 9); ManualAutomatic ma = GetManualAutomatic(list, 10); List <string> alarmList = GetAlarmList(list, 12); //BitArray list LYR001StatusData r = new LYR001StatusData(cm1, cm2, cm3, rm1, rm2, ma, alarmList); return(r); }
private void UpdatePipes(PumpStatus pumpStatus) { Task.Factory.StartNew(() => { MethodInvoker mth = (MethodInvoker) delegate() { try { lock (this) { List <Control> controls = new List <Control>(); foreach (Control control in this.splMain.Panel2.Controls) { if (control.Name.StartsWith("pipe")) { controls.Add(control); } } if (pumpStatus == PumpStatus.On) { foreach (Control control in controls.OrderBy(p => p.Tag)) { ((Panel)control).BackColor = Color.FromArgb(0, 168, 243); this.Refresh(); Thread.Sleep(50); } } else { foreach (Control control in controls.OrderByDescending(p => p.Tag)) { ((Panel)control).BackColor = Color.White; this.Refresh(); Task.Delay(50); } } } } catch (Exception e) { txtMsg.Text = e.Message; } }; if (!this.IsHandleCreated) { mth.Invoke(); } else { this.BeginInvoke(mth); } }); }
public void SetStatus(PumpStatus ps1, double limit1, string type1, string plate1, double flow1, int nozz1) { ps = ps1; limit = limit1; plate = plate1; dFlow = flow1; type = type1; if (nozz1 != -1) { nozz = nozz1; } }
public void DetachCrate(IMovableSnappable detaching) { capturedResource = null; detachTimer = StartCoroutine(DetachCrateTimer()); PumpHandle.tag = "Untagged"; CurrentPumpStatus = PumpStatus.PumpOff; RefreshPumpState(); if (connectedPumpable != null) { connectedPumpable.OnAdjacentChanged(); //trigger a recalculate for the connected thing } }
private IEnumerator DoPump(bool pumpIn) { SoundSource.Play(); while (isActiveAndEnabled && CurrentPumpStatus != PumpStatus.PumpOff && capturedResource != null && connectedPumpable != null) { if (pumpIn) { if (capturedResource.Data.Container.CurrentAmount < PumpPerUpdateInterval) { break; } else { float amountFromCrate = capturedResource.Data.Container.Pull(PumpPerUpdateInterval); float excessToAttached = PushToAttached(amountFromCrate); if (excessToAttached > 0f) { capturedResource.Data.Container.Push(excessToAttached); } if (amountFromCrate <= 0f) { break; } } } else { float amountFromAttached = PullFromAttached(PumpPerUpdateInterval); float excessToCrate = capturedResource.Data.Container.Push(amountFromAttached); if (excessToCrate > 0) { PushToAttached(excessToCrate); } if (amountFromAttached <= 0f) { break; } } yield return(new WaitForSeconds(PumpUpdateIntervalSeconds)); } SoundSource.Stop(); CurrentPumpStatus = PumpStatus.PumpOff; RefreshPumpState(); }
private void TimerEventProcessor(Object myObject, EventArgs myEventArgs) { myTimer.Stop(); //MessageBox.Show("Timer done"); if (CheckAuth(cardtoauth, ActiveNozz, ref limit, ref type, ref plate, ref reason)) { ps = PumpStatus.InUse; pup.ResetVol(conf.PumpAuthDelay); pup.SetStatus(ps, limit, dd.type, dd.plate, conf.flowrate, -1); AddToLogList(MsgLogType.Authorized, reason, 0, plate, limit, gotmsg.carddata); (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + plate; if (type == "Money") { (MainPage.Document.GetElementById("Limit")).InnerHtml = limit.ToString("0") + " " + conf.LimitPerMoneyText; } else { (MainPage.Document.GetElementById("Limit")).InnerHtml = limit.ToString("0") + " " + conf.LimitPerVolText; } } else if (reason == "CPass required") { AddToLogList(MsgLogType.CheckCPass, reason, 0, plate, limit, cardtoauth); myTimer.Start(); //recheck in as few seconds } else if (reason == "CPass wait") { //AddToLogList(MsgLogType.CheckCPass, reason, 0, plate, limit, cardtoauth); //no second message if (CPassTry == conf.CPassRetry) { reason = "No mobile confirmation"; if (statustouse != 0x30) { AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, limit, gotmsg.carddata); } return; } CPassTry++; myTimer.Start(); //recheck in as few seconds } else { if (statustouse != 0x30) { AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, limit, gotmsg.carddata); } } }
public PumpStatus GetPumpStatus(int userId, int pumpId) { var pumpStatus = new PumpStatus { PumpId = 1, PmpStatus = -1, RAmp = 12, BAmp = 123, YVoltage = 242, RVoltage = 222, BVoltage = 235, LastUpdatedTimestamp = "11123123112" }; return(pumpStatus); }
/// <summary> /// Creates exemplar of Probe class. /// </summary> /// <param name="pts">Exemplar of parent PTS class.</param> internal Pump(PTS pts) { this.AutocloseTransaction = true; this._pts = pts; this._status = PumpStatus.OFFLINE; this.CommandToExecute = 0; this.CommandPlannedToExecute = 0; this.StatusReceivedCounterBeforeCommand = 0; this.Locked = false; this._nozzles = new Nozzle[PtsConfiguration.MaxNozzlesCount]; for (int i = 0; i < PtsConfiguration.MaxNozzlesCount; i++) { _nozzles[i] = new Nozzle(this, (byte)(i + 1)); _nozzles[i].PricePerLiter = 0; } }
public PumpStatus GetPumpStatus(int pumpID) { PumpStatus status = PumpStatus.None; int pumpIndex = pumpID - 1; switch (PumpsStatus[pumpIndex]) { case 'I': status = PumpStatus.Idle; break; case 'C': status = PumpStatus.Calling; break; case 'A': status = PumpStatus.Authorized; break; case 'P': status = PumpStatus.Pumping; break; case 'S': status = PumpStatus.Stopped; break; case 'O': status = PumpStatus.Offline; break; case 'F': status = PumpStatus.Finished; break; case 'N': status = PumpStatus.NoConnection; break; case 'H': status = PumpStatus.Holding; break; } return(status); }
//handled by AttachTo //protected override void OnSnap() {} protected override void OnDetach() { if (connectedPumpable != null) { IndustryExtensions.RemoveAdjacentPumpable(this, connectedPumpable); connectedPumpable = null; connectedSink = null; } PumpHandle.tag = "Untagged"; CurrentPumpStatus = PumpStatus.PumpOff; RefreshPumpState(); if (capturedResource != null) { capturedResource.UnsnapCrate(); } }
static private VPump100Data[] ConvertToVPump100Datas(DataTable datatable, out int createCount) { NullOrDBNullConverter nc = new NullOrDBNullConverter(0f); createCount = 0; List <VPump100Data> list = new List <VPump100Data>(); foreach (DataRow row in datatable.Rows) { DateTime dt = Convert.ToDateTime(row[ColumnNamesForPump.StrTime]); float instantFlux = Convert.ToSingle(nc.Convert(row[ColumnNamesForPump.Flux])); float efficienty = Convert.ToSingle(nc.Convert(row[ColumnNamesForPump.Efficiency])); float sum = Convert.ToSingle(nc.Convert(row[ColumnNames.TuWater])); float remain = Convert.ToSingle(nc.Convert(row[ColumnNames.ReWater])); PumpStatus pumpStatus = VPumpStatusParser.ParsePumpStatus(row[ColumnNamesForPump.PumpStatus].ToString()); ForceStartStatus forceStatus = VPumpStatusParser.ParseForceStartStatus(row[ColumnNamesForPump.ForceRun].ToString()); VibrateStatus vibrateStatus = VPumpStatusParser.ParseVibrateStatus(row[ColumnNamesForPump.Vibrate].ToString()); PumpPowerStatus powerStatus = VPumpStatusParser.ParsePowerStatus(row[ColumnNamesForPump.Power].ToString()); VPump100Data data = new VPump100Data(); data.DT = dt; data.InstantFlux = instantFlux; data.Efficiency = efficienty; data.TotalAmount = sum; data.RemainAmount = remain; data.PumpStatus = pumpStatus; data.ForceStartStatus = forceStatus; data.VibrateStatus = vibrateStatus; data.PowerStatus = powerStatus; list.Add(data); if (list.Count >= 5) { break; } } createCount = list.Count; while (list.Count < 5) { list.Add(new VPump100Data()); } return(list.ToArray()); }
/// <summary> /// /// </summary> /// <param name="bs"></param> /// <param name="startIndex"></param> /// <returns></returns> static public VPump100Data ToVPump100Data(byte[] bs, int startIndex) { int start = startIndex; Int64 ticks = BitConverter.ToInt64(bs, start); start += 8; float instantFlux = BitConverter.ToSingle(bs, start); start += 4; float eff = BitConverter.ToSingle(bs, start); start += 4; float total = BitConverter.ToSingle(bs, start); start += 4; float remain = BitConverter.ToSingle(bs, start); start += 4; PumpStatus pumpStatus = (PumpStatus)bs[start++]; ForceStartStatus forceStartStatus = (ForceStartStatus)bs[start++]; VibrateStatus vibrateStatus = (VibrateStatus)bs[start++]; PumpPowerStatus powerStatus = (PumpPowerStatus)bs[start++]; VPump100Data data = new VPump100Data(); data.DT = new DateTime(ticks); data.InstantFlux = instantFlux; data.Efficiency = eff; data.ForceStartStatus = forceStartStatus; data.PowerStatus = powerStatus; data.PumpStatus = pumpStatus; data.RemainAmount = remain; data.TotalAmount = total; data.VibrateStatus = vibrateStatus; return(data); }
/// <summary> /// /// </summary> /// <param name="cm1"></param> /// <param name="cm2"></param> /// <param name="cm3"></param> /// <param name="rm1"></param> /// <param name="rm2"></param> /// <param name="rm3"></param> /// <param name="manOrAuto"></param> /// <param name="alarmList"></param> public LYR001StatusData(PumpStatus cm1, PumpStatus cm2, PumpStatus cm3, PumpStatus rm1, PumpStatus rm2, ManualAutomatic manOrAuto, List <string> alarmList ) { _cM1 = cm1; _cM2 = cm2; _cM3 = cm3; _rM1 = rm1; _rM2 = rm2; _manualAutomatic = manOrAuto; _alarmList = alarmList; }
public void StartPumpingOut() { if (CurrentPumpStatus == PumpStatus.PumpIn) { CurrentPumpStatus = PumpStatus.PumpOff; } else if (CurrentPumpStatus == PumpStatus.PumpOff) { CurrentPumpStatus = PumpStatus.PumpOut; if (Pumping != null) { StopCoroutine(Pumping); } Pumping = StartCoroutine(DoPump(false)); } RefreshPumpState(); }
public void ToggleValve() { if (CurrentPumpStatus == PumpStatus.PumpOpen) { CurrentPumpStatus = PumpStatus.PumpOff; if (connectedPumpable != null) { connectedPumpable.OnAdjacentChanged(); //trigger a recalculate for the connected thing } } else if (CurrentPumpStatus == PumpStatus.PumpOff) { CurrentPumpStatus = PumpStatus.PumpOpen; if (connectedPumpable != null) { connectedPumpable.OnAdjacentChanged(); //trigger a recalculate for the connected thing } } RefreshPumpState(); }
private void ShowProgress(StatusData msg) { Thread.BeginCriticalRegion(); gotmsg = msg; try { if (msg.status == -1) { AddToLogList(MsgLogType.CommErr, "", 0, "", 0, msg.carddata); bWGTInError = true; pup.SetStatus(PumpStatus.Stopped); return; } ActiveNozz = pup.GetNozz(); //check that we were in error and update log if (bWGTInError) { bWGTInError = false; AddToLogList(MsgLogType.WGTConnected, "", 0, "", 0, ""); } limit = 0.0; plate = ""; reason = ""; type = ""; cardtoauth = ""; statustouse = 0x30; if (ActiveNozz == 1) { cardtoauth = msg.carddata; statustouse = msg.status; } else if (ActiveNozz == 2) { cardtoauth = msg.carddata2; statustouse = msg.status2; } else //no nozzle is active { return; } //check if anything changed if (cardtoauth == laststatus.carddata && statustouse == laststatus.status) { return; //no change } laststatus.carddata = cardtoauth; laststatus.status = statustouse; switch (ps) { case PumpStatus.Idle: //try authorize card if (CheckAuth(cardtoauth, ActiveNozz, ref limit, ref type, ref plate, ref reason)) { ps = PumpStatus.Ready; pup.SetStatus(ps, limit, dd.type, dd.plate, conf.flowrate, -1); AddToLogList(MsgLogType.Authorized, reason, 0, plate, limit, msg.carddata); (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + plate; if (type == "Money") { (MainPage.Document.GetElementById("Limit")).InnerHtml = limit.ToString("0.00") + " " + conf.LimitPerMoneyText; } else { (MainPage.Document.GetElementById("Limit")).InnerHtml = limit.ToString("0.00") + " " + conf.LimitPerVolText; } } else { if (statustouse == 0x30) { AddToLogList(MsgLogType.Disconnected, "", 0, "", 0, ""); return; } if (msg.status == -1) { AddToLogList(MsgLogType.CommErr, "", 0, plate, limit, msg.carddata); return; } AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, 0, msg.carddata); } break; case PumpStatus.Call: if (cardtoauth != "") { MobileRes = "None"; CPassTry = 0; MsgID++; AddToLogList(MsgLogType.CheckAuth, "", 0, "", 0, cardtoauth); myTimer.Start(); } /* * if (CheckAuth(cardtoauth,ActiveNozz, ref limit, ref type, ref plate,ref reason)) * { * ps = PumpStatus.InUse; * pup.ResetVol(); * pup.SetStatus(ps, limit, dd.type, dd.plate, conf.flowrate, -1); * AddToLogList(MsgLogType.Authorized, reason, 0, plate, limit, msg.carddata); * (MainPage.Document.GetElementById("Plate")).InnerHtml = plate; * if (type == "Money") * (MainPage.Document.GetElementById("Limit")).InnerHtml = limit.ToString("0.00") + " " + conf.LimitPerMoneyText; * else * (MainPage.Document.GetElementById("Limit")).InnerHtml = limit.ToString("0.00") + " " + conf.LimitPerVolText; * } * else * { * if (statustouse != 0x30) * AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, limit, msg.carddata); * } */ break; case PumpStatus.InUse: //check if we are 'out' if (statustouse == 0x30) { ps = PumpStatus.Stopped; pup.SetStatus(ps); //TODO ActivityList.Items.Insert(0, "Nozzle is out - suspending fuelling " + msg.carddata); AddToLogList(MsgLogType.Suspending, reason, 0, plate, limit, msg.carddata); break; } //check that we did not got other card if (cardtoauth != fuellingcardnumber) { //stop fuelling ps = PumpStatus.Stopped; pup.SetStatus(ps); //TODO ActivityList.Items.Insert(0, "Got another card - suspending fuelling " + msg.carddata); AddToLogList(MsgLogType.OtherCard, "", 0, plate, limit, msg.carddata); } break; case PumpStatus.Stopped: //check if we can resume if (cardtoauth == fuellingcardnumber) { ps = PumpStatus.InUse; pup.SetStatus(ps); AddToLogList(MsgLogType.Resuming, reason, 0, plate, limit, cardtoauth); } else if (cardtoauth != "") { // AddToLogList(MsgLogType.OtherCard, reason, 0, plate, limit, cardtoauth); } break; case PumpStatus.Ready: //if we lost the connection cancle the auth if (statustouse == 0x30) { ps = PumpStatus.Idle; pup.SetStatus(ps, 0); AddToLogList(MsgLogType.CancelAuth, reason, 0, plate, limit, cardtoauth); } //if we got a different card - need to recheck if (statustouse == 0x34 && fuellingcardnumber != cardtoauth) { if (CheckAuth(cardtoauth, ActiveNozz, ref limit, ref type, ref plate, ref reason)) { ps = PumpStatus.Ready; pup.SetStatus(ps, limit, dd.type, dd.plate, conf.flowrate, -1); AddToLogList(MsgLogType.NewCard, reason, 0, plate, limit, cardtoauth); (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + plate; if (type == "Money") { (MainPage.Document.GetElementById("Limit")).InnerHtml = limit.ToString("0.00") + " " + conf.LimitPerMoneyText; } else { (MainPage.Document.GetElementById("Limit")).InnerHtml = limit.ToString("0.00") + " " + conf.LimitPerVolText; } } else { ps = PumpStatus.Idle; pup.SetStatus(ps, 0); AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, limit, msg.carddata); } } break; } } catch (Exception ex) { // MessageBox.Show(ex.Message); } finally { Thread.EndCriticalRegion(); } }
public void SetStatus(PumpStatus ps1) { ps = ps1; SetUpdateData(false); }
public void SetStatus(PumpStatus ps1, int nozz1) { ps = ps1; nozz = nozz1; }
public Pump() { _Status = PumpStatus.Off; _OperationMode = OperationMode.Automatic; this.Changed = false; }
public PumpUpdater(ContainerControl sender, Delegate senderDelegate) { m_sender = sender; m_senderDelegate = senderDelegate; ps = PumpStatus.Idle; }
public void Nozz2_Click() { if (pup.GetNozz() == 1) //no nozz or this nozz { return; //cannot use two nozzles at same time } ProductCode = conf.Prod2Code; msr.SetInfo(SelectedStation, ProductCode); HtmlElement a = MainPage.Document.GetElementById("Nozz2"); switch (ps) { case PumpStatus.Idle: //just lift nozzle a.SetAttribute("src", "NozzUp.png"); AddToLogList(MsgLogType.NozzleUP, "", 2, "", 0, ""); if (MSRSuspendedAuth()) { msgSaved = null; //clear for next } else { ps = PumpStatus.Call; pup.SetStatus(ps, 2); } break; case PumpStatus.Call: //put nozzle back a.SetAttribute("src", "NozzDn.png"); AddToLogList(MsgLogType.NozzelDown, "", 2, "", 0, ""); ProductCode = 0; msr.SetInfo(SelectedStation, ProductCode); ps = PumpStatus.Idle; pup.SetStatus(ps, 0); break; case PumpStatus.Ready: //we can move to inuse a.SetAttribute("src", "NozzUp.png"); AddToLogList(MsgLogType.StartRefuel, "", 2, "", 0, ""); ps = PumpStatus.InUse; pup.ResetVol(conf.PumpAuthDelay); pup.SetStatus(ps, 2); break; case PumpStatus.InUse: //stop fuelling; a.SetAttribute("src", "NozzDn.png"); AddToLogList(MsgLogType.TransEnded, "", 2, "", 0, ""); ps = PumpStatus.Idle; ProductCode = 0; msr.SetInfo(SelectedStation, ProductCode); MobileRes = "None"; CPassTry = 0; pup.SetStatus(ps, 0); if (dd.bCPass) { SendMobileSummary(dd.cardnum, MsgID); } if (conf.UseMSR) { SendTransactionComplete(); } break; case PumpStatus.Stopped: a.SetAttribute("src", "NozzDn.png"); AddToLogList(MsgLogType.TransEnded, "", 2, "", 0, ""); ps = PumpStatus.Idle; ProductCode = 0; msr.SetInfo(SelectedStation, ProductCode); MobileRes = "None"; CPassTry = 0; pup.SetStatus(ps, 0); if (dd.bCPass) { SendMobileSummary(dd.cardnum, MsgID); } break; } }
public MsgPumpData(PumpStatus statusPump, OperationMode operationMode) { this.StatusPump = statusPump; this.OperationMode = operationMode; }