Esempio n. 1
0
        public static void GenerateRandomData(int standId, StatusEnum modelName)
        {
            Random r = new Random();
            int completePercentage = 0;

            completePercentage = r.Next(1, 30);
            var standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() };
            SendToEventhub(standData);
            Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax));

            completePercentage = r.Next(31, 60);
            standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() };
            SendToEventhub(standData);
            Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax));

            completePercentage = r.Next(61, 99);
            standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() };
            SendToEventhub(standData);
            Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax));

            completePercentage = 100;
            standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() };
            SendToEventhub(standData);

            //Pause for reset progress to 0
            Thread.Sleep(_statusCompleteDelay);

            completePercentage = 0;
            standData = new StatusModel() { StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString() };
            SendToEventhub(standData);
        }
        public IHttpActionResult CreateUser(User user)
        {
            try
            {
                var sameusercount = db.Users.Where(w => w.Name.Replace(" ", "").Equals(user.Name.Trim().Replace(" ", ""))).Count();

                if (sameusercount == 0)
                {
                    user.Email = user.Name.Trim().Replace(" ", "").ToLower() + "@locusnine.com";
                }
                else
                {
                    int emailsuffux = sameusercount == 1 ? sameusercount : sameusercount + 1;
                    user.Email = user.Name.Trim().Replace(" ", "").ToLower() + (emailsuffux) + "@locusnine.com";
                }

                Random     random       = new Random();
                StatusEnum randomStatus = (StatusEnum)random.Next(0, 3);

                user.Status = randomStatus.ToString();

                db.Users.Add(user);
                db.SaveChanges();

                return(CreatedAtRoute("DefaultApi", new { id = user.ID }, user));
            }
            catch (Exception ex)
            {
                ExceptionWrite.Log(ex, "api/user/CreateUser");
                throw ex;
            }
        }
Esempio n. 3
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            StatusEnum status1 = (StatusEnum)values[0]; // статус заказа из БД
            StatusEnum status2 = (StatusEnum)values[1]; // статус заказа по блюдам, разрешенным на КДСе

            Brush retVal = null;
            Dictionary <string, BrushesPair> appBrushes = BrushHelper.AppBrushes;
            string key = null;

            if (((bool)WpfHelper.GetAppGlobalValue("IsShowOrderStatusByAllShownDishes")) &&
                (status2 != StatusEnum.None) && (status2 != StatusEnum.WaitingCook) && (status2 != status1))
            {
                key = status2.ToString();
            }
            else
            {
                key = status1.ToString();
            }

            if (!key.IsNull() && appBrushes.ContainsKey(key) && (parameter != null))
            {
                string[]    aParam = parameter.ToString().Split(';');
                BrushesPair brPair = appBrushes[key];

                retVal = (aParam[0] == "fore") ? brPair.Foreground : brPair.Background;
            }

            return((retVal == null) ? _defaultBrush : retVal);
        }
Esempio n. 4
0
 public void SetStatus(StatusEnum status, string statusText)
 {
     SendCommandToServer(new SetStatus()
     {
         status    = status.ToString(),
         statusmsg = statusText
     }.ToString());
 }
Esempio n. 5
0
        public void SetComments(StatusEnum statusEnum, Mode mode, Media media)
        {
            this.mode       = mode;
            this.statusEnum = statusEnum;
            this.media      = media;

            ItemsList.DataSource = media.Comments.Where(i => i.Status == statusEnum.ToString()).OrderByDescending(i => i.DateLastModified).ToList();
            ItemsList.DataBind();
        }
Esempio n. 6
0
 public List <BatchTrackingModel> GetByStatus(StatusEnum status)
 {
     return(_trackingContext.Trackings
            .Include(p => p.Ex)
            .Include(p => p.Messages)
            .Include(p => p.Pings)
            .Where(p => p.State == status.ToString())
            .Select(p => (BatchTrackingModel)p)
            .ToList <BatchTrackingModel>());
 }
Esempio n. 7
0
        public string ConvertToXMLResult(StatusEnum status, string payload = "")
        {
            XDocument document = new XDocument(XML_DECLARATION,
                                               new XElement(RESULT_TAG,
                                                            new XElement(STATUS_TAG, status.ToString()),
                                                            new XElement(STATUS_CODE_TAG, (int)status),
                                                            new XElement(PAYLOAD_TAG, payload)));

            return(document.ToString());
        }
