void ComponerAlarma() { var date = (DateTime)Date_Picker.Value; var time = (DateTime)Time_Picker.Value; int segundos=time.Second; int hora = time.Hour; int minutos = time.Minute; int mes = date.Month; int year = date.Year; int dia = date.Day; DateTime fechaCompleta = new DateTime(year,mes,dia,hora,minutos,segundos); if (ScheduledActionService.Find("alarmaCalendario") != null) ScheduledActionService.Remove("alarmaCalendario"); Alarm alamarCalendario= new Alarm("alarmaCalendario"); alamarCalendario.Content = recordatorio.Text; alamarCalendario.Sound = new Uri("Alarma-Calendario.mp3", UriKind.Relative); alamarCalendario.BeginTime = fechaCompleta; alamarCalendario.RecurrenceType = RecurrenceInterval.Daily; ScheduledActionService.Add(alamarCalendario); if(AppResources.Idioma.Equals("Ingles")) MessageBox.Show("The alarm is set for the " + fechaCompleta); else MessageBox.Show("La alarma esta programada para el " + fechaCompleta); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); }
protected override void OnHandleIntent (Intent intent) { Context context = ApplicationContext; // var alarm = (Alarm)intent.GetParcelableExtra (ALARM_KEY); // TODO - workaround https://github.com/googlesamples/android-DirectBoot/issues/4 Bundle bundle = intent.Extras; var alarm = new Alarm { Id = bundle.GetInt ("id"), Year = bundle.GetInt ("year"), Month = bundle.GetInt ("month"), Day = bundle.GetInt ("day"), Hour = bundle.GetInt ("hour"), Minute = bundle.GetInt ("minute") }; var manager = context.GetSystemService (NotificationService).JavaCast<NotificationManager> (); var builder = new NotificationCompat.Builder (context) .SetSmallIcon (Resource.Drawable.ic_fbe_notification) .SetCategory (Notification.CategoryAlarm) .SetSound (Settings.System.DefaultAlarmAlertUri) .SetContentTitle (context.GetString (Resource.String.alarm_went_off, alarm.Hour, alarm.Minute)); manager.Notify (alarm.Id, builder.Build ()); var alarmStorage = new AlarmStorage (context); alarmStorage.DeleteAlarm (alarm); var wentoffIntent = new Intent (ALARM_WENT_OFF_ACTION); wentoffIntent.PutExtra (ALARM_KEY, alarm); LocalBroadcastManager.GetInstance (context).SendBroadcast (wentoffIntent); }
private void CreateAlarm() { if (!NotificationDate.Value.HasValue || !TPkon2.Value.HasValue) return; var date = new DateTime(NotificationDate.Value.Value.Year, NotificationDate.Value.Value.Month, NotificationDate.Value.Value.Day, 0, 0, 0); var time = new DateTime(NotificationDate.Value.Value.Year, NotificationDate.Value.Value.Month, NotificationDate.Value.Value.Day, TPkon2.Value.Value.Hour, TPkon2.Value.Value.Minute, 0); var beginTime = date + time.TimeOfDay; if (beginTime < DateTime.Now) { MessageBox.Show("указанное время события прошло"); return; } if (ScheduledActionService.Find(Alarm) != null) ScheduledActionService.Remove(Alarm); var alarm = new Alarm(Alarm); alarm.Content = textBox1.Text; alarm.RecurrenceType = RecurrenceInterval.None; alarm.BeginTime = beginTime; alarm.ExpirationTime = beginTime.AddMinutes(5); ScheduledActionService.Add(alarm); MessageBox.Show("будильник установлен на " + beginTime.ToString()); }
/// <summary> /// Cancels the scheduled alarm. /// </summary> /// <returns>The alarm to be canceled.</returns> /// <param name="alarm">Alarm.</param> public void CancelAlarm (Alarm alarm) { var intent = new Intent (context, typeof (AlarmIntentService)); intent.PutExtra (AlarmIntentService.ALARM_KEY, alarm); var pendingIntent = PendingIntent.GetService (context, alarm.Id, intent, PendingIntentFlags.UpdateCurrent); alarmManager.Cancel (pendingIntent); }
private void Button_Click_1(object sender, RoutedEventArgs e) { i++; bool isAlarmExist; Alarm alarm = ScheduledActionService.Find("Alarm" + i) as Alarm; if (alarm == null) { isAlarmExist = false; alarm = new Alarm("Alarm" + i); } else { isAlarmExist = true; } alarm.BeginTime = DateTime.Now.AddMinutes(1); alarm.ExpirationTime = DateTime.Now.AddMinutes(2); alarm.Content = "闹钟" + i; alarm.Sound = new Uri("/Assets/Making love without nothing at all.mp3", UriKind.Relative); alarm.RecurrenceType = RecurrenceInterval.Daily; if (!isAlarmExist) ScheduledActionService.Add(alarm); else ScheduledActionService.Replace(alarm); var alarms = ScheduledActionService.GetActions<Alarm>(); lls.ItemsSource = alarms.ToList(); }
public void Should_Set_AlarmClock_Alarm_When_AlarmViewPresenter_Sets_Alarm() { var newAlarm = new Alarm(); mockAlarmViewPresenter.Raise(avp => avp.AlarmSet += null, mockAlarmViewPresenter.Object, newAlarm); Expect(() => { mockAlarmClock.Verify(ac => ac.SetAlarm(newAlarm)); }, Throws.Nothing); }
private void SubsribeAlarm(object sender, RoutedEventArgs e) { var sliderValue = this.alarmSlider.Value; List<StationStat> stationStatCollection = ((sender as Button).DataContext as List<StationStat>); if (stationStatCollection == null) { return; } foreach (var item in stationStatCollection) { DateTime stationStart = (DateTime)(item as StationStat).Start.Time; Alarm alarm = new Alarm(string.Format("Nasa ISS pass at {0} with {1} brightness.", (item as StationStat).Start.Time, (item as StationStat).Brightness)); alarm.BeginTime = stationStart.AddMinutes(-sliderValue); alarm.ExpirationTime = alarm.BeginTime.AddMinutes(5); alarm.Content = alarm.Name; //ScheduledActionService.Add(alarm); var action = ScheduledActionService.GetActions<Alarm>().FirstOrDefault(x => x.Name == alarm.Name); if (action == null) { ScheduledActionService.Add(alarm); MessageBox.Show(string.Format("Alarm set for {0}\nExpiration time: {1}\n", alarm.BeginTime, alarm.ExpirationTime)); } } }
// Insertion of a new alarm in the alarm table. public int AddAlarm(Alarm alarm) { MySqlConnection sqlConnection = new MySqlConnection(connectionString); MySqlCommand sqlCmd = sqlConnection.CreateCommand(); int id = -1; try { sqlConnection.Open(); sqlCmd.CommandText = "INSERT INTO " + "ALARMS ( ISENABLE, SENSITIVITY, LOCATION, ALARMTYPE, PARENTID ) " + "VALUES ( " + alarm.IsEnabled + ", " + alarm.Sensitivity + ", \"" + alarm.Location + "\", \"" + alarm.Type + "\", " + alarm.ParentId + ")"; sqlCmd.ExecuteNonQuery(); sqlCmd.CommandText = "SELECT LAST_INSERT_ID() FROM ALARMS"; id = Convert.ToInt32(sqlCmd.ExecuteScalar()); } catch (Exception e) { Console.WriteLine("Could not connect to database!"); Console.WriteLine("{0} Exception caught.", e); } finally { sqlConnection.Close(); } return id; }
public static void AddAlarm(Entry entry) { try { Alarm alarm = new Alarm(MetroCalendarAlarm + entry.EntryId); alarm.Content = entry.Subject; alarm.Sound = RingTone(entry.RingTone); alarm.BeginTime = entry.AlarmTime; alarm.ExpirationTime = entry.ExpirationTime; alarm.RecurrenceType = Recurrence(entry.RepeatType); ScheduledActionService.Add(alarm); } catch (InvalidOperationException ex) { Debug.WriteLine(ex.Message); } catch (SchedulerServiceException sex) { Debug.WriteLine(sex.Message); } catch (ArgumentOutOfRangeException aore) { Debug.WriteLine(aore.Message); } catch (Exception e) { Debug.WriteLine(e.Message); } }
private void AlarmView_AlarmSet(object sender, Alarm e) { var handler = AlarmSet; if (AlarmSet != null) { AlarmSet(this, e); } }
//sends a notification to the user when the user can drive again private void ResultNotification_Click(object sender, RoutedEventArgs e) { Alarm drivingAlarm = new Alarm("Sober notification"); drivingAlarm.Content = "You are now able to drive. Drive carefully"; drivingAlarm.BeginTime = hoursTilDrivingLimit; ScheduledActionService.Add(drivingAlarm); }
public void TriggerStartAlarm() { int count = 0; this.integerVariable.Value = 20; Alarm alarm = new Alarm(this.integerVariable, value => ((int) value) == 30); alarm.StartAlarm += (oldvalue, newvalue) => count++; this.integerVariable.Value = 30; Assert.AreEqual(1, count); }
public static void AddAlarm(Alarm alarm) { try { ScheduledActionService.Add(alarm); } catch (System.Exception) { } }
public void a_normal_pressure_value_should_not_raise_the_alarm() { StubSensor stubSensor = new StubSensor(); stubSensor.StubCallToPopNextPressurePsiValue(Alarm.LowPressureTreshold); Alarm target = new Alarm(stubSensor); target.Check(); Assert.AreEqual(false, target.AlarmOn, "alarm on"); }
public void a_pressure_value_out_of_range_should_raise_the_alarm() { StubSensor stubSensor = new StubSensor(); stubSensor.StubCallToPopNextPressurePsiValue(Alarm.LowPressureTreshold -1); Alarm target = new Alarm(stubSensor); target.Check(); Assert.AreEqual(true, target.AlarmOn, "alarm on"); }
private void CreateAlarm(int p) { string alarmName = Guid.NewGuid().ToString(); var alarm = new Alarm(alarmName) { Content = appdata["data3"].ToString(), BeginTime = DateTime.Now.AddSeconds(p) }; ScheduledActionService.Add(alarm); }
public static void Activate() { if (isActive) return; isActive = true; spawnAlarm = Alarm.Start(60, spawnObject); spawnAlarm.IsLooping = true; GlobalEvent.Step += moveBackground; }
public AlarmViewModel(Alarm alarm) { Alarm = alarm; ResetCommand = new RelayCommand(OnReset, CanReset); RemoveFromIgnoreListCommand = new RelayCommand(OnRemoveFromIgnoreList, CanRemoveFromIgnoreList); ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan); ShowDeviceCommand = new RelayCommand(OnShowDevice, CanShowDevice); ShowZoneCommand = new RelayCommand(OnShowZone, CanShowZone); ShowInstructionCommand = new RelayCommand(OnShowInstruction, CanShowInstruction); }
static public void DoTests() { Alarm a = new Alarm(); a.InitAll(); a.ALARM1(); a.ALARM2(); a.ALARM3(); a.ALARM4(); a.ALARM5(); a.ALARM6(); }
public void SetAlarm() { Alarm alarm = new Alarm("Wake or waste"); alarm.Content = "Wake uppp"; alarm.Sound = new Uri("/Ringtones/baroqueloop90z.wma", UriKind.Relative); alarm.BeginTime = DateTime.Now.AddMinutes(1); alarm.ExpirationTime = DateTime.Now.AddDays(21); alarm.RecurrenceType = RecurrenceInterval.Daily; ScheduledActionService.Add(alarm); }
// Use this for initialization void Start () { transform.position = position; l = GetComponent<Light>(); l.type = LightType.Directional; l.color = Color.red; alarm = l.gameObject.AddComponent<Alarm>(); l.enabled = false; alarmActivated = false; waitingTime = 1.0f; audioSource = GetComponent<AudioSource>(); audioSource.clip = clip; }
/// <summary> /// Delete the specified alarm instance from the SharedPreferences. /// This method iterates through the alarms stored in the SharedPreferences, /// timing corresponds linearly to the alarms count. /// </summary> /// <param name="toBeDeleted">To be deleted.</param> public void DeleteAlarm (Alarm toBeDeleted) { foreach (string alarmJson in sharedPreferences.All.Values) { var alarm = Alarm.FromJson (alarmJson); if (alarm.Id == toBeDeleted.Id) { ISharedPreferencesEditor editor = sharedPreferences.Edit (); editor.Remove (alarm.Id.ToString ()); editor.Apply (); return; } } }
public void a_normal_pressure_value_after_an_out_of_range_pressure_value_should_keep_the_alarm_on() { StubSensor stubSensor = new StubSensor(); stubSensor.StubCallToPopNextPressurePsiValues(new double[] { Alarm.LowPressureTreshold, Alarm.LowPressureTreshold - 1, Alarm.LowPressureTreshold }); Alarm target = new Alarm(stubSensor); target.Check(); target.Check(); target.Check(); Assert.AreEqual(true, target.AlarmOn, "alarm on"); }
public void setAlarm(DateTime time) { Alarm alarm = new Alarm(name); alarm.Content = "News Alarm"; alarm.Sound = new Uri("/Sound/Ringtone/Ring01.wma", UriKind.Relative); //alarm.Sound = new Uri(@"http://dl.dropbox.com/u/5758134/sara.mp3"); alarm.BeginTime = time; alarm.ExpirationTime = DateTime.MaxValue; alarm.RecurrenceType = RecurrenceInterval.Daily; ScheduledActionService.Add(alarm); }
private void button2_Click(object sender, EventArgs e) { Heater heater = new Heater(); Alarm alarm = new Alarm(); heater.Boiled += alarm.MakeAlert; //注册方法 heater.Boiled += (new Alarm()).MakeAlert; //给匿名对象注册方法 heater.Boiled += new Heater.BoiledEventHandler(alarm.MakeAlert); //也可以这么注册 heater.Boiled += Display.ShowMsg; //注册静态方法 heater.BoilWater(); //烧水,会自动调用注册过对象的方法 }
public void TriggerNoStopAlarm() { int count = 0; this.integerVariable.Value = 0; Alarm alarm = new Alarm(this.integerVariable, value => (int)value != 30); alarm.StopAlarm += (oldvalue, newvalue) => count++; for (int k = 1; k <= 100; k++) if (k != 30) this.integerVariable.Value = k; Assert.AreEqual(0, count); }
public AlarmViewModel(Alarm alarm) { ShowObjectOrPlanCommand = new RelayCommand(OnShowObjectOrPlan); ShowObjectCommand = new RelayCommand(OnShowObject); ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan); ResetCommand = new RelayCommand(OnReset, CanReset); ResetIgnoreCommand = new RelayCommand(OnResetIgnore, CanResetIgnore); TurnOnAutomaticCommand = new RelayCommand(OnTurnOnAutomatic, CanTurnOnAutomatic); ShowJournalCommand = new RelayCommand(OnShowJournal); ShowPropertiesCommand = new RelayCommand(OnShowProperties, CanShowProperties); Alarm = alarm; InitializePlanLink(); }
private static AlarmAction ToAlarmAction(Alarm phoneAlarm) { return new AlarmAction() { BeginTime = new DateTimeOffset(phoneAlarm.BeginTime), ExpirationTime = new DateTimeOffset(phoneAlarm.ExpirationTime), IsScheduled = phoneAlarm.IsScheduled, IsEnabled = phoneAlarm.IsEnabled, Name = phoneAlarm.Name, Content = phoneAlarm.Content, RecurrencyType = (RecurrenceInterval)phoneAlarm.RecurrenceType, Title = phoneAlarm.Title }; }
public MainPageVM() { m_oAlarm = new Alarm("Parking Meter Timer"); init_timer(); // initialize xml serializer for storage m_xXmlSerializer = new XmlSerializer(typeof(SaveData)); // initialize the time selectors init_selectors(); // initialize all commands init_Commands(); }
private void SetAlarm(DateTime wakeupTime, int duration = 1) { Alarm alarm = new Alarm(ALARM_NAME); alarm.Content = "Wake uppp"; alarm.Sound = new Uri("/Ringtones/cuckoo__clock.mp3", UriKind.Relative); alarm.BeginTime = wakeupTime; alarm.ExpirationTime = DateTime.Now.AddDays(duration); alarm.RecurrenceType = RecurrenceInterval.Daily; if (!(ScheduledActionService.Find(ALARM_NAME) == null)) { ScheduledActionService.Remove(ALARM_NAME); } ScheduledActionService.Add(alarm); }
//private void TextBox_GotFocus(object sender, RoutedEventArgs e) //{ // if (this.bookname.Text.Equals("书名")) // { // this.bookname.Text = ""; // this.bookname.Foreground = new SolidColorBrush(Color.FromArgb(255,0,0,0)); // } //} private void save_clicked(object sender, EventArgs e) { plan.DatePicker = this.datePicker.ValueString; plan.Priority = (string)this.prioritylist.SelectedItem; plan.IsReminder = (bool)this.toggle.IsChecked; plan.RingTime = this.timepicker.ValueString; plan.Detail = this.detail.Text.ToString(); if (plan.IsReminder) { plan.Image = "/Icon/feature.alarm.png"; string clockname = "alarm" + plan.ISBN; //IEnumerable <Alarm> list = ScheduledActionService.GetActions<Alarm>(); if (isRemind) { if (ScheduledActionService.Find(clockname) != null) { ScheduledActionService.Remove(clockname); } } Alarm clock = new Alarm(clockname); //开始时间(注意考虑开始时间小于系统时间的情况) DateTime beginTime = (DateTime)this.timepicker.Value; TimeSpan timespan = beginTime.TimeOfDay; if (beginTime < DateTime.Now) { DateTime date = DateTime.Now.AddDays(1).Date; beginTime = date + timespan; Debug.WriteLine("[Debug]date:" + date + "timespan" + timespan + "beginTime.TimeOfDay" + beginTime); } clock.BeginTime = beginTime; //结束时间 //clock.ExpirationTime = clock.BeginTime + new TimeSpan(0, 0, 30); DateTime expirationtime = (DateTime)this.datePicker.Value + timespan; Debug.WriteLine("[Debug]expirationtime:" + expirationtime); if (expirationtime < beginTime) { MessageBox.Show("截止提醒时间已过,请修改截止时间或提醒时间"); return; } clock.ExpirationTime = expirationtime; //提醒内容 clock.Content = "别忘了今天要读<<" + plan.Title + ">>."; //提醒铃声 clock.Sound = new Uri("/SleepAway.mp3", UriKind.Relative); //提醒类型 clock.RecurrenceType = RecurrenceInterval.Daily; ScheduledActionService.Add(clock); } else { plan.Image = ""; string clockname = "alarm" + plan.ISBN; if (isRemind) { if (ScheduledActionService.Find(clockname) != null) { ScheduledActionService.Remove(clockname); } } } Debug.WriteLine("[DEBUG]plan.userid: " + plan.UserId + "plan.ISBN;" + plan.ISBN + "plan.title:" + plan.Title + "plan.dataPicker:" + plan.DatePicker + "plan.priority;" + plan.Priority + "plan.IsReminder:" + plan.IsReminder + "plan.ringtime:" + plan.RingTime + "plan.Detail:" + plan.Detail); bool result = bookService.updateReadingPlan(plan); if (result) { //MessageBox.Show("succeed!"); //NavigationService.Navigate(new Uri("/MainPage.xaml",UriKind.Relative)); NavigationService.GoBack(); } else { MessageBox.Show("failed!"); } }
public async Task LogAddMtu() { Mtu mtu = form.mtu; Global global = this.config.Global; dynamic map = form.map; string temp = string.Empty; string DISABLED = MemoryMap.MemoryMap.DISABLED; string ENABLED = MemoryMap.MemoryMap.ENABLED; ActionType actionType = this.action.type; bool isReplaceMeter = actionType == ActionType.ReplaceMeter || actionType == ActionType.ReplaceMtuReplaceMeter || actionType == ActionType.AddMtuReplaceMeter; bool isReplaceMtu = actionType == ActionType.ReplaceMTU || actionType == ActionType.ReplaceMtuReplaceMeter; #region General //logger.addAtrribute ( this.addMtuAction, "display", addMtuDisplay ); // logger.addAtrribute ( this.addMtuAction, "type", addMtuType ); // logger.addAtrribute ( this.addMtuAction, "reason", addMtuReason ); logger.AddAtrribute(this.addMtuAction, "display", Action.displays[this.action.type]); logger.AddAtrribute(this.addMtuAction, "type", Action.tag_types[this.action.type]); logger.AddAtrribute(this.addMtuAction, "reason", Action.tag_reasons[this.action.type]); logger.Parameter(this.addMtuAction, new Parameter("Date", "Date/Time", DateTime.UtcNow.ToString("MM/dd/yyyy HH:mm:ss"))); if (!string.IsNullOrEmpty(this.user)) { logger.Parameter(this.addMtuAction, new Parameter("User", "User", this.user)); } if (isReplaceMtu && form.ContainsParameter(FIELD.MTU_ID_OLD)) { logger.Parameter(this.addMtuAction, form.OldMtuId); } logger.Parameter(this.addMtuAction, new Parameter("MtuId", "MTU ID", this.mtuBasicInfo.Id)); logger.Parameter(this.addMtuAction, new Parameter("MtuType", "MTU Type", this.mtuBasicInfo.Type)); logger.Parameter(this.addMtuAction, form.ReadInterval); bool useDailyReads = (global.AllowDailyReads && mtu.DailyReads && form.ContainsParameter(FIELD.SNAP_READS)); string dailyReads = (useDailyReads) ? form.SnapReads.Value : DISABLED; string dailyGmtHourRead = (useDailyReads) ? form.SnapReads.Value : DISABLED; logger.Parameter(this.addMtuAction, new Parameter("DailyGMTHourRead", "GMT Daily Reads", dailyGmtHourRead)); if (!dailyGmtHourRead.Equals(DISABLED)) { logger.Parameter(this.addMtuAction, new Parameter("DailyReads", "Daily Reads", dailyReads)); } if (mtu.FastMessageConfig) { logger.Parameter(this.addMtuAction, form.TwoWay); } // Related to F12WAYRegister1XX registers string afc = (mtu.TimeToSync && global.AFC && await map.MtuSoftVersion.GetValue() >= 19) ? "Set" : "OFF"; logger.Parameter(this.addMtuAction, new Parameter("AFC", "AFC", afc)); #endregion #region Certificate Mobile.ConfigData data = Mobile.configData; // Avoid try to log encryption info when not it has not been performed if (data.isMtuEncrypted) { //logger.Parameter ( this.addMtuAction, new Parameter ( "Encryption", "Encrypted", map.Encryption.GetValue () ) ); logger.Parameter(this.addMtuAction, new Parameter("EncryptionIndex", "Encryption Index", await map.EncryptionIndex.GetValue())); // Using certificate with public key if (data.IsCertLoaded) { Utils.Print("Using certificate creating activity log"); logger.Parameter(this.addMtuAction, new Parameter("MtuSymKey", "MtuSymKey", data.RandomKeyAndShaEncryptedInBase64)); logger.Parameter(this.addMtuAction, new Parameter("HeadendCertThumb", "HeadendCertThumb", data.certificate.Thumbprint)); logger.Parameter(this.addMtuAction, new Parameter("HeadendCertValidTill", "HeadendCertExpiration", data.certificate.NotAfter.ToString("MM/dd/yy hh:mm:ss tt"))); logger.Parameter(this.addMtuAction, new Parameter("DeviceCertSubject", "DeviceCertSubject", data.certificate.Subject)); } // No certificate present else { Utils.Print("Not using certificate creating activity log"); logger.Parameter(this.addMtuAction, new Parameter("MtuSymKey", "MtuSymKey", data.RandomKeyAndShaInBase64)); } } #endregion #region Port 1 Meter meter = (!Data.Get.IsFromScripting) ? ( Meter )form.Meter.Value : this.config.getMeterTypeById(Convert.ToInt32(( string )form.Meter.Value)); XElement port = new XElement("Port"); logger.AddAtrribute(port, "display", "Port 1"); logger.AddAtrribute(port, "number", "1"); logger.Parameter(port, form.AccountNumber); if (global.WorkOrderRecording) { logger.Parameter(port, form.WorkOrder); } if (isReplaceMeter) { if (global.UseMeterSerialNumber) { logger.Parameter(port, form.MeterNumberOld); } if (global.MeterWorkRecording) { logger.Parameter(port, form.OldMeterWorking); } if (global.OldReadingRecording) { logger.Parameter(port, form.MeterReadingOld); } if (global.RegisterRecording) { logger.Parameter(port, form.ReplaceMeterRegister); } if (global.AutoRegisterRecording) { temp = (string.Equals(form.MeterNumber, form.MeterNumberOld)) ? "Register head change" : "Meter change"; logger.Parameter(port, new Parameter("MeterRegisterAutoStatus", temp, "Meter Register Auto Status")); } } string meterType = string.Format("({0}) {1}", meter.Id, meter.Display); logger.Parameter(port, new Parameter("MeterType", "Meter Type", meterType)); logger.Parameter(port, new Parameter("MeterTypeId", "Meter Type ID", meter.Id.ToString())); logger.Parameter(port, new Parameter("MeterVendor", "Meter Vendor", meter.Vendor)); logger.Parameter(port, new Parameter("MeterModel", "Meter Model", meter.Model)); if (global.UseMeterSerialNumber) { logger.Parameter(port, form.MeterNumber); } logger.Parameter(port, form.MeterReading); logger.Parameter(port, new Parameter("PulseHi", "Pulse Hi Time", meter.PulseHiTime.ToString().PadLeft(2, '0'))); logger.Parameter(port, new Parameter("PulseLo", "Pulse Low Time", meter.PulseLowTime.ToString().PadLeft(2, '0'))); this.addMtuAction.Add(port); #endregion #region Port 2 if (form.usePort2) { Meter meter2 = (!Data.Get.IsFromScripting) ? ( Meter )form.Meter_2.Value : this.config.getMeterTypeById(Convert.ToInt32(( string )form.Meter_2.Value)); port = new XElement("Port"); logger.AddAtrribute(port, "display", "Port 2"); logger.AddAtrribute(port, "number", "2"); logger.Parameter(port, form.AccountNumber_2); if (global.WorkOrderRecording) { logger.Parameter(port, form.WorkOrder_2); } if (isReplaceMeter) { if (global.UseMeterSerialNumber) { logger.Parameter(port, form.MeterNumberOld_2); } if (global.MeterWorkRecording) { logger.Parameter(port, form.OldMeterWorking_2); } if (global.OldReadingRecording) { logger.Parameter(port, form.MeterReadingOld_2); } if (global.RegisterRecording) { logger.Parameter(port, form.ReplaceMeterRegister_2); } if (global.AutoRegisterRecording) { temp = (string.Equals(form.MeterNumber_2, form.MeterNumberOld_2)) ? "Register head change" : "Meter change"; logger.Parameter(port, new Parameter("MeterRegisterAutoStatus", temp, "Meter Register Auto Status")); } } string meterType2 = string.Format("({0}) {1}", meter2.Id, meter2.Display); logger.Parameter(port, new Parameter("MeterType", "Meter Type", meterType2)); logger.Parameter(port, new Parameter("MeterTypeId", "Meter Type ID", meter2.Id.ToString())); logger.Parameter(port, new Parameter("MeterVendor", "Meter Vendor", meter2.Vendor)); logger.Parameter(port, new Parameter("MeterModel", "Meter Model", meter2.Model)); if (global.UseMeterSerialNumber) { logger.Parameter(port, form.MeterNumber_2); } logger.Parameter(port, form.MeterReading_2); logger.Parameter(port, new Parameter("PulseHi", "Pulse Hi Time", meter2.PulseHiTime.ToString().PadLeft(2, '0'))); logger.Parameter(port, new Parameter("PulseLo", "Pulse Low Time", meter2.PulseLowTime.ToString().PadLeft(2, '0'))); this.addMtuAction.Add(port); } #endregion #region Alarms if (mtu.RequiresAlarmProfile) { Alarm alarms = (Alarm)form.Alarm.Value; if (alarms != null) { XElement alarmSelection = new XElement("AlarmSelection"); logger.AddAtrribute(alarmSelection, "display", "Alarm Selection"); string overlap = alarms.Overlap.ToString(); logger.Parameter(alarmSelection, new Parameter("Overlap", "Message Overlap", overlap)); string alarmConfiguration = alarms.Name; logger.Parameter(alarmSelection, new Parameter("AlarmConfiguration", "Alarm Configuration Name", alarmConfiguration)); string immediateAlarmTransmit = (alarms.ImmediateAlarmTransmit) ? "True" : "False"; logger.Parameter(alarmSelection, new Parameter("ImmediateAlarm", "Immediate Alarm Transmit", immediateAlarmTransmit)); string urgentAlarm = (alarms.DcuUrgentAlarm) ? "True" : "False"; logger.Parameter(alarmSelection, new Parameter("UrgentAlarm", "DCU Urgent Alarm Transmit", urgentAlarm)); if (mtu.InsufficientMemory) { logger.Parameter(alarmSelection, new Parameter("InsufficentMemory", "Insufficent Memory", await map.InsufficientMemoryTamperStatus.GetValue())); } if (mtu.GasCutWireAlarm) { logger.Parameter(alarmSelection, new Parameter("CutAlarmCable", "Cut Alarm Cable", await map.GasCutWireTamperStatus.GetValue())); } if (mtu.SerialComProblem) { logger.Parameter(alarmSelection, new Parameter("SerialComProblem", "Serial Com Problem", await map.SerialComProblemTamperStatus.GetValue())); } if (mtu.LastGasp) { logger.Parameter(alarmSelection, new Parameter("LastGasp", "Last Gasp", await map.LastGaspTamperStatus.GetValue())); } if (mtu.TiltTamper) { logger.Parameter(alarmSelection, new Parameter("TiltTamper", "Tilt Tamper", await map.TiltTamperStatus.GetValue())); } if (mtu.MagneticTamper) { logger.Parameter(alarmSelection, new Parameter("MagneticTamper", "Magnetic Tamper", await map.MagneticTamperStatus.GetValue())); } if (mtu.InterfaceTamper) { logger.Parameter(alarmSelection, new Parameter("InterfaceTamper", "Interface Tamper", await map.InterfaceTamperStatus.GetValue())); } if (mtu.RegisterCoverTamper) { logger.Parameter(alarmSelection, new Parameter("RegisterCoverTamper", "Register Cover Tamper", await map.RegisterCoverTamperStatus.GetValue())); } if (mtu.ReverseFlowTamper) { logger.Parameter(alarmSelection, new Parameter("ReverseFlow", "Reverse Flow Tamper", await map.ReverseFlowTamperStatus.GetValue())); logger.Parameter(alarmSelection, new Parameter("FlowDirection", "Flow Direction", meter.Flow.ToString())); } if (mtu.SerialCutWire) { logger.Parameter(alarmSelection, new Parameter("SerialCutWire", "Serial Cut Wire", await map.SerialCutWireTamperStatus.GetValue())); } if (mtu.TamperPort1) { logger.Parameter(alarmSelection, new Parameter("Cut1WireTamper", "Cut Port1 Wire Tamper", await map.GasCutWireTamperStatus.GetValue())); } if (mtu.TamperPort2) { logger.Parameter(alarmSelection, new Parameter("Cut2WireTamper", "Cut Port2 Wire Tamper", await map.P2GasCutWireTamperStatus.GetValue())); } this.addMtuAction.Add(alarmSelection); } } #endregion // TODO (encoders) #region Demands if (mtu.MtuDemand) { XElement demandConf = new XElement("DemandConfiguration"); logger.AddAtrribute(demandConf, "display", "Demand Configuration"); logger.Parameter(demandConf, new Parameter("ConfigurationName", "Configuration Name", "Default")); // TODO: replace real value logger.Parameter(demandConf, new Parameter("MtuNumLowPriorityMsg", "Mtu Num Low Priority Msg", "2")); // TODO: replace real value logger.Parameter(demandConf, new Parameter("MtuPrimaryWindowInterval", "Mtu Primary WindowInterval", "180")); // TODO: replace real value logger.Parameter(demandConf, new Parameter("MtuWindowAStart", "Mtu Window A Start", "0")); // TODO: replace real value logger.Parameter(demandConf, new Parameter("MtuWindowBStart", "Mtu Window B Start", "0")); // TODO: replace real value logger.Parameter(demandConf, new Parameter("MtuPrimaryWindowIntervalB", "Mtu Primary WindowInterval B", "3600")); // TODO: replace real value logger.Parameter(demandConf, new Parameter("MtuPrimaryWindowOffset", "Mtu Primary Window Offset", "51")); // TODO: replace real value this.addMtuAction.Add(demandConf); } #endregion #region Misc/Optional if (form.ContainsParameter(FIELD.GPS_LATITUDE) && form.ContainsParameter(FIELD.GPS_LONGITUDE) && form.ContainsParameter(FIELD.GPS_ALTITUDE)) { //logger.logParameter ( this.addMtuAction, form.GPS_LATITUDE ); //logger.logParameter ( this.addMtuAction, form.GPS_LONGITUDE ); //logger.logParameter ( this.addMtuAction, form.GPS_ALTITUDE ); logger.Parameter(this.addMtuAction, new Parameter("GPS_Y", "Lat", form.GPSLat.Value)); logger.Parameter(this.addMtuAction, new Parameter("GPS_X", "Long", form.GPSLon.Value)); logger.Parameter(this.addMtuAction, new Parameter("Altitude", "Elevation", form.GPSAlt.Value)); } if (!(form.OptionalParams.Value is string)) { List <Parameter> optionalParams = (List <Parameter>)form.OptionalParams.Value; if (optionalParams != null) { foreach (Parameter p in optionalParams) { logger.Parameter(this.addMtuAction, p); } } } #endregion }
public void AddAlarm(Alarm alarm) { AlarmList.Add(alarm); SortAlarms(); }
public static void Disable(Alarm alarm) { TelephoneService.Recall(alarm.NumberToCall); }
public void SetAlarm(TimeStamp time, Action callback, bool recurring = false) { var alarm = new Alarm(time, callback, recurring); _newAlarms.Add(alarm); }
public bool TryFindAlarm(DateTime time, Sounds sound, string message, out Alarm outAlarm) { return(TryFindAlarm(time, sound, message, out outAlarm, 0)); }
public void InformationLog(Alarm alarm) { Console.WriteLine("Information"); Audit.InformationLog(alarm); }
/// <summary> /// 设备报警 /// </summary> /// <param name="alarm"></param> internal void OnAlarmReceived(Alarm alarm) { try { //logger.Debug("OnAlarmReceived started."); Event.Alarm alm = new Event.Alarm(); alm.AlarmType = alm.AlarmType = Event.Alarm.Types.AlarmType.CrossingLine; //switch (alarm.AlarmMethod) //{ // case "1": // break; // case "2": // alm.AlarmType = Event.Alarm.Types.AlarmType.AlarmOutput; // break; //} alm.Detail = alarm.AlarmDescription ?? string.Empty; //alm.DeviceID = alarm.DeviceID;//dms deviceid //alm.DeviceName = alarm.DeviceID;//dms name //devicemanagementservice 是预留的服务标识(暂命名为设备管理服务).目前没有这个服务. //需要你的微服务架构中实现一个设备资产以及一个配置管理服务(或者二合一的资源管服务) //以达到两个目的:1、用来为当前GB服务提供启动配置,2、为GB收到注册的设备/平台信息,提供全平台的统一的存储服务. string GBServerChannelAddress = EnvironmentVariables.DeviceManagementServiceAddress ?? "devicemanagementservice:8080"; logger.Debug("Device Management Service Address: " + GBServerChannelAddress); var channel = GrpcChannel.ForAddress(GBServerChannelAddress); var client = new DevicesManager.DevicesManagerClient(channel); var _rep = new QueryGBDeviceByGBIDsResponse(); var req = new QueryGBDeviceByGBIDsRequest(); logger.Debug("OnAlarmReceived Alarm: " + JsonConvert.SerializeObject(alarm)); req.GbIds.Add(alarm.DeviceID); _rep = client.QueryGBDeviceByGBIDs(req); if (_rep.Devices != null && _rep.Devices.Count > 0) { alm.DeviceID = _rep.Devices[0].GBID; alm.DeviceName = _rep.Devices[0].Name; } else { logger.Debug("QueryGBDeviceByGBIDsResponse Devices.Count: " + _rep.Devices.Count); } logger.Debug("QueryGBDeviceByGBIDsRequest-Alarm .Devices: " + _rep.Devices[0].ToString()); UInt64 timeStamp = (UInt64)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds; alm.EndTime = timeStamp; alm.StartTime = timeStamp; Message message = new Message(); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("Content-Type", "application/octet-stream"); message.Header = dic; message.Body = alm.ToByteArray(); byte[] payload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message)); string subject = Event.AlarmTopic.OriginalAlarmTopic.ToString();//"OriginalAlarmTopic" #region Options opts = ConnectionFactory.GetDefaultOptions(); opts.Url = EnvironmentVariables.GBNatsChannelAddress ?? Defaults.Url; logger.Debug("GB Nats Channel Address: " + opts.Url); using (IConnection c = new ConnectionFactory().CreateConnection(opts)) { c.Publish(subject, payload); c.Flush(); logger.Debug("Device alarm created connection and published."); } #endregion new Action(() => { logger.Debug("OnAlarmReceived AlarmResponse: " + alm.ToString()); _sipCoreMessageService.NodeMonitorService[alarm.DeviceID].AlarmResponse(alarm); }).Invoke(); } catch (Exception ex) { logger.Error("OnAlarmReceived Exception: " + ex.Message); } }
public AlarmOccurrence(Alarm a, IDateTime dt, IRecurringComponent rc) { Alarm = a; Period = new Period(dt); Component = rc; }
/// <summary> /// Increments the counter for the given alarm. /// </summary> /// <param name="alarm">The alarm that was raised.</param> public void IncrementCounter(Alarm alarm) { m_countBySeverity.AddOrUpdate((int)alarm.Severity, severity => 1L, (severity, count) => count + 1L); }
private IEnumerator BoostRoutine(Player player) { holding = player; travelling = true; ++nodeIndex; sprite.Visible = false; sprite.Position = Vector2.Zero; Collidable = false; var finalBoost = nodeIndex >= nodes.Length; Level level = SceneAs <Level>(); Stopwatch sw = new Stopwatch(); sw.Start(); if (!finalBoost) { Audio.Play("event:/char/badeline/booster_begin", Position); } else { Audio.Play("event:/char/badeline/booster_final", Position); } if (player.Holding != null) { player.Drop(); } player.StateMachine.State = 11; player.DummyAutoAnimate = false; player.DummyGravity = false; if (player.Inventory.Dashes > 1) { player.Dashes = 1; } else { player.RefillDash(); } player.RefillStamina(); player.Speed = Vector2.Zero; var side = Math.Sign(player.X - X); if (side == 0) { side = -1; } BadelineDummy badeline = new BadelineDummy(Position); Scene.Add(badeline); if (side == -1) { player.Facing = Facings.Right; } else { player.Facing = Facings.Left; } badeline.Sprite.Scale.X = side; Vector2 playerFrom = player.Position; Vector2 playerTo = Position + new Vector2(side * 4, -3f); Vector2 badelineFrom = badeline.Position; Vector2 badelineTo = Position + new Vector2(-side * 4, 3f); for (var p = 0.0f; (double)p < 1.0; p += Engine.DeltaTime / 0.2f) { Vector2 target = Vector2.Lerp(playerFrom, playerTo, p); if (player.Scene != null) { player.MoveToX(target.X); } if (player.Scene != null) { player.MoveToY(target.Y); } badeline.Position = Vector2.Lerp(badelineFrom, badelineTo, p); yield return(null); } if (finalBoost) { Vector2 center = new Vector2(Calc.Clamp(player.X - level.Camera.X, 120f, 200f), Calc.Clamp(player.Y - level.Camera.Y, 60f, 120f)); Add(new Coroutine(level.ZoomTo(center, 1.5f, 0.18f))); Engine.TimeRate = 0.5f; } else { Audio.Play("event:/char/badeline/booster_throw", Position); } badeline.Sprite.Play("boost"); yield return(0.1f); if (!player.Dead) { player.MoveV(5f); } yield return(0.1f); Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => { if (player.Dashes < player.Inventory.Dashes) { ++player.Dashes; } Scene.Remove(badeline); (Scene as Level)?.Displacement.AddBurst(badeline.Position, 0.25f, 8f, 32f, 0.5f); }, 0.15f, true)); (Scene as Level)?.Shake(); holding = null; if (!finalBoost) { player.BadelineBoostLaunch(CenterX); Vector2 from = Position; Vector2 to = nodes[nodeIndex]; var time = Vector2.Distance(from, to) / MoveSpeed; time = Math.Min(3f, time); stretch.Visible = true; stretch.Rotation = (to - from).Angle(); Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.SineInOut, time, true); tween.OnUpdate = t => { Position = Vector2.Lerp(from, to, t.Eased); stretch.Scale.X = (float)(1.0 + Calc.YoYo(t.Eased) * 2.0); stretch.Scale.Y = (float)(1.0 - Calc.YoYo(t.Eased) * 0.75); if (t.Eased >= 0.899999976158142 || !Scene.OnInterval(0.03f)) { return; } TrailManager.Add(this, Player.TwoDashesHairColor, 0.5f, false); level.ParticlesFG.Emit(BadelineBoost.P_Move, 1, Center, Vector2.One * 4f); }; tween.OnComplete = t => { if (level != null && X >= (double)level.Bounds.Right) { RemoveSelf(); } else { travelling = false; stretch.Visible = false; sprite.Visible = true; Collidable = true; Audio.Play("event:/char/badeline/booster_reappear", Position); } }; Add(tween); relocateSfx.Play("event:/char/badeline/booster_relocate"); Input.Rumble(RumbleStrength.Strong, RumbleLength.Medium); level.DirectionalShake(-Vector2.UnitY); level.Displacement.AddBurst(Center, 0.4f, 8f, 32f, 0.5f); } else { Console.WriteLine("TIME: " + sw.ElapsedMilliseconds); Engine.FreezeTimer = 0.1f; yield return(null); Input.Rumble(RumbleStrength.Strong, RumbleLength.Long); level.Flash(Color.White * 0.5f, true); level.DirectionalShake(Vector2.UnitY, 0.6f); level.Displacement.AddBurst(Center, 0.6f, 8f, 64f, 0.5f); level.ResetZoom(); player.StateMachine.State = 18; Engine.TimeRate = 1f; Finish(); } }
public void addAlarm(Alarm alarm) { this.internAlarmList.Add(alarm); }
public static bool Validate(Alarm alarm, byte[] encryptedAlarm, byte[] signature) { return(ValidateAlarm(alarm) && ValidateSignature(encryptedAlarm, signature)); }
public void CriticalLog(Alarm alarm) { Console.WriteLine("Critical"); Audit.CriticalLog(alarm); this.proxy.DeleteFile(alarm.Filename); }
protected void btnUpload_Click(object sender, EventArgs e) { try { if (!FileUpload1.HasFile) { throw new MyFlightbookException("Please provide a file."); } using (iCalendar ic = new iCalendar()) { using (CSVReader cr = new CSVReader(FileUpload1.FileContent)) { string[] rgCols = cr.GetCSVLine(true); int iColSubject = -1; int iColStartDate = -1; int iColStartTime = -1; int iColEndDate = -1; int iColEndTime = -1; int iColLocation = -1; for (int i = 0; i < rgCols.Length; i++) { switch (rgCols[i]) { case "Subject": iColSubject = i; break; case "Start Date": iColStartDate = i; break; case "Start Time": iColStartTime = i; break; case "End Date": iColEndDate = i; break; case "End Time": iColEndTime = i; break; case "Location": iColLocation = i; break; } } if (iColSubject < 0) { throw new MyFlightbookException("No subject column found"); } if (iColStartDate < 0) { throw new MyFlightbookException("No start date column found"); } if (iColStartTime < 0) { throw new MyFlightbookException("No start time column found"); } if (iColEndDate < 0) { throw new MyFlightbookException("No end date column found"); } if (iColEndTime < 0) { throw new MyFlightbookException("No end time column found"); } if (iColLocation < 0) { throw new MyFlightbookException("No location column found"); } int id = 0; while ((rgCols = cr.GetCSVLine()) != null) { if (String.IsNullOrEmpty(rgCols[iColSubject])) { continue; } Event ev = ic.Create <Event>(); ev.UID = id++.ToString(System.Globalization.CultureInfo.InvariantCulture); ev.IsAllDay = false; ev.Description = ev.Summary = rgCols[iColSubject]; ev.Location = rgCols[iColLocation]; DateTime dtStart = Convert.ToDateTime(String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} {1}", rgCols[iColStartDate], rgCols[iColStartTime]), System.Globalization.CultureInfo.CurrentCulture); DateTime dtEnd = Convert.ToDateTime(String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} {1}", rgCols[iColEndDate], rgCols[iColEndTime]), System.Globalization.CultureInfo.CurrentCulture); ev.Start = new iCalDateTime(dtStart, "Pacific Standard Time"); ev.End = new iCalDateTime(dtEnd, "Pacific Standard Time"); Alarm a = new Alarm(); a.Action = AlarmAction.Display; a.Description = ev.Summary; a.Trigger = new Trigger(); a.Trigger.DateTime = ev.Start.AddMinutes(-30); ev.Alarms.Add(a); ic.Method = "PUBLISH"; } iCalendarSerializer s = new iCalendarSerializer(); string output = s.SerializeToString(ic); Page.Response.Clear(); Page.Response.ContentType = "text/calendar"; Response.AddHeader("Content-Disposition", String.Format(System.Globalization.CultureInfo.InvariantCulture, "inline;filename={0}.ics", txtTitle.Text)); Response.Write(output); Response.Flush(); Response.End(); } } } catch (CSVReaderInvalidCSVException ex) { lblErr.Text = ex.Message; } catch (MyFlightbookException ex) { lblErr.Text = ex.Message; } }
bool AlarmTrigger(int hour, Days day, Alarm alarm) { return(((day & alarm.day) != 0) && ((hour == alarm.hour))); }
protected override void LogicImpl() { var Para = Product.Inst; switch (LG.Step) { case 1: if (TaskMain.sticklogic.feeder.GetBusy) { return; } TakeCount = 0; //取料个数 whichNuzzle = 0; //哪个吸嘴 LG.StepNext(2); break; case 2: //Z轴抬起到安全高度 for (int i = 0; i < CTRCard.Axis_Z.Count; i++) { CTRCard.Axis_Z[i].MC_MoveAbs(Para.Stickdata.ZSafePos); //Z到安全位置 CTRCard.Axis_R[i].MC_MoveAbs(0); } LG.StepNext(3); break; case 3: if (CTRCard.ZArrive && CTRCard.RArrive) { bool isCanTake = false; if ( Para.Stickdata.NuzzleForbit[whichNuzzle] == false && Para.ProcessData.NuzzlePara[whichNuzzle].isHave == false) //吸嘴没被禁用且没有料 { isCanTake = true; } else { if (Para.Stickdata.NuzzleForbit[whichNuzzle] == true) //吸嘴禁用取料加1 { TakeCount++; } } if (isCanTake) { if (TakeCount == 1 && whichNuzzle == 1) { LG.StepNext(7); //如果左吸嘴取过一次且目前可以取料的是右吸嘴 } else { LG.StepNext(4); //可以取料 去取料位置 } } else { LG.StepNext(14); //去 判断 } } break; case 4: if (whichNuzzle == 0) { Ltime.Stop(); Lsticktime = (int)Ltime.ElapsedMilliseconds; Ltime.Restart(); } else { Rtime.Stop(); Rsticktime = (int)Rtime.ElapsedMilliseconds; Rtime.Restart(); } CTRCard.Axis_X.MC_MoveAbs(Para.Stickdata.FeederPara.TakePos.X); CTRCard.Axis_Y.MC_MoveAbs(Para.Stickdata.FeederPara.TakePos.Y); //到拍照位置 DeviceRsDef.Q_UpLighSource.ON(); //上光源打开 LG.StepNext(5); break; case 5: if (CTRCard.XYArrive) { //VisionProject.Instance.visionApi.TrigRun(0, 2);//触发拍照 LG.StepNext(6); } break; case 6: if (Product.Inst.IsAging) { if (LG.Delay(200)) { CCDresult.X = 0; CCDresult.Y = 0; CCDresult.R = 0; LG.StepNext(7); } } else { //if (VisionProject.Instance.visionApi.Trig == false)//相机触发的值 //{ // if (VisionProject.Instance.visionApi.Error == 0)//相机接口错误码 // { // LG.StepNext(7);//xy到取标位置 // DeviceRsDef.Q_UpLighSource.OFF();//上相机光源关闭 // } // else // { // LG.StepNext(101);//重新送料 // CTCount++;//拍照识别次数 // if (CTCount > 2)//大于2就视觉NG // { // CTCount = 0;//重新置零 // Alarm.SetAlarm(AlarmLevelEnum.Level2, "Feeder视觉NG");//报警 // } // } //} } break; case 7: CTRCard.Q_Blow[whichNuzzle].OFF(); //吹气关闭 if (Product.Inst.IsAging) { if (LG.Delay(500)) { CCDresult.X = 0; CCDresult.Y = 0; CCDresult.R = 0; } } //else if (VisionProject.Instance.visionApi.Result.Length == 2) //{ // CCDresult.X = (float)VisionProject.Instance.visionApi.Result[TakeCount].X;//ccd的x值[改为链表形式] // CCDresult.Y = (float)VisionProject.Instance.visionApi.Result[TakeCount].Y;//ccd的y值 // CCDresult.R = -(float)VisionProject.Instance.visionApi.Result[TakeCount].R;//ccd的r值 //} //else //{ // CCDresult.X = (float)VisionProject.Instance.visionApi.Result[0].X;//ccd的x值[改为链表形式] // CCDresult.Y = (float)VisionProject.Instance.visionApi.Result[0].Y;//ccd的y值 // CCDresult.R = -(float)VisionProject.Instance.visionApi.Result[0].R;//ccd的r值 //} CTRCard.Axis_X.MC_MoveAbs(TakePos(whichNuzzle).X + (float)CCDresult.X); CTRCard.Axis_Y.MC_MoveAbs(TakePos(whichNuzzle).Y + (float)CCDresult.Y); CTRCard.Axis_R[whichNuzzle].MC_MoveAbs((float)CCDresult.R); LG.StepNext(8); break; case 8: //XY到位后判断缓取,开始下压时打开吸嘴 if (CTRCard.RArrive && CTRCard.XYArrive) { if (whichNuzzle == 0) { CTRCard.Axis_Z[whichNuzzle].MC_MoveAbs(Para.Stickdata.TakeLabelPara.LiftTakePos_Z); } else { CTRCard.Axis_Z[whichNuzzle].MC_MoveAbs(Para.Stickdata.TakeLabelPara.RightTakePos_Z); } LG.StepNext(9); } break; case 9: if (CTRCard.ZArrive) { CTRCard.Q_Nuzzle[whichNuzzle].ON(); //真空打开 CTRCard.Q_Blow[whichNuzzle].OFF(); //吹气关闭 LG.StepNext(10); } break; case 10: if (whichNuzzle == 0) { Para.Stickdata.TakeLabelPara.TakeLableWholeLNum++; } else { Para.Stickdata.TakeLabelPara.TakeLableWholeRNum++; } LG.StepNext(11); break; case 11: //取标延时后Z轴抬起(缓抬) if (whichNuzzle == 0 && LG.Delay(Para.Stickdata.TakeLabelPara.LiftTakeDelay)) { LG.StepNext(201); } else if (whichNuzzle == 1 && LG.Delay(Para.Stickdata.TakeLabelPara.RightTakeDelay)) { LG.StepNext(201); } break; case 201: if (Para.Stickdata.FeederPara.FeederMode[1]) { //剥标板回退 LG.StepNext(202); } else { LG.StepNext(12); } break; case 202: if (Para.Stickdata.FeederPara.FeederMode[1]) //拨标板回退停止 { CTRCard.Axis_Z[whichNuzzle].MC_MoveAbs(Para.Stickdata.ZSafePos); //Z轴抬起 LG.StepNext(13); } break; case 12: //取标延时后Z轴抬起 if (CTRCard.ZArrive) { CTRCard.Axis_Z[whichNuzzle].MC_MoveAbs(Para.Stickdata.ZSafePos); LG.StepNext(13); } break; case 13: //检测真空//add if (CTRCard.ZArrive) //所有轴都到达 { if (!Product.Inst.IsAging && CTRCard.I_Vacuum[whichNuzzle].Value == false) { TakeNum++; if (TakeNum >= 2) { TakeNum = 0; LG.StepNext(101); //运行状态下进入14 重新剥标 CTRCard.Q_Nuzzle[whichNuzzle].Value = false; //吸真空电磁阀 Alarm.SetAlarm(AlarmLevelEnum.Level2, "取料失败,请检查真空和真空感应"); Para.ProcessData.NuzzlePara[whichNuzzle].isHave = false; //是否有料 } else { LG.StepNext(4); //到拍照位 } } else { if (whichNuzzle == 0) { Para.Stickdata.TakeLabelPara.TakeLableLNum++; } else { Para.Stickdata.TakeLabelPara.TakeLableRNum++; } LG.StepNext(14); //结束 Para.ProcessData.NuzzlePara[whichNuzzle].isHave = true; //有料 } } break; case 101: if (CTRCard.ZArrive) { LG.StepNext(4); } break; case 14: //结束 if (CTRCard.ZArrive) { whichNuzzle++; //吸嘴换成另一个吸嘴 TakeCount++; if (whichNuzzle >= 2) { LG.StepNext(15); } else { LG.StepNext(2); } } break; case 15: if (TakeCount >= 2) { LG.StepNext(0xef); } //else if (VisionProject.Instance.visionApi.Result.Length == 1) //{ // TakeCount = 0; // LG.StepNext(0xef); //} else if (Para.ProcessData.NuzzlePara[0].isHave == true && Para.ProcessData.NuzzlePara[1].isHave == true) { TakeCount = 0; LG.StepNext(0xef); } else { LG.StepNext(2); } break; case 0xef: LG.End(); break; } }
public TimedAlarm(Alarm alarm, IEnumerable <TimeCriterion> timeServices) { _alarm = alarm; _timeServices = timeServices; }
public static void Trigger(Alarm alarm) { TelephoneService.Call(alarm.NumberToCall); }
/// <summary> /// Send the remove alarm command to the arduino. /// </summary> /// <param name="alarm">The alarm we want to remove.</param> private void SendRemoveAlarm(Alarm alarm) { SocketWorker.Send( Commands.AlarmRemove, alarm.Id.ToString() ); }
protected void Page_Load(object sender, EventArgs e) { //if (Session["IsFirstLogin"] != null) //{ // if (Session["IsFirstLogin"].ToString() == "1") // { // } // else // { if (!IsPostBack) { GC.Collect(); Response.ExpiresAbsolute = DateTime.Now; try { string str = "<script> " + "try " + "{ " + " var nav=window.parent.frames.Navigation.document.getElementById('labNavigation');" + " nav.innerText='快速通道';" + "} " + "catch(e) " + "{ " + "} " + "</script>"; this.ClientScript.RegisterClientScriptBlock(this.GetType(), DateTime.Now.ToLongTimeString(), str); #region 提醒 bool show = false; Alarm objAlarm = new Alarm(); DataSet dsRemind = objAlarm.GetRemindList(); if (dsRemind.Tables[0].Rows.Count > 0) { show = true; TableRow tr = new TableRow(); TableCell tc = new TableCell(); tc.Text = string.Format("<a href='code/StorageManagement/StorageRemindPage.aspx'>有:<font color='red'>{0}条</font>库存预警信息</a>", dsRemind.Tables[0].Rows.Count); tr.Controls.Add(tc); this.tblRemind.Controls.Add(tr); } if (show) { this.pnlRemind.Visible = true; } else { this.pnlRemind.Visible = false; } #endregion } catch (Exception ex) { //Session["ModuleName"] = "MainPage.aspx"; //Session["FunctionName"] = "Page_Load事件"; //Session["ExceptionalType"] = ex.GetType().FullName; //Session["ExceptionalDescription"] = ex.Message; //Response.Redirect("Common/MistakesPage.aspx"); } } //} if (Session["UserID"] != null) { GetDestopItemByUserID(Session["UserID"].ToString()); } else { Response.Redirect("~/SessionTimeOut.aspx"); } CreatePage(); //} //else //{ // Response.Redirect("~/SessionTimeOut.aspx"); //} }
public static async Task ReplyWithDeletedAlarm(ITurnContext context, Alarm data) { await context.SendActivity($"I have deleted {data.Title} alarm"); }
private void SendAlarm(PlateInfo plateInfo, string milestoneCameraName, FQID bookmarkFQID)//, string plateFromAlertList, string descFromAlertList) { var fqid = MilestoneServer.GetCameraByName(milestoneCameraName); var temp = AlertListHelper.GetLastWriteTime(); if (temp != lastAlertUpdateTime) { AlertListHelper.LoadAlertList(dicBlack); lastAlertUpdateTime = temp; Program.Logger.Log.Info("Reload Alert list"); } var plateFromAlertList = plateInfo.BestPlateNumber; var existsInAlertList = dicBlack.ContainsKey(plateInfo.BestPlateNumber); if (!existsInAlertList) { Program.Logger.Log.Info($"{plateFromAlertList} not listed in the alert list."); Program.Logger.Log.Info($"looking if any candidates listed in the alert list"); existsInAlertList = plateInfo.CandidatesPlate.Split(',').Any(p => dicBlack.ContainsKey(p)); if (existsInAlertList) { plateFromAlertList = plateInfo.CandidatesPlate.Split(',').FirstOrDefault(p => dicBlack.ContainsKey(p)); Program.Logger.Log.Info($"Candidate {plateFromAlertList} listed in the alert list"); } else { Program.Logger.Log.Info($"No any candidates plate number listed in the alert list"); } } else { Program.Logger.Log.Info($"{plateFromAlertList} found in the alert list"); } if (existsInAlertList) { var descFromAlertList = dicBlack[plateFromAlertList]; Program.Logger.Log.Info($"Sending an alert for {plateInfo.BestPlateNumber}"); var cameraName = MilestoneServer.GetCameraName(fqid.ObjectId); var eventSource = new EventSource() { FQID = fqid, Name = cameraName, //Description = "", //ExtensionData = }; var eventHeader = new EventHeader() { //The unique ID of the event. ID = Guid.NewGuid(), //The class of the event, e.g. "Analytics", "Generic", "User-defined". Class = "Analytics", //The type - a sub-classification - of the event, if applicable. Type = null, //The time of the event. Timestamp = plateInfo.EpochStart, //The event message. This is the field that will be matched with the AlarmDefinition message when sending this event to the Event Server. Message = "OpenALPR Alarm", //The event name. Name = plateInfo.BestPlateNumber, //The source of the event. This can represent e.g. a camera, a microphone, a user-defined event, etc. Source = eventSource, //The priority of the event. Priority = 2, //The priority name of the event. PriorityName = "Medium", //optional //The message id of the event. The message id coorsponds to the ID part returned in ItemManager.GetKnownEventTypes. MessageId = Guid.Empty, //A custom tag set by the user to filter the events. CustomTag = plateFromAlertList,// the value we got from the config file //The expire time of the event. The event will be deleted from the event database when the time is reached. When creating events a value of DateTime.MinValue (default value) indicates that the default event expire time should be used. ExpireTimestamp = DateTime.Now.AddDays(EventExpireAfterDays), //ExtensionData = System.Runtime .Serialization. //The version of this document schema. Version = null }; var alarm = new Alarm() { //The EventHeader, containing information common for all Milestone events. EventHeader = eventHeader, //The current state name. StateName = "In progress", //The current state of the alarm. 0: Any 1: New 4: In progress 9: On hold 11: Closed. State = 4, //The user to which the alarm is currently assigned. Can be seen in the Smart Client dropdown AssignedTo = null,//Environment.UserName, // Other fields could be filled out, e.g. objectList //The current category of the alarm. This should be created first on the Client Management under Alarms then Alaem Data Settings //Category = 0, //The current category name. //CategoryName = null,//"Critical", //The count value, if the alarm is a counting alarm. Default: 0 (no count). Count = 0, //The description of the alarm. Description = descFromAlertList, //The end time of the alarm, if it takes plate over a period of time. EndTime = plateInfo.EpochStart.AddSeconds(EpochEndSecondsAfter), // ExtensionData = //The location of the alarm (this will typically be the same as the camera's location). //Location = null, //The ObjectList, containing information about the detected object(s) in the scene. //new AnalyticsObjectList() //ObjectList = null, // The ReferenceList, containing any number of references to other entities in the system, e.g. alarms or cameras, by FQID. ReferenceList = new ReferenceList { new Reference { FQID = bookmarkFQID } }, // save bookmark id //The RuleList, containing information contains information about the rule(s), which triggered the alarm. //RuleList = null,//new RuleList(), //The SnapshotList, containing any number of images related to the alarm. If the Source is a camera, it is not neccesary to attach a snapshot from that camera at the time of the alarm. //SnapshotList = null,// new SnapshotList(), //The start time of the alarm, if it takes plate over a period of time. StartTime = plateInfo.EpochStart.AddSeconds(-EpochStartSecondsBefore), //The Vendor, containing information about the analytics vendor including any custom data. Vendor = new Vendor { CustomData = plateInfo.ToString() } // save json data }; // Send the Alarm directly to the EventServer, to store in the Alarm database. No rule is being activated. try { using (var impersonation = new Impersonation(BuiltinUser.NetworkService)) EnvironmentManager.Instance.SendMessage(new Message(MessageId.Server.NewAlarmCommand) { Data = alarm }); } catch (Exception ex) { Program.Logger.Log.Error(null, ex); } } }
/// <summary> /// Message消息处理 /// </summary> /// <param name="localEP">本地终结点</param> /// <param name="remoteEP">远程终结点</param> /// <param name="request">sip请求</param> private void MessageHandle(SIPEndPoint localEP, SIPEndPoint remoteEP, SIPRequest request) { SendResponse(localEP, remoteEP, request); //心跳消息 KeepAlive keepAlive = KeepAlive.Instance.Read(request.Body); if (keepAlive != null && keepAlive.CmdType == CommandType.Keepalive) { KeepaliveHandle(localEP, remoteEP, request, keepAlive); return; } //设备目录 Catalog catalog = Catalog.Instance.Read(request.Body); if (catalog != null && catalog.CmdType == CommandType.Catalog) { CatalogHandle(localEP, remoteEP, request, catalog); return; } //录像查询 RecordInfo record = RecordInfo.Instance.Read(request.Body); if (record != null && record.CmdType == CommandType.RecordInfo) { RecordInfoHandle(localEP, remoteEP, request, record); return; } //媒体通知 MediaStatus mediaStatus = MediaStatus.Instance.Read(request.Body); if (mediaStatus != null && mediaStatus.CmdType == CommandType.MediaStatus) { _nodeMonitorService[request.Header.From.FromURI.User].ByeVideoReq(); //取值121表示历史媒体文件发送结束(回放结束/下载结束) //NotifyType未找到相关文档标明所有该类型值,暂时只处理121 if (mediaStatus.NotifyType.Equals("121")) { OnMediaStatusReceived?.Invoke(remoteEP, mediaStatus); } return; } //设备状态查询 DeviceStatus deviceStatus = DeviceStatus.Instance.Read(request.Body); if (deviceStatus != null && deviceStatus.CmdType == CommandType.DeviceStatus) { OnDeviceStatusReceived?.Invoke(remoteEP, deviceStatus); return; } //设备信息查询 DeviceInfo deviceInfo = DeviceInfo.Instance.Read(request.Body); if (deviceInfo != null && deviceInfo.CmdType == CommandType.DeviceInfo) { OnDeviceInfoReceived?.Invoke(remoteEP, deviceInfo); return; } //设备配置查询 DeviceConfigDownload devDownload = DeviceConfigDownload.Instance.Read(request.Body); if (devDownload != null && devDownload.CmdType == CommandType.ConfigDownload) { OnDeviceConfigDownloadReceived?.Invoke(remoteEP, devDownload); } //预置位查询 PresetInfo preset = PresetInfo.Instance.Read(request.Body); if (preset != null && preset.CmdType == CommandType.PresetQuery) { OnPresetQueryReceived?.Invoke(remoteEP, preset); } //报警通知 Alarm alarm = Alarm.Instance.Read(request.Body); if (alarm != null && alarm.CmdType == CommandType.Alarm)//单兵上报经纬度 { OnAlarmReceived?.Invoke(alarm); } }
public NewAlarmPageModel(IAlarmStorageService alarmStorage) : base(alarmStorage) { Alarm = new Alarm(); AlarmTone = alarmStorage.GetTone(Alarm.Tone); Alarm.Time = DateTime.Now.TimeOfDay; }
public static void Dump(Alarm alarm) { Console.WriteLine("{ Calls: " + alarm.NumberToCall + " }"); }
public void SetAlarm() { if (settingAlarm) { return; } settingAlarm = true; int jaarId = tijdInfo[4].value; int maandId = tijdInfo[3].value; int dagId = tijdInfo[2].value; int minuutId = tijdInfo[1].value; int urenId = tijdInfo[0].value; int jaar = int.Parse(tijdInfo[4].options[jaarId].text); int maand = int.Parse(tijdInfo[3].options[maandId].text); int dag = int.Parse(tijdInfo[2].options[dagId].text); int uren = int.Parse(tijdInfo[1].options[minuutId].text); int minuten = int.Parse(tijdInfo[0].options[urenId].text); if (jaar == null) { jaar = 0; } if (maand == null) { maand = 0; } if (dag == null) { dag = 0; } if (uren == null) { uren = 0; } if (minuten == null) { minuten = 0; } DateTime alarmTime = new DateTime(jaar, maand, dag, uren, minuten, 0); Alarm newAlarm = new Alarm(); switch (alarmOption.value) { case 0: newAlarm = new Alarm(alarmTime, KoffieAan); break; case 1: newAlarm = new Alarm(alarmTime, KoffieZetten); break; default: newAlarm = new Alarm(DateTime.Now, null); break; } if (!newAlarm.Equals(null)) { AlarmElement temp = new AlarmElement(newAlarm.AlarmTime().ToString(), newAlarm.actionToPerform.Method.Name); fullfile.alarms.Add(temp); alarmCount++; network.debugText.GetComponent <Text>().text = alarmCount + " alarm count"; dirty = true; } settingAlarm = false; }
void CreateAlarm(Vector3 pos, float duration) { Alarm newAlarm = new Alarm(pos, duration); alarms.AddLast(newAlarm); }
public Resp_Binary_Member <AlarmDTO> Add_One(CaptureDTO model) { var alert = false; var capture = model.GetPrototype <CaptureDTO, Capture>(); if (capture.Pass == 1) //without代表该车出场 { capture.WithOut = 0; } if (capture.Pass == 0) { capture.WithOut = 1; } var result = false; var guid = Guid.NewGuid().ToString(); long layoutId = 0; using (var context = new SKContext()) { using (var tran = new TransactionScope()) { var layout = context.Layouts.Where(d => d.CarNumber == model.CarNumber && d.IsValid == 1 && d.Channel == model.Channel).FirstOrDefault(); if (layout.IsNotNull()) { if (layout.TriggerType == 2 || layout.TriggerType == model.Pass.ToInt()) //进出场控制 { alert = true; var lettercode = GetRandomNumberString(ConfigPara.LetterCount); var alarm = new Alarm { CarNumber = model.CarNumber, IsDeal = 0, GUID = guid, AlarmTime = DateTime.Now, Channel = model.Channel, LetterCode = AESEncryptHelper.Encrypt(lettercode) }; _messageRepository.SendMessage(capture.ToJson(), capture.Channel); capture.Alarms.Add(alarm); layoutId = layout.ID; //if (layout.Degree > 0) // --layout.Degree; //if (layout.Degree == 0) // layout.IsValid = 0; } } var captureback = model.GetPrototype <CaptureDTO, CaptureBackup>(); //当车出场时,将该车的进场记录的是否出场改为已出场 if (model.Pass.ToInt() == 0) { var in_captures = context.Captures.Where(t => t.CarNumber == model.CarNumber && t.Pass == 1 && t.WithOut == 0); foreach (var item in in_captures) { item.WithOut = 1; } } var recordM = context.RecordManagers.Where(t => t.CarNumber == model.CarNumber).OrderByDescending(t => t.ID).FirstOrDefault(); if (recordM.IsNotNull()) { capture.BeiAn = recordM.Type; captureback.BeiAn = recordM.Type; if (model.Pass.ToInt() == 1) //进场修改备案最后一次进场时间 { recordM.LastInTime = model.CreateTime.ToDateTime(); } else if (model.Pass.ToInt() == 0) //出场修改备案最近一次出场时间 { recordM.LastOutTime = model.CreateTime.ToDateTime(); } } else { capture.BeiAn = 2; captureback.BeiAn = 2; } context.Captures.Add(capture); context.CaptureBackups.Add(captureback); context.SaveChanges(); tran.Complete(); result = true; } } if (result) { if (alert) { // var req_dock = new Req_Warning // { // WARNINGDATE = DateTime.Now.ToString("yyyy-MM-dd hh: mm:ss"), // CARNO = model.CarNumber, // CARTYPE = model.CarType, // inout = model.Pass.Equals("1") ? "进" : "出", // bayonet = model.Channel, // Remark = model.Remark // }; // Docking(req_dock); //报警通知第三方 var alam = _alarmRepository.GetByWhere(t => t.GUID == guid).FirstOrDefault(); var dto = alam.ConvertoDto <Alarm, AlarmDTO>(); dto.LetterCode = alam.LetterCode; return(new Resp_Binary_Member <AlarmDTO> { message = "该车辆已中控报警!", flag = 2, LetterCode = dto.LetterCode, entity = dto, LayoutId = layoutId }); } return(new Resp_Binary_Member <AlarmDTO> { message = "添加成功", flag = 1 }); } return(new Resp_Binary_Member <AlarmDTO> { message = "添加失败", flag = 0 }); }
public void LogAddMtu(bool isFromScripting = false) { Mtu mtu = form.mtu; Global global = form.global; dynamic map = form.map; string temp = string.Empty; bool isReplaceMeter = form.actionType == ActionType.ReplaceMeter || form.actionType == ActionType.ReplaceMtuReplaceMeter || form.actionType == ActionType.AddMtuReplaceMeter; bool isReplaceMtu = form.actionType == ActionType.ReplaceMTU || form.actionType == ActionType.ReplaceMtuReplaceMeter; #region General logger.addAtrribute(this.addMtuAction, "display", addMtuDisplay); logger.addAtrribute(this.addMtuAction, "type", addMtuType); logger.addAtrribute(this.addMtuAction, "reason", addMtuReason); logger.logParameter(this.addMtuAction, new Parameter("Date", "Date/Time", DateTime.UtcNow.ToString("MM/dd/yyyy HH:mm:ss"))); if (!string.IsNullOrEmpty(this.user)) { logger.logParameter(this.addMtuAction, new Parameter("User", "User", this.user)); } if (isReplaceMtu && form.ContainsParameter(FIELD.MTU_ID_OLD)) { logger.logParameter(this.addMtuAction, form.OldMtuId); } logger.logParameter(this.addMtuAction, new Parameter("MtuId", "MTU ID", this.mtuBasicInfo.Id)); logger.logParameter(this.addMtuAction, new Parameter("MtuType", "MTU Type", this.mtuBasicInfo.Type)); logger.logParameter(this.addMtuAction, form.ReadInterval); bool useDailyReads = (global.AllowDailyReads && mtu.DailyReads); string dailyReads = (useDailyReads) ? form.SnapReads.Value : "Disable"; string dailyGmtHourRead = (useDailyReads) ? form.SnapReads.Value : "Disable"; logger.logParameter(this.addMtuAction, new Parameter("DailyGMTHourRead", "GMT Daily Reads", dailyGmtHourRead)); logger.logParameter(this.addMtuAction, new Parameter("DailyReads", "Daily Reads", dailyReads)); if (mtu.FastMessageConfig) { logger.logParameter(this.addMtuAction, form.TwoWay); } // Related to F12WAYRegister1XX registers string afc = (mtu.TimeToSync && global.AFC && map.MtuSoftVersion >= 19) ? "Set" : "Off"; logger.logParameter(this.addMtuAction, new Parameter("AFC", "AFC", afc)); #endregion #region Port 1 Meter meter = (!isFromScripting) ? ( Meter )form.Meter.Value : Configuration.GetInstance().getMeterTypeById(Convert.ToInt32(( string )form.Meter.Value)); XElement port = new XElement("Port"); logger.addAtrribute(port, "display", "Port 1"); logger.addAtrribute(port, "number", "1"); logger.logParameter(port, form.AccountNumber); if (global.WorkOrderRecording) { logger.logParameter(port, form.WorkOrder); } if (isReplaceMeter) { if (global.UseMeterSerialNumber) { logger.logParameter(port, form.MeterNumberOld); } if (global.MeterWorkRecording) { logger.logParameter(port, form.OldMeterWorking); } if (global.OldReadingRecording) { logger.logParameter(port, form.MeterReadingOld); } if (global.RegisterRecording) { logger.logParameter(port, form.ReplaceMeterRegister); } if (global.AutoRegisterRecording) { temp = (string.Equals(form.MeterNumber, form.MeterNumberOld)) ? "Register head change" : "Meter change"; logger.logParameter(port, new Parameter("MeterRegisterAutoStatus", temp, "Meter Register Auto Status")); } } string meterType = string.Format("({0}) {1}", meter.Id, meter.Display); logger.logParameter(port, new Parameter("MeterType", "Meter Type", meterType)); logger.logParameter(port, new Parameter("MeterTypeId", "Meter Type ID", meter.Id.ToString())); logger.logParameter(port, new Parameter("MeterVendor", "Meter Vendor", meter.Vendor)); logger.logParameter(port, new Parameter("MeterModel", "Meter Model", meter.Model)); if (global.UseMeterSerialNumber) { logger.logParameter(port, form.MeterNumber); } logger.logParameter(port, form.MeterReading); logger.logParameter(port, new Parameter("PulseHi", "Pulse Hi Time", meter.PulseHiTime.ToString().PadLeft(2, '0'))); logger.logParameter(port, new Parameter("PulseLo", "Pulse Low Time", meter.PulseLowTime.ToString().PadLeft(2, '0'))); this.addMtuAction.Add(port); #endregion #region Port 2 if (form.usePort2) { Meter meter2 = (!isFromScripting) ? ( Meter )form.Meter_2.Value : Configuration.GetInstance().getMeterTypeById(Convert.ToInt32(( string )form.Meter_2.Value)); port = new XElement("Port"); logger.addAtrribute(port, "display", "Port 2"); logger.addAtrribute(port, "number", "2"); logger.logParameter(port, form.AccountNumber_2); if (global.WorkOrderRecording) { logger.logParameter(port, form.WorkOrder_2); } if (isReplaceMeter) { if (global.UseMeterSerialNumber) { logger.logParameter(port, form.MeterNumberOld_2); } if (global.MeterWorkRecording) { logger.logParameter(port, form.OldMeterWorking_2); } if (global.OldReadingRecording) { logger.logParameter(port, form.MeterReadingOld_2); } if (global.RegisterRecording) { logger.logParameter(port, form.ReplaceMeterRegister_2); } if (global.AutoRegisterRecording) { temp = (string.Equals(form.MeterNumber_2, form.MeterNumberOld_2)) ? "Register head change" : "Meter change"; logger.logParameter(port, new Parameter("MeterRegisterAutoStatus", temp, "Meter Register Auto Status")); } } string meterType2 = string.Format("({0}) {1}", meter2.Id, meter2.Display); logger.logParameter(port, new Parameter("MeterType", "Meter Type", meterType2)); logger.logParameter(port, new Parameter("MeterTypeId", "Meter Type ID", meter2.Id.ToString())); logger.logParameter(port, new Parameter("MeterVendor", "Meter Vendor", meter2.Vendor)); logger.logParameter(port, new Parameter("MeterModel", "Meter Model", meter2.Model)); if (global.UseMeterSerialNumber) { logger.logParameter(port, form.MeterNumber_2); } logger.logParameter(port, form.MeterReading_2); logger.logParameter(port, new Parameter("PulseHi", "Pulse Hi Time", meter2.PulseHiTime.ToString().PadLeft(2, '0'))); logger.logParameter(port, new Parameter("PulseLo", "Pulse Low Time", meter2.PulseLowTime.ToString().PadLeft(2, '0'))); this.addMtuAction.Add(port); } #endregion #region Alarms if (mtu.RequiresAlarmProfile) { Alarm alarms = (Alarm)form.Alarm.Value; if (alarms != null) { XElement alarmSelection = new XElement("AlarmSelection"); logger.addAtrribute(alarmSelection, "display", "Alarm Selection"); string alarmConfiguration = alarms.Name; logger.logParameter(alarmSelection, new Parameter("AlarmConfiguration", "Alarm Configuration Name", alarmConfiguration)); string immediateAlarmTransmit = "False"; if (alarms.ImmediateAlarmTransmit) { immediateAlarmTransmit = "True"; } logger.logParameter(alarmSelection, new Parameter("ImmediateAlarm", "Immediate Alarm Transmit", immediateAlarmTransmit)); string urgentAlarm = "False"; if (alarms.DcuUrgentAlarm) { urgentAlarm = "True"; } logger.logParameter(alarmSelection, new Parameter("UrgentAlarm", "DCU Urgent Alarm Transmit", urgentAlarm)); string overlap = alarms.Overlap.ToString(); logger.logParameter(alarmSelection, new Parameter("Overlap", "Message Overlap", overlap)); if (mtu.MagneticTamper) { logger.logParameter(alarmSelection, new Parameter("MagneticTamper", "Magnetic Tamper", (alarms.Magnetic) ? ENABLE : DISABLE)); } if (mtu.RegisterCoverTamper) { logger.logParameter(alarmSelection, new Parameter("RegisterCoverTamper", "Register Cover Tamper", (alarms.RegisterCover) ? ENABLE : DISABLE)); } if (mtu.TiltTamper) { logger.logParameter(alarmSelection, new Parameter("TiltTamper", "Tilt Tamper", (alarms.Tilt) ? ENABLE : DISABLE)); } if (mtu.ReverseFlowTamper) { logger.logParameter(alarmSelection, new Parameter("ReverseFlow", "Reverse Flow Tamper", (alarms.ReverseFlow) ? ENABLE : DISABLE)); logger.logParameter(alarmSelection, new Parameter("FlowDirection", "Flow Direction", meter.Flow.ToString())); } if (mtu.InterfaceTamper) { logger.logParameter(alarmSelection, new Parameter("InterfaceTamper", "Interface Tamper", (alarms.InterfaceTamper) ? ENABLE : DISABLE)); } this.addMtuAction.Add(alarmSelection); } } #endregion // TODO (encoders) #region Demands if (mtu.MtuDemand) { XElement demandConf = new XElement("DemandConfiguration"); logger.addAtrribute(demandConf, "display", "Demand Configuration"); logger.logParameter(demandConf, new Parameter("ConfigurationName", "Configuration Name", "Default")); // TODO: replace real value logger.logParameter(demandConf, new Parameter("MtuNumLowPriorityMsg", "Mtu Num Low Priority Msg", "2")); // TODO: replace real value logger.logParameter(demandConf, new Parameter("MtuPrimaryWindowInterval", "Mtu Primary WindowInterval", "180")); // TODO: replace real value logger.logParameter(demandConf, new Parameter("MtuWindowAStart", "Mtu Window A Start", "0")); // TODO: replace real value logger.logParameter(demandConf, new Parameter("MtuWindowBStart", "Mtu Window B Start", "0")); // TODO: replace real value logger.logParameter(demandConf, new Parameter("MtuPrimaryWindowIntervalB", "Mtu Primary WindowInterval B", "3600")); // TODO: replace real value logger.logParameter(demandConf, new Parameter("MtuPrimaryWindowOffset", "Mtu Primary Window Offset", "51")); // TODO: replace real value this.addMtuAction.Add(demandConf); } #endregion #region Misc/Optional if (form.ContainsParameter(FIELD.GPS_LATITUDE) && form.ContainsParameter(FIELD.GPS_LONGITUDE) && form.ContainsParameter(FIELD.GPS_ALTITUDE)) { //logger.logParameter ( this.addMtuAction, form.GPS_LATITUDE ); //logger.logParameter ( this.addMtuAction, form.GPS_LONGITUDE ); //logger.logParameter ( this.addMtuAction, form.GPS_ALTITUDE ); logger.logParameter(this.addMtuAction, new Parameter("GPS_Y", "Lat", form.GPSLat.Value)); logger.logParameter(this.addMtuAction, new Parameter("GPS_X", "Long", form.GPSLon.Value)); logger.logParameter(this.addMtuAction, new Parameter("Altitude", "Elevation", form.GPSAlt.Value)); } if (!(form.OptionalParams.Value is string)) { List <Parameter> optionalParams = (List <Parameter>)form.OptionalParams.Value; if (optionalParams != null) { foreach (Parameter p in optionalParams) { logger.logParameter(this.addMtuAction, p); } } } #endregion }