Esempio n. 8
0
        private void UpdateStatistics(StatusEnum newStatus)
        {
            Statistics.Execution thisExecution;

            if (newStatus == Job.StatusEnum.Ready)
            {
                thisExecution = new Statistics.Execution();
                this.Stat.Executions.Add(thisExecution);
                thisExecution.StartTime = DateTime.Now.ToString("u");
            }
            else
            {
                thisExecution = this.Stat.Executions.LastOrDefault();
                if (thisExecution == null)
                {
                    return;
                }
            }

            if (newStatus == StatusEnum.RunningLocal ||
                newStatus == StatusEnum.RunningOnServer)
            {
                TimeStart               = DateTime.Now;
                TimeInQueue             = TimeStart - TimePosted;
                thisExecution.StartTime = DateTime.Now.ToString("u");
            }
            else if (newStatus == StatusEnum.Succeeded || this.IsFailed())
            {
                TimeDone = DateTime.Now;
                if (TimeDone > TimeStart)
                {
                    TimeTotal = TimeDone - TimeStart;
                }
            }

            // update the execution statistics (queued -> new execution)

            if (thisExecution != null)
            {
                thisExecution.StatusTraces.Add(new Statistics.Execution.StatusTrace()
                {
                    Status    = newStatus.ToString(),
                    TimeStamp = DateTime.Now.ToString("u")
                });
            }
        }
Esempio n. 9
0
        public void Assignments_ShouldBeSuccessful()
        {
            t.Should()
            .Be("In Process");

            t2.Should()
            .Be(StatusEnum.Stopped);

            t3.Should()
            .Be(StatusEnum.Error.Value);
            t4.Description.Should()
            .Be(StatusEnum.Error.ToString());
            t5.Description.Should()
            .Be("Indicates Running");
            t5.Name.Should()
            .NotBe(t5.Description);
            t4.Name.Should()
            .Be(t4.Description);
            t5.Name.Should()
            .Be(t5.ToString());
            t5.Name.Should()
            .Be("In Process");
            vals.Should()
            .HaveCount(StatusEnum.Count);
            t3.Should()
            .Be(t4);

            StatusEnum val = "Error1";

            val.Should()
            .BeNull();

            val = 12;
            val.Should()
            .BeNull();

            val = "In Process";
            val.Should()
            .Be(StatusEnum.Running);

            val = 5;
            val.Should()
            .Be(StatusEnum.Running);
        }
Esempio n. 10
0
        private void ChangeStatus(long commandArgument, StatusEnum newStatus)
        {
            var comment = CommentsMapper.GetByID(commandArgument);

            if (comment != null)
            {
                comment.Status = newStatus.ToString();

                var returnObj = CommentsMapper.Update(comment);

                if (returnObj.IsError)
                {
                    BasePage.DisplayErrorMessage("Error", returnObj.Error);
                }
                else
                {
                    BasePage.DisplaySuccessMessage("Successfully Updated Comment");
                    BasePage.ExecuteRawJS("UpdateCommentsTab();");
                }
            }
        }
Esempio n. 11
0
        private void ChangeStatus(long commandArgument, StatusEnum newStatus)
        {
            var comment = CommentsMapper.GetByID(commandArgument);

            if (comment != null)
            {
                comment.Status = newStatus.ToString();

                var returnObj = CommentsMapper.Update(comment);

                if (returnObj.IsError)
                {
                    BasePage.DisplayErrorMessage("Error", returnObj.Error);
                }
                else
                {
                    BasePage.DisplaySuccessMessage("Successfully Updated Comment");
                    BasePage.ExecuteRawJS("UpdateCommentsTab(); RefreshSiteTreeNodeById(" + AdminBasePage.SelectedMedia.ParentMediaID + "); ReloadPreviewPanel(); ");
                }
            }
        }
Esempio n. 12
0
        private BrushesPair getHeaderBrushes()
        {
            StatusEnum status1 = _order.Status, status2 = _order.StatusAllowedDishes;
            string     key = null;

            if (((bool)WpfHelper.GetAppGlobalValue("IsShowOrderStatusByAllShownDishes")) &&
                (status2 != StatusEnum.None) && (status2 != StatusEnum.WaitingCook) && (status2 != status1))
            {
                key = status2.ToString();
            }
            else
            {
                key = status1.ToString();
            }

            BrushesPair retVal = null;

            if (!key.IsNull() && BrushHelper.AppBrushes.ContainsKey(key))
            {
                retVal = BrushHelper.AppBrushes[key];
            }

            return(retVal);
        }
Esempio n. 13
0
        public OrderPanelHeader(OrderViewModel order, double width)
        {
            InitializeComponent();

            this.MouseUp         += root_MouseUp;
            grdHeader.DataContext = order;

            // стили и кисти
            BrushesPair brPair;
            StatusEnum  status1 = order.Status, status2 = order.StatusAllowedDishes;
            string      key = null;

            if (((bool)WpfHelper.GetAppGlobalValue("IsShowOrderStatusByAllShownDishes")) &&
                (status2 != StatusEnum.None) && (status2 != StatusEnum.WaitingCook) && (status2 != status1))
            {
                key = status2.ToString();
            }
            else
            {
                key = status1.ToString();
            }
            if (!key.IsNull() && BrushHelper.AppBrushes.ContainsKey(key))
            {
                brPair = BrushHelper.AppBrushes[key];
                brdHrdTableRow.Background = brPair.Background;
                brdHrdTableRow.SetValue(TextBlock.ForegroundProperty, brPair.Foreground);
                brdHdrWaiter.Background = brPair.Background;
                brdHdrWaiter.SetValue(TextBlock.ForegroundProperty, brPair.Foreground);
                brdHdrOrderTime.Background = brPair.Background;
                brdHdrOrderTime.SetValue(TextBlock.ForegroundProperty, brPair.Foreground);
            }
            // уголки рамок
            brdHrdTableRow.CornerRadius = new CornerRadius(0.03 * width, 0.03 * width, 0, 0);
            // отступы
            Thickness rowMargin = new Thickness(0.02 * width, 0, 0.02 * width, 0);

            tblTable.Margin        = rowMargin;
            tblOrderNumber.Margin  = rowMargin;
            tbWaiter.Margin        = rowMargin;
            grdHdrOrderTime.Margin = rowMargin;

            // таймер
            double timerCornerRadius = 0.025 * width;

            brdOrderTimer.CornerRadius = new CornerRadius(timerCornerRadius, timerCornerRadius, timerCornerRadius, timerCornerRadius);
            brPair = BrushHelper.AppBrushes["orderHeaderTimer"];
            if (brPair != null)
            {
                brdOrderTimer.Background = brPair.Background;
                brdOrderTimer.SetValue(TextBlock.ForegroundProperty, brPair.Foreground);
            }

            // шрифты
            double fontScale = (double)WpfHelper.GetAppGlobalValue("AppFontScale", 1.0d);

            double fSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrLabelFontSize");

            tbTableLabel1.FontSize              = fSize;
            tbTableLabel2.FontSize              = fSize;
            tbOrderDateLabel.FontSize           = fSize;
            tbOrderCookingCounterLabel.FontSize = fSize;

            tbTableName.FontSize           = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrTableNameFontSize");
            tbOrderNumber.FontSize         = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrOrderNumberFontSize");
            tbWaiter.FontSize              = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrWaiterNameFontSize");
            tbOrderDate.FontSize           = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrOrderCreateDateFontSize");
            tbOrderCookingCounter.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrOrderTimerFontSize");

            if (!order.DivisionColorRGB.IsNull())
            {
                brdDivisionMark.Fill = WpfHelper.GetBrushFromRGBString(order.DivisionColorRGB);
            }
        }
Esempio n. 14
0
 public BaseApiResponse(StatusEnum status, string message)
 {
     this.Status  = status.ToString();
     this.Message = message;
 }
Esempio n. 15
0
        public static void GenerateRandomData(int standId, StatusEnum modelName)
        {
            Random r = new Random();
            int    completePercentage = 0;

            completePercentage = r.Next(1, 30);
            var standData = new StatusModel()
            {
                StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString()
            };

            SendToEventhub(standData);
            Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax));

            completePercentage = r.Next(31, 60);
            standData          = new StatusModel()
            {
                StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString()
            };
            SendToEventhub(standData);
            Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax));

            completePercentage = r.Next(61, 99);
            standData          = new StatusModel()
            {
                StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString()
            };
            SendToEventhub(standData);
            Thread.Sleep(r.Next(_statusDelayMin, _statusDelayMax));

            completePercentage = 100;
            standData          = new StatusModel()
            {
                StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString()
            };
            SendToEventhub(standData);

            //Pause for reset progress to 0
            Thread.Sleep(_statusCompleteDelay);

            completePercentage = 0;
            standData          = new StatusModel()
            {
                StandID = standId, Status = completePercentage, TimeStamp = DateTime.Now, Description = modelName.ToString()
            };
            SendToEventhub(standData);
        }
Esempio n. 16
0
 public int GetByStatusCount(StatusEnum status)
 {
     return(_trackingContext.Trackings.Where(p => p.State == status.ToString()).Count());
 }
Esempio n. 17
0
 /// <summary>
 /// 批量更改协议状态
 /// </summary>
 /// <param name="guidList">主键列表</param>
 /// <param name="status">状态</param>
 public void UpdateAgreeStatus(List<string> guidList, StatusEnum.AgreeStatusEnum status)
 {
     StringBuilder strSql = new StringBuilder("update T_Agreements set status='" + status.ToString("D") + "' where ID in(");
     for (int i = 0; i < guidList.Count; i++)
     {
         strSql.AppendFormat(i == guidList.Count - 1 ? "'{0}'" : "'{0}',", guidList[i]);
     }
     strSql.Append(")");
     using (DBHelper db = DBHelper.Create())
     {
         db.ExecuteNonQuery(strSql.ToString());
     }
 }
Esempio n. 18
0
        // Update content, play animation, play sound, display for a while, then automatically hide
        // Callback only used when there are two buttons
        // Might also consider adding a log, especially for errors
        public void Update(StatusEnum status, string text, ActionsEnum action, PlacementEnum placement, ActionCallBack callback = null)
        {
            // Save parameters
            Status   = status;
            Text     = text;
            Action   = action;
            CallBack = callback;

            // Reconfigure timer
            dispatcherTimer.Interval = new TimeSpan(0, 0, 7);

            // Update Content
            StatusLabel.Content = Status.ToString(); // Update status label
            switch (Status)                          // Update status icon
            {
            case StatusEnum.Event:
                // StatusIcon.Source = ...
                break;

            case StatusEnum.TimerEvent:
                // StatusIcon.Source = ...
                break;

            case StatusEnum.Notice:
                // StatusIcon.Source = ...
                dispatcherTimer.Interval = new TimeSpan(0, 0, 2);
                break;

            case StatusEnum.Welcome:
                // StatusIcon.Source = ...
                break;

            case StatusEnum.Error:
                // StatusIcon.Source = ...
                break;

            default:
                break;
            }
            StatusTextBlock.Text = Text; // Update status text
            switch (Action)              // Update buttons
            {
            case ActionsEnum.AcceptCancel:
                LeftButton.Content      = "Accept";
                LeftButton.Visibility   = Visibility.Visible;
                RightButton.Content     = "Cancel";
                RightButton.Visibility  = Visibility.Visible;
                CenterButton.Visibility = Visibility.Hidden;
                break;

            case ActionsEnum.YesNo:
                LeftButton.Content      = "Yes";
                LeftButton.Visibility   = Visibility.Visible;
                RightButton.Content     = "No";
                RightButton.Visibility  = Visibility.Visible;
                CenterButton.Visibility = Visibility.Hidden;
                break;

            case ActionsEnum.Acknowledge:
                LeftButton.Visibility   = Visibility.Hidden;
                RightButton.Visibility  = Visibility.Hidden;
                CenterButton.Content    = "Ackownledge";
                CenterButton.Visibility = Visibility.Visible;
                break;

            case ActionsEnum.None:
                LeftButton.Visibility   = Visibility.Hidden;
                RightButton.Visibility  = Visibility.Hidden;
                CenterButton.Visibility = Visibility.Hidden;
                break;

            default:
                break;
            }

            // Play blink animation
            // ...

            // Play notif souond
            // ...

            // Restart timer
            dispatcherTimer.Stop();
            dispatcherTimer.Start();

            // Set window location
            var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;

            switch (placement)
            {
            case PlacementEnum.UpperRight:
                this.Left = desktopWorkingArea.Right - this.Width - 50;
                this.Top  = 50;
                break;

            case PlacementEnum.LowerRight:
                this.Left = desktopWorkingArea.Right - this.Width - 50;
                this.Top  = desktopWorkingArea.Bottom - this.ActualHeight - 80;
                break;

            default:
                break;
            }

            // Display Contents
            this.Visibility = Visibility.Visible;
        }
Esempio n. 19
0
 public StatusListItemViewModel(StatusEnum statusEnum)
 {
     Value       = statusEnum;
     DisplayText = statusEnum.ToString();
 }
Esempio n. 20
0
 public static IEnumerable <Comment> GetByStatus(StatusEnum statusEnum)
 {
     return(GetDataModel().Comments.Where(item => item.Status == statusEnum.ToString()));
 }
 public void DisplayText_Always_ReturnsExpectedValue(StatusEnum input)
 {
     status = input;
     RecreateSystemUnderTest();
     Assert.That(SystemUnderTest.DisplayText, Is.EqualTo(input.ToString()));
 }
Esempio n. 22
0
        async void dispatcherTimer_Tick(object sender, object e)
        {
            heartBeatTimer.Stop();

            // Commmon actions from scale and testo
            bool   device_watcher_needs_stopping = false;
            string message_scale = "";
            string message_testo = "";

            //  ===========   ACAIA  ==================

            if (statusScale == StatusEnum.Disabled)
            {
                // do nothing
            }
            else if (statusScale == StatusEnum.Disconnected)
            {
                foreach (var d in KnownDevices)
                {
                    if (d.Name.StartsWith("PROCH") || d.Name.StartsWith("ACAIA"))
                    {
                        deviceIdAcaia = d.Id;

                        ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
                        localSettings.Values["DeviceIdAcaia"] = deviceIdAcaia;

                        statusScale = StatusEnum.Discovered;

                        device_watcher_needs_stopping = true;

                        message_scale = "Discovered " + deviceIdAcaia + " ";

                        break;
                    }
                }
            }
            else if (statusScale == StatusEnum.Discovered)
            {
                try
                {
                    if (bluetoothDeviceScale == null)
                    {
                        try
                        {
                            bluetoothDeviceScale = await BluetoothLEDevice.FromIdAsync(deviceIdAcaia);
                        }
                        catch (Exception) { }
                    }

                    if (bluetoothDeviceScale == null)
                    {
                        FatalError("Failed to create Acaia BluetoothLEDevice");
                        return;
                    }

                    GattDeviceServicesResult result_service = await bluetoothDeviceScale.GetGattServicesForUuidAsync(
                        new Guid(ScaleServiceGuid), bluetoothCacheMode);

                    if (result_service.Status != GattCommunicationStatus.Success)
                    {
                        FatalError("Failed to get Scale service 0x1820 " + result_service.Status.ToString());
                        return;
                    }

                    if (result_service.Services.Count != 1)
                    {
                        FatalError("Error, expected to find one Scale service 0x1820");
                        return;
                    }

                    var service = result_service.Services[0];

                    // Ensure we have access to the device.
                    var accessStatus = await service.RequestAccessAsync();

                    if (accessStatus != DeviceAccessStatus.Allowed)
                    {
                        FatalError("Do not have access to the Scale service 0x1820");
                        return;
                    }

                    // BT_Code: Get all the child characteristics of a service. Use the cache mode to specify uncached characterstics only
                    // and the new Async functions to get the characteristics of unpaired devices as well.

                    GattCharacteristicsResult result_charact = await service.GetCharacteristicsForUuidAsync(new Guid(ScaleCharactGuid), bluetoothCacheMode);

                    if (result_charact.Status != GattCommunicationStatus.Success)
                    {
                        FatalError("Failed to get Scale service characteristics 0x2A80 " + result_charact.Status.ToString());
                        return;
                    }

                    if (result_charact.Characteristics.Count != 1)
                    {
                        FatalError("Error, expected to find one Scale service characteristics 0x2A80");
                        return;
                    }

                    characteristicScale = result_charact.Characteristics[0];

                    characteristicScale.ValueChanged += CharacteristicScale_ValueChanged;

                    // enable notifications
                    var result = await characteristicScale.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);

                    subscribedForNotificationsScale = true;

                    WriteAppIdentity(); // in order to start receiving weights

                    statusScale = StatusEnum.CharacteristicConnected;

                    message_scale = "Connected to Acaia ";

                    PanelConnectDisconnect.Background = new SolidColorBrush(Windows.UI.Colors.Green);

                    BtnBeansWeight.IsEnabled = true;
                    BtnTare.IsEnabled        = true;
                    BtnStartLog.IsEnabled    = true;
                    BtnStopLog.IsEnabled     = false;
                }
                catch (Exception ex)
                {
                    FatalError("Exception when accessing service or its characteristics: " + ex.Message);
                    return;
                }
            }
            else if (statusScale == StatusEnum.CharacteristicConnected)
            {
                WriteHeartBeat();
            }
            else
            {
                FatalError("Unknown Status for Acaia scale" + statusScale.ToString());
                return;
            }



            //  ===========   TESTO  ==================

            if (statusTesto == StatusEnum.Disabled)
            {
                // do nothing
            }
            else if (statusTesto == StatusEnum.Disconnected)
            {
                foreach (var d in KnownDevices)
                {
                    if (d.Name.StartsWith("T549i"))
                    {
                        deviceIdTesto = d.Id;

                        ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
                        localSettings.Values["DeviceIdTesto"] = deviceIdTesto;

                        statusTesto = StatusEnum.Discovered;

                        device_watcher_needs_stopping = true;

                        message_testo = "Discovered " + deviceIdTesto + " ";
                    }
                }
            }
            else if (statusTesto == StatusEnum.Discovered)
            {
                try
                {
                    if (bluetoothDeviceTesto == null)
                    {
                        try
                        {
                            bluetoothDeviceTesto = await BluetoothLEDevice.FromIdAsync(deviceIdTesto);
                        }
                        catch (Exception) { }
                    }

                    if (bluetoothDeviceTesto == null)
                    {
                        FatalError("Failed to create Testo BluetoothLEDevice");
                        return;
                    }

                    GattDeviceServicesResult result_service = await bluetoothDeviceTesto.GetGattServicesForUuidAsync(
                        new Guid(TestoServiceGuid), bluetoothCacheMode);

                    if (result_service.Status != GattCommunicationStatus.Success)
                    {
                        FatalError("Failed to get Testo service 0xfff0 " + result_service.Status.ToString());
                        return;
                    }

                    if (result_service.Services.Count != 1)
                    {
                        FatalError("Error, expected to find one Testo service 0xfff0");
                        return;
                    }

                    var service = result_service.Services[0];

                    // Ensure we have access to the device.
                    var accessStatus = await service.RequestAccessAsync();

                    if (accessStatus != DeviceAccessStatus.Allowed)
                    {
                        FatalError("Do not have access to the Testo service 0xfff0");
                        return;
                    }

                    // BT_Code: Get all the child characteristics of a service. Use the cache mode to specify uncached characterstics only
                    // and the new Async functions to get the characteristics of unpaired devices as well.

                    //  ====  NOTIF characteristics  =====

                    GattCharacteristicsResult result_charact = await service.GetCharacteristicsForUuidAsync(new Guid(TestoCharactNotifGuid), bluetoothCacheMode);

                    if (result_charact.Status != GattCommunicationStatus.Success)
                    {
                        FatalError("Failed to get Testo service characteristics 0xfff2 " + result_charact.Status.ToString());
                        return;
                    }

                    if (result_charact.Characteristics.Count != 1)
                    {
                        FatalError("Error, expected to find one Testo service characteristics 0xfff2");
                        return;
                    }

                    characteristicTestoNotif = result_charact.Characteristics[0];

                    characteristicTestoNotif.ValueChanged += CharacteristicTesto_ValueChanged;

                    // enable notifications
                    var result = await characteristicTestoNotif.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);

                    subscribedForNotificationsTesto = true;


                    //  ====  WRITE characteristics  =====

                    result_charact = await service.GetCharacteristicsForUuidAsync(new Guid(TestoCharactWriteGuid), bluetoothCacheMode);

                    if (result_charact.Status != GattCommunicationStatus.Success)
                    {
                        FatalError("Failed to get Testo service characteristics fff1 " + result_charact.Status.ToString());
                        return;
                    }

                    if (result_charact.Characteristics.Count != 1)
                    {
                        FatalError("Error, expected to find one Testo service characteristics fff1");
                        return;
                    }

                    characteristicTestoWrite = result_charact.Characteristics[0];



                    WriteCommandsToEnablePressureMeasurements(); // in order to start receiving pressure

                    statusTesto = StatusEnum.CharacteristicConnected;

                    message_testo = "Connected to T549i ";

                    PanelConnectDisconnect.Background = new SolidColorBrush(Windows.UI.Colors.Green);

                    BtnBeansWeight.IsEnabled = true;
                    BtnTare.IsEnabled        = true;
                    BtnStartLog.IsEnabled    = true;
                    BtnStopLog.IsEnabled     = false;

                    if (ChkTesto.IsOn)
                    {
                        BtnZeroPressure.IsEnabled = true;
                    }
                }
                catch (Exception ex)
                {
                    FatalError("Exception when accessing service or its characteristics: " + ex.Message);
                    return;
                }
            }
            else if (statusTesto == StatusEnum.CharacteristicConnected)
            {
                // do nothing
            }
            else
            {
                FatalError("Unknown Status for Testo" + statusTesto.ToString());
                return;
            }

            // Do not need device watcher anymore
            if (statusScale != StatusEnum.Disconnected && statusTesto != StatusEnum.Disconnected && device_watcher_needs_stopping)
            {
                StopBleDeviceWatcher();
            }

            // Notify
            if (message_scale != "" || message_testo != "")
            {
                NotifyUser(message_scale + message_testo, NotifyType.StatusMessage);
            }


            heartBeatTimer.Start();
        }
Esempio n. 23
0
 public void UpdateStatus(StatusEnum status)
 {
     if (this.Status != status)
     {
         this.AddNote("Status changed from " + this.Status.ToString() + " to " + status.ToString(), "System");
         this.Status = status;
         if (status == StatusEnum.Success)
             DateTimeComplete = DateTime.Now;
         else if (status == StatusEnum.Pending)
             DateTimeComplete = DateTime.MinValue;
         this.Update();
         this.UpdateAffectedInvoices();
     }
 }
Esempio n. 24
0
        private void UpdateStatistics(StatusEnum newStatus)
        {
            Statistics.Execution thisExecution;

            if (newStatus == Job.StatusEnum.Ready)
            {
                thisExecution = new Statistics.Execution();
                this.Stat.Executions.Add(thisExecution);
                thisExecution.StartTime = DateTime.Now.ToString("u");
            }
            else
            {
                thisExecution = this.Stat.Executions.LastOrDefault();
                if (thisExecution == null)
                {
                    return;
                }
            }

            if (newStatus == StatusEnum.RunningLocal ||
                newStatus == StatusEnum.RunningOnServer)
            {
                TimeStart = DateTime.Now;
                TimeInQueue = TimeStart - TimePosted;
                thisExecution.StartTime = DateTime.Now.ToString("u");
            }
            else if (newStatus == StatusEnum.Succeeded || this.IsFailed())
            {
                TimeDone = DateTime.Now;
                if (TimeDone > TimeStart)
                    TimeTotal = TimeDone - TimeStart;
            }

            // update the execution statistics (queued -> new execution)

            if (thisExecution != null)
            {
                thisExecution.StatusTraces.Add(new Statistics.Execution.StatusTrace()
                {
                    Status = newStatus.ToString(),
                    TimeStamp = DateTime.Now.ToString("u")
                });
            }

        }
Esempio n. 25
0
 public static string StatusEnumToString(StatusEnum v)
 {
     return(v.ToString());
 }