  | 48 | 48 | | private MenuItem menuUpload; |
| | 49 | 49 | | |
| | 50 | 50 | | |
  | 51 | | - | private string _uploadServer = ""; |
| | | 51 | + | |
| 52 | 52 | | |
| | 53 | 53 | | |
| | 54 | 54 | | |
| |
|
|
 |
… |
| 61 | 61 | | private Delegate _delegateUploadUpdate; |
| | 62 | 62 | | |
| | 63 | 63 | | |
  | 64 | | - | private SensorDataManager _sensorDataManager; |
| | | 64 | + | |
| | | 65 | + | private List<SensorDataManager> manualSensorDataManagers = new List<SensorDataManager>(1); |
| | | 66 | + | private List<SensorDataManager> automaticSensorDataManagers = new List<SensorDataManager>(1); |
| 65 | 67 | | |
| | 66 | 68 | | private FeedbackManager _feedbackManager; |
| | 67 | 69 | | |
| |
|
|
 |
… |
| 77 | 79 | | |
| | 78 | 80 | | private object _lock = new object(); |
| | 79 | 81 | | |
  | 80 | | - | private bool _manualCapture = false; |
| | | 82 | + | |
| | | 83 | + | |
| 81 | 84 | | |
  | 82 | | - | private UploadManager _uploadManager; |
| | | 85 | + | |
| 83 | 86 | | |
| | 84 | 87 | | private string _campaignname = ""; |
  | 85 | | - | private Boolean _uploadOnStart = false; |
| | | 88 | + | private Boolean _uploadOnStart = true; |
| 86 | 89 | | private Boolean _startOnLoad = false; |
| | 87 | 90 | | private Boolean _debugModeOn = false; |
| | 88 | 91 | | private Boolean _killUploadMonitor = false; |
| |
|
|
 |
… |
| 100 | 103 | | |
| | 101 | 104 | | #region Public Delegates |
| | 102 | 105 | | |
  | 103 | | - | |
| | | 106 | + | |
| 104 | 107 | | public delegate void DelegateMenus(object sender, EventArgs args); |
  | 105 | | - | |
| | | 108 | + | |
| 106 | 109 | | public delegate void DelegateStatusUpdate(Label ctrl, Object val); |
  | 107 | | - | |
| | | 110 | + | |
| 108 | 111 | | public delegate void DelegateFeedbackUpdate(Label ctrl, Object val); |
  | 109 | | - | |
| | | 112 | + | |
| 110 | 113 | | public delegate void DelegateUploadUpdate(Label ctrl, Object val); |
| | 111 | 114 | | |
| | 112 | 115 | | #endregion |
| |
|
|
 |
… |
| 148 | 151 | | _delegateFeedbackUpdate = new DelegateFeedbackUpdate(FeedbackUpdate); |
| | 149 | 152 | | _delegateUploadUpdate = new DelegateUploadUpdate(UploadUpdate); |
| | 150 | 153 | | |
  | 151 | | - | _sensorDataManager = new SensorDataManager(); |
| | | 154 | + | |
| 152 | 155 | | _feedbackManager = new FeedbackManager(); |
| | 153 | 156 | | |
| | 154 | 157 | | |
| |
|
|
 |
… |
| 432 | 435 | | |
| | 433 | 436 | | private void exitMenuItem_Click(object sender, EventArgs e) |
| | 434 | 437 | | { |
  | 435 | | - | if (_sensorDataManager != null) |
| | | 438 | + | if (manualSensorDataManagers.Count > 0 || automaticSensorDataManagers.Count > 0) |
| 436 | 439 | | { |
| | 437 | 440 | | DatabaseManager.MessageQueue.PostItem(new Message("Closing Campaignr", MessageType.Status)); |
  | 438 | | - | _sensorDataManager.Log = false; |
| | | 441 | + | |
| | | 442 | + | foreach(SensorDataManager manager in manualSensorDataManagers) |
| | | 443 | + | manager.Log = false; |
| | | 444 | + | foreach (SensorDataManager manager in automaticSensorDataManagers) |
| | | 445 | + | manager.Log = false; |
| 439 | 446 | | } |
| | 440 | 447 | | |
| | 441 | 448 | | try |
| |
|
|
 |
… |
| 482 | 489 | | _killUploadMonitor = true; |
| | 483 | 490 | | _uploadMonitorTimer.Dispose(); |
| | 484 | 491 | | } |
  | 485 | | - | _sensorDataManager.CloseSensors(); |
| | | 492 | + | |
| | | 493 | + | foreach (SensorDataManager manager in manualSensorDataManagers) |
| | | 494 | + | { |
| | | 495 | + | manager.CloseSensors(); |
| | | 496 | + | } |
| | | 497 | + | foreach (SensorDataManager manager in automaticSensorDataManagers) |
| | | 498 | + | { |
| | | 499 | + | manager.CloseSensors(); |
| | | 500 | + | } |
| 486 | 501 | | } |
| | 487 | 502 | | |
| | 488 | 503 | | private OperationModes _operationMode; |
| |
|
|
 |
… |
| 496 | 511 | | _operationMode = value; |
| | 497 | 512 | | |
| | 498 | 513 | | |
  | 499 | | - | closeSensors(); |
| | | 514 | + | |
| 500 | 515 | | |
| | 501 | 516 | | bool activityOn = false; |
| | 502 | 517 | | |
| |
|
|
 |
… |
| 508 | 523 | | |
| | 509 | 524 | | activityOn = menuUpload.Checked = !menuUpload.Checked; |
| | 510 | 525 | | |
  | 511 | | - | if(activityOn) |
| | 512 | | - | _sensorDataManager.UploadOnly(); |
| | | 526 | + | if (activityOn) |
| | | 527 | + | { |
| | | 528 | + | foreach (SensorDataManager manager in manualSensorDataManagers) |
| | | 529 | + | { |
| | | 530 | + | manager.UploadOnly(); |
| | | 531 | + | } |
| | | 532 | + | foreach (SensorDataManager manager in automaticSensorDataManagers) |
| | | 533 | + | { |
| | | 534 | + | manager.UploadOnly(); |
| | | 535 | + | } |
| | | 536 | + | } |
| 513 | 537 | | |
| | 514 | 538 | | break; |
| | 515 | 539 | | case OperationModes.Collect: |
| |
|
|
 |
… |
| 518 | 542 | | |
| | 519 | 543 | | activityOn = menuCollect.Checked = !menuCollect.Checked; |
| | 520 | 544 | | |
  | 521 | | - | if(activityOn) |
| | 522 | | - | _sensorDataManager.Collect(false); |
| | | 545 | + | if (activityOn) |
| | | 546 | + | { |
| | | 547 | + | |
| | | 548 | + | |
| | | 549 | + | |
| | | 550 | + | |
| | | 551 | + | foreach (SensorDataManager manager in automaticSensorDataManagers) |
| | | 552 | + | { |
| | | 553 | + | manager.Collect(false); |
| | | 554 | + | } |
| | | 555 | + | } |
| 523 | 556 | | |
| | 524 | 557 | | break; |
| | 525 | 558 | | case OperationModes.CollectUpload: |
| |
|
|
 |
… |
| 528 | 561 | | |
| | 529 | 562 | | activityOn = menuCollectUpload.Checked = !menuCollectUpload.Checked; |
| | 530 | 563 | | |
  | 531 | | - | if (activityOn && _manualCapture == false) |
| | 532 | | - | _sensorDataManager.Collect(true); |
| | | 564 | + | if (activityOn && automaticSensorDataManagers.Count > 0) |
| | | 565 | + | { |
| | | 566 | + | foreach (SensorDataManager manager in automaticSensorDataManagers) |
| | | 567 | + | { |
| | | 568 | + | manager.Collect(true); |
| | | 569 | + | } |
| | | 570 | + | } |
| 533 | 571 | | |
| | 534 | 572 | | break; |
| | 535 | 573 | | } |
| |
|
|
 |
… |
| 558 | 596 | | } |
| | 559 | 597 | | |
| | 560 | 598 | | |
  | 561 | | - | private void readXMLConfig(string xmlcfgfilename) |
| | | 599 | + | private void ParseXMLConfiguration(string filename, string path) |
| 562 | 600 | | { |
| | 563 | 601 | | try |
| | 564 | 602 | | { |
  | 565 | | - | XmlTextReader rdr = new XmlTextReader(xmlcfgfilename); |
| | | 603 | + | XmlTextReader rdr = new XmlTextReader(path + filename); |
| 566 | 604 | | SimpleDOMParser sdp = new SimpleDOMParser(); |
| | 567 | 605 | | SimpleElement se = sdp.parse(rdr); |
| | 568 | 606 | | |
| | 569 | 607 | | bool flushDatabase = false; |
| | 570 | 608 | | |
  | 571 | | - | if(_sensorDataManager!=null) |
| | 572 | | - | _sensorDataManager.ClearSensors(); |
| | | 609 | + | foreach (SensorDataManager manager in manualSensorDataManagers) |
| | | 610 | + | { |
| | | 611 | + | manager.CloseSensors(); |
| | | 612 | + | } |
| | | 613 | + | foreach (SensorDataManager manager in automaticSensorDataManagers) |
| | | 614 | + | { |
| | | 615 | + | manager.CloseSensors(); |
| | | 616 | + | } |
| 573 | 617 | | |
  | | 618 | + | manualSensorDataManagers.Clear(); |
| | | 619 | + | automaticSensorDataManagers.Clear(); |
| | | 620 | + | |
| 574 | 621 | | if (se.TagName.ToLower().Equals("campaign")) |
| | 575 | 622 | | { |
| | 576 | 623 | | _campaignname = se.Attributes["name"]; |
| |
|
|
 |
… |
| 582 | 629 | | this.Text = "Campaignr - "+ _campaignname; |
| | 583 | 630 | | |
| | 584 | 631 | | |
  | 585 | | - | _uploadOnStart = System.Convert.ToBoolean(se.Attributes["uploadOnStart"]); |
| | | 632 | + | if(se.Attributes["uploadOnStart"] != null && System.Convert.ToBoolean(se.Attributes["uploadOnStart"]) == false) |
| | | 633 | + | _uploadOnStart = false; |
| 586 | 634 | | |
| | 587 | 635 | | _debugModeOn = System.Convert.ToBoolean(se.Attributes["debug"]); |
| | 588 | 636 | | |
  | 589 | | - | if (!_debugModeOn) |
| | 590 | | - | _sensorDataManager.Log = false; |
| | 591 | | - | else |
| | 592 | | - | _sensorDataManager.Log = true; |
| | 593 | | - | |
| 594 | 637 | | SimpleElements elements = se.ChildElements; |
| | 595 | 638 | | |
  | 596 | | - | SimpleElement automatic = elements.Item("automatic"); |
| | 597 | | - | |
| | 598 | | - | if (automatic==null) |
| | | 639 | + | if (elements.Count == 0) |
| 599 | 640 | | { |
  | 600 | | - | automatic = elements.Item("manual"); |
| | 601 | | - | _manualCapture = true; |
| | 602 | | - | } |
| | 603 | | - | |
| | 604 | | - | if (automatic==null) |
| | 605 | | - | { |
| 606 | 641 | | DatabaseManager.MessageQueue.PostItem(new Message("Configuration file missing automatic or manual section", MessageType.Error)); |
| | 607 | 642 | | return; |
| | 608 | 643 | | } |
| | 609 | 644 | | |
  | 610 | | - | |
| | 611 | | - | _startOnLoad = System.Convert.ToBoolean(se.Attributes["startOnLoad"]) && !_manualCapture; |
| | | 645 | + | for (int i = 0; i < elements.Count; i++) |
| | | 646 | + | { |
| | | 647 | + | SimpleElement collection = elements.Item(i); |
| 612 | 648 | | |
  | 613 | | - | progressBar1.Value += 10; |
| | 614 | | - | int step = (int)Math.Floor(20 / automatic.ChildElements.Count); |
| | | 649 | + | SensorDataManager manager = new SensorDataManager(flushDatabase); |
| | | 650 | + | manager.CollectInterval = uploadInterval; |
| | | 651 | + | manager.Log = _debugModeOn; |
| | | 652 | + | manager.CampaignId = filename; |
| 615 | 653 | | |
  | 616 | | - | foreach (SimpleElement child in automatic.ChildElements) |
| | 617 | | - | { |
| | 618 | | - | progressBar1.Value += step; |
| | | 654 | + | if (collection.TagName == "automatic") |
| | | 655 | + | { |
| | | 656 | + | |
| | | 657 | + | _startOnLoad = System.Convert.ToBoolean(se.Attributes["startOnLoad"]); |
| 619 | 658 | | |
  | 620 | | - | string name = child.TagName; |
| | 621 | | - | if (name.ToLower().Equals("sensor")) |
| | | 659 | + | manager.Automatic = true; |
| | | 660 | + | |
| | | 661 | + | automaticSensorDataManagers.Add(manager); |
| | | 662 | + | } |
| | | 663 | + | else if (collection.TagName == "manual") |
| 622 | 664 | | { |
  | 623 | | - | string type = child.Attributes["type"]; |
| | | 665 | + | manualSensorDataManagers.Add(manager); |
| | | 666 | + | } |
| | | 667 | + | else |
| | | 668 | + | { |
| | | 669 | + | manager = null; |
| | | 670 | + | continue; |
| | | 671 | + | } |
| | | 672 | + | |
| | | 673 | + | progressBar1.Value += 10; |
| | | 674 | + | int step = (int)Math.Floor(((20 / elements.Count) / collection.ChildElements.Count)); |
| 624 | 675 | | |
  | 625 | | - | if (type != null) |
| | | 676 | + | foreach (SimpleElement child in collection.ChildElements) |
| | | 677 | + | { |
| | | 678 | + | progressBar1.Value += Math.Min(progressBar1.Maximum - progressBar1.Value, step); |
| | | 679 | + | |
| | | 680 | + | string name = child.TagName; |
| | | 681 | + | if (name.ToLower().Equals("sensor")) |
| 626 | 682 | | { |
  | 627 | | - | try |
| | 628 | | - | { |
| | 629 | | - | |
| | 630 | | - | string sensorName = child.Attributes["name"]; |
| | 631 | | - | if (sensorName == null) |
| | 632 | | - | |
| | 633 | | - | sensorName = type.Trim(); |
| | 634 | | - | else |
| | 635 | | - | sensorName = sensorName.Trim(); |
| | | 683 | + | string type = child.Attributes["type"]; |
| 636 | 684 | | |
  | 637 | | - | if (type.ToLower().Equals("imei")) |
| | | 685 | + | if (type != null) |
| | | 686 | + | { |
| | | 687 | + | try |
| 638 | 688 | | { |
  | 639 | | - | string hashed = child.Attributes["hash"]; |
| | 640 | | - | |
| | 641 | | - | if(hashed!=null && hashed=="true") |
| | 642 | | - | _sensorDataManager.assignSensors(new DeviceId("campaignrwm"), sensorName); |
| | | 689 | + | |
| | | 690 | + | string sensorName = child.Attributes["name"]; |
| | | 691 | + | if (sensorName == null) |
| | | 692 | + | |
| | | 693 | + | sensorName = type.Trim(); |
| 643 | 694 | | else |
  | 644 | | - | _sensorDataManager.assignSensors(new Imei(), sensorName); |
| | 645 | | - | } |
| | 646 | | - | else if (type.ToLower().Equals("cellid")) |
| | 647 | | - | _sensorDataManager.assignSensors(new CellTower(), sensorName); |
| | 648 | | - | else if (type.ToLower().Equals("timestamp")) |
| | 649 | | - | _sensorDataManager.assignSensors(new Timestamp(), sensorName); |
| | 650 | | - | else if (type.ToLower().Equals("bt_stumble")) |
| | 651 | | - | { |
| | 652 | | - | if (child.ChildElements.Count == 0) |
| | 653 | | - | _sensorDataManager.assignSensors(new BTStumbler(true), sensorName); |
| | 654 | | - | else |
| | | 695 | + | sensorName = sensorName.Trim(); |
| | | 696 | + | |
| | | 697 | + | if (type.ToLower().Equals("imei")) |
| 655 | 698 | | { |
  | 656 | | - | foreach (SimpleElement btchild in child.ChildElements) |
| | | 699 | + | string hashed = child.Attributes["hash"]; |
| | | 700 | + | |
| | | 701 | + | if (hashed != null && hashed == "true") |
| | | 702 | + | manager.AssignSensor(new DeviceId("campaignrwm"), sensorName); |
| | | 703 | + | else |
| | | 704 | + | manager.AssignSensor(new Imei(), sensorName); |
| | | 705 | + | } |
| | | 706 | + | else if (type.ToLower().Equals("cellid")) |
| | | 707 | + | manager.AssignSensor(new CellTower(), sensorName); |
| | | 708 | + | else if (type.ToLower().Equals("timestamp")) |
| | | 709 | + | manager.AssignSensor(new Timestamp(), sensorName); |
| | | 710 | + | else if (type.ToLower().Equals("bt_stumble")) |
| | | 711 | + | { |
| | | 712 | + | if (child.ChildElements.Count == 0) |
| | | 713 | + | manager.AssignSensor(new BTStumbler(true), sensorName); |
| | | 714 | + | else |
| 657 | 715 | | { |
  | 658 | | - | if (btchild.TagName == "address_only") |
| | 659 | | - | _sensorDataManager.assignSensors(new BTStumbler(false), sensorName); |
| | | 716 | + | foreach (SimpleElement btchild in child.ChildElements) |
| | | 717 | + | { |
| | | 718 | + | if (btchild.TagName == "address_only") |
| | | 719 | + | manager.AssignSensor(new BTStumbler(false), sensorName); |
| | | 720 | + | } |
| 660 | 721 | | } |
  | 661 | | - | } |
| 662 | 722 | | |
  | 663 | | - | } |
| | 664 | | - | else if (type.ToLower().Equals("location")) |
| | 665 | | - | { |
| | 666 | | - | Gps gps = new Gps(); |
| | 667 | | - | |
| | 668 | | - | |
| | 669 | | - | |
| | 670 | | - | gps.Open(); |
| | 671 | | - | gps.LocationChanged += new LocationChangedEventHandler(LocationChanged); |
| | 672 | | - | |
| | 673 | | - | _sensorDataManager.assignSensors(gps, sensorName); |
| | 674 | | - | } |
| | 675 | | - | else if (type.ToLower().Equals("audio")) |
| | 676 | | - | _sensorDataManager.assignSensors(new Microphone(), sensorName); |
| | 677 | | - | else if (type.ToLower().Equals("tag")) |
| | 678 | | - | { |
| | 679 | | - | SimpleElement prompt = child.ChildElements.Item("prompt"); |
| | 680 | | - | SimpleElement input = child.ChildElements.Item("text"); |
| | 681 | | - | |
| | 682 | | - | if (input != null) |
| | | 723 | + | } |
| | | 724 | + | else if (type.ToLower().Equals("location")) |
| 683 | 725 | | { |
  | 684 | | - | Ucla.Cens.Campaignr.Library.Sensors.TextInput text = new Ucla.Cens.Campaignr.Library.Sensors.TextInput(false); |
| | | 726 | + | Gps gps = new Gps(); |
| | | 727 | + | gps.Open(); |
| | | 728 | + | gps.LocationChanged += new LocationChangedEventHandler(LocationChanged); |
| 685 | 729 | | |
  | 686 | | - | if (prompt != null) |
| | 687 | | - | text.Prompt = prompt.Text; |
| | 688 | | - | |
| | 689 | | - | text.InputText = input.Text; |
| | 690 | | - | |
| | 691 | | - | _sensorDataManager.assignSensors(text, sensorName); |
| | | 730 | + | manager.AssignSensor(gps, sensorName); |
| 692 | 731 | | } |
  | 693 | | - | else |
| | | 732 | + | else if (type.ToLower().Equals("audio")) |
| | | 733 | + | manager.AssignSensor(new Microphone(), sensorName); |
| | | 734 | + | else if (type.ToLower().Equals("tag")) |
| 694 | 735 | | { |
  | 695 | | - | Ucla.Cens.Campaignr.Library.Sensors.Tag tag = new Ucla.Cens.Campaignr.Library.Sensors.Tag(); |
| | | 736 | + | SimpleElement prompt = child.ChildElements.Item("prompt"); |
| | | 737 | + | SimpleElement input = child.ChildElements.Item("text"); |
| 696 | 738 | | |
  | 697 | | - | if (child.Attribute("multiselect") == "false") |
| | 698 | | - | tag.Multiselect = false; |
| | | 739 | + | if (input != null) |
| | | 740 | + | { |
| | | 741 | + | Ucla.Cens.Campaignr.Library.Sensors.TextInput text = new Ucla.Cens.Campaignr.Library.Sensors.TextInput(false); |
| 699 | 742 | | |
  | 700 | | - | if (prompt != null) |
| | 701 | | - | tag.Prompt = prompt.Text; |
| | | 743 | + | if (prompt != null) |
| | | 744 | + | text.Prompt = prompt.Text; |
| 702 | 745 | | |
  | 703 | | - | input = child.ChildElements.Item("list"); |
| | | 746 | + | text.InputText = input.Text; |
| 704 | 747 | | |
  | 705 | | - | if (input == null) |
| | 706 | | - | throw new ArgumentNullException("An input (text or list) element must be specified for this sensor"); |
| | 707 | | - | |
| | 708 | | - | foreach (SimpleElement item in input.ChildElements) |
| | 709 | | - | { |
| | 710 | | - | if (item.TagName == "text") |
| | 711 | | - | tag.AddItem(item.Text); |
| | | 748 | + | manager.AssignSensor(text, sensorName); |
| 712 | 749 | | } |
  | | 750 | + | else |
| | | 751 | + | { |
| | | 752 | + | Ucla.Cens.Campaignr.Library.Sensors.Tag tag = new Ucla.Cens.Campaignr.Library.Sensors.Tag(); |
| 713 | 753 | | |
  | 714 | | - | _sensorDataManager.assignSensors(tag, sensorName); |
| | 715 | | - | } |
| | 716 | | - | } |
| | 717 | | - | else if (type.ToLower().Equals("text")) |
| | 718 | | - | { |
| | 719 | | - | Ucla.Cens.Campaignr.Library.Sensors.TextInput text = new Ucla.Cens.Campaignr.Library.Sensors.TextInput(true); |
| | | 754 | + | if (child.Attribute("multiselect") == "false") |
| | | 755 | + | tag.Multiselect = false; |
| 720 | 756 | | |
  | 721 | | - | SimpleElement input = child.ChildElements.Item("text"); |
| | | 757 | + | if (prompt != null) |
| | | 758 | + | tag.Prompt = prompt.Text; |
| 722 | 759 | | |
  | 723 | | - | if (input != null) |
| | 724 | | - | text.InputText = input.Text; |
| | | 760 | + | input = child.ChildElements.Item("list"); |
| 725 | 761 | | |
  | 726 | | - | _sensorDataManager.assignSensors(text, sensorName); |
| | 727 | | - | } |
| | 728 | | - | else if (type.ToLower().Equals("pedometer")) |
| | 729 | | - | { |
| | 730 | | - | string portName = (child.Attributes["port"] != null) ? child.Attributes["port"] : "com0"; |
| | 731 | | - | _sensorDataManager.assignSensors(new NikePedometer(portName), sensorName); |
| | 732 | | - | } |
| | 733 | | - | else if (type.ToLower().Equals("video")) |
| | 734 | | - | { |
| | 735 | | - | SimpleElement size = child.ChildElements.Item("size"); |
| | 736 | | - | SimpleElement audio = child.ChildElements.Item("audio"); |
| | | 762 | + | if (input == null) |
| | | 763 | + | throw new ArgumentNullException("An input (text or list) element must be specified for this sensor"); |
| 737 | 764 | | |
  | 738 | | - | Ucla.Cens.Campaignr.Library.Sensors.ManualCamera.Modes mode = Ucla.Cens.Campaignr.Library.Sensors.ManualCamera.Modes.VIDEO; |
| | | 765 | + | foreach (SimpleElement item in input.ChildElements) |
| | | 766 | + | { |
| | | 767 | + | if (item.TagName == "text") |
| | | 768 | + | tag.AddItem(item.Text); |
| | | 769 | + | } |
| 739 | 770 | | |
  | 740 | | - | if (audio != null) |
| | 741 | | - | mode = Ucla.Cens.Campaignr.Library.Sensors.ManualCamera.Modes.VIDEOAUDIO; |
| | | 771 | + | manager.AssignSensor(tag, sensorName); |
| | | 772 | + | } |
| | | 773 | + | } |
| | | 774 | + | else if (type.ToLower().Equals("text")) |
| | | 775 | + | { |
| | | 776 | + | Ucla.Cens.Campaignr.Library.Sensors.TextInput text = new Ucla.Cens.Campaignr.Library.Sensors.TextInput(true); |
| 742 | 777 | | |
  | 743 | | - | Ucla.Cens.Campaignr.Library.Sensors.ManualCamera camera = new Ucla.Cens.Campaignr.Library.Sensors.ManualCamera(mode); |
| | | 778 | + | SimpleElement input = child.ChildElements.Item("text"); |
| 744 | 779 | | |
  | 745 | | - | if (size != null) |
| | 746 | | - | camera.Resolution = size.Text; |
| | | 780 | + | if (input != null) |
| | | 781 | + | text.InputText = input.Text; |
| 747 | 782 | | |
  | 748 | | - | _sensorDataManager.assignSensors(camera, sensorName); |
| | 749 | | - | } |
| | 750 | | - | else if (type.ToLower().Equals("image")) |
| | 751 | | - | { |
| | 752 | | - | SimpleElement size = child.ChildElements.Item("size"); |
| | 753 | | - | SimpleElement format = child.ChildElements.Item("format"); |
| | 754 | | - | string review = child.Attribute("review"); |
| | 755 | | - | |
| | 756 | | - | if (child.ChildElements.Item("viewfinder") != null) |
| | | 783 | + | manager.AssignSensor(text, sensorName); |
| | | 784 | + | } |
| | | 785 | + | else if (type.ToLower().Equals("pedometer")) |
| 757 | 786 | | { |
  | 758 | | - | |
| | | 787 | + | string portName = (child.Attributes["port"] != null) ? child.Attributes["port"] : "com0"; |
| | | 788 | + | manager.AssignSensor(new NikePedometer(portName), sensorName); |
| | | 789 | + | } |
| | | 790 | + | else if (type.ToLower().Equals("video")) |
| | | 791 | + | { |
| | | 792 | + | SimpleElement size = child.ChildElements.Item("size"); |
| | | 793 | + | SimpleElement audio = child.ChildElements.Item("audio"); |
| 759 | 794 | | |
  | | 795 | + | Ucla.Cens.Campaignr.Library.Sensors.ManualCamera.Modes mode = Ucla.Cens.Campaignr.Library.Sensors.ManualCamera.Modes.VIDEO; |
| | | 796 | + | |
| | | 797 | + | if (audio != null) |
| | | 798 | + | mode = Ucla.Cens.Campaignr.Library.Sensors.ManualCamera.Modes.VIDEOAUDIO; |
| | | 799 | + | |
| | | 800 | + | Ucla.Cens.Campaignr.Library.Sensors.ManualCamera camera = new Ucla.Cens.Campaignr.Library.Sensors.ManualCamera(mode); |
| | | 801 | + | |
| 760 | 802 | | if (size != null) |
| | 761 | 803 | | camera.Resolution = size.Text; |
| | 762 | 804 | | |
  | 763 | | - | |
| | 764 | | - | |
| | 765 | | - | |
| | | 805 | + | manager.AssignSensor(camera, sensorName); |
| | | 806 | + | } |
| | | 807 | + | else if (type.ToLower().Equals("image")) |
| | | 808 | + | { |
| | | 809 | + | SimpleElement size = child.ChildElements.Item("size"); |
| | | 810 | + | SimpleElement format = child.ChildElements.Item("format"); |
| | | 811 | + | string review = child.Attribute("review"); |
| 766 | 812 | | |
  | 767 | | - | NativeCamera camera = new NativeCamera(); |
| | | 813 | + | if (child.ChildElements.Item("viewfinder") != null) |
| | | 814 | + | { |
| | | 815 | + | |
| 768 | 816 | | |
  | 769 | | - | |
| | 770 | | - | |
| | | 817 | + | |
| | | 818 | + | |
| 771 | 819 | | |
  | 772 | | - | if (review != null){ |
| | 773 | | - | if(review == "false") |
| | 774 | | - | camera.Review = false; |
| | 775 | | - | else |
| | 776 | | - | camera.Review = true; |
| | 777 | | - | } |
| | | 820 | + | |
| | | 821 | + | |
| | | 822 | + | |
| 778 | 823 | | |
  | 779 | | - | _sensorDataManager.assignSensors(camera, sensorName); |
| | | 824 | + | NativeCamera camera = new NativeCamera(); |
| | | 825 | + | |
| | | 826 | + | |
| | | 827 | + | |
| | | 828 | + | |
| | | 829 | + | if (review != null) |
| | | 830 | + | { |
| | | 831 | + | if (review == "false") |
| | | 832 | + | camera.Review = false; |
| | | 833 | + | else |
| | | 834 | + | camera.Review = true; |
| | | 835 | + | } |
| | | 836 | + | |
| | | 837 | + | manager.AssignSensor(camera, sensorName); |
| | | 838 | + | } |
| | | 839 | + | else |
| | | 840 | + | { |
| | | 841 | + | manager.AssignSensor(new ImageSensor(), sensorName); |
| | | 842 | + | } |
| 780 | 843 | | } |
| | 781 | 844 | | else |
| | 782 | 845 | | { |
  | 783 | | - | _sensorDataManager.assignSensors(new ImageSensor(), sensorName); |
| | 784 | | - | } |
| | 785 | | - | } |
| | 786 | | - | else |
| | 787 | | - | { |
| | 788 | | - | |
| | 789 | | - | |
| | 790 | | - | List<object> args = new List<object>(); |
| | | 846 | + | |
| | | 847 | + | |
| | | 848 | + | List<object> args = new List<object>(); |
| 791 | 849 | | |
  | 792 | | - | foreach (string key in child.Attributes.Keys) |
| | 793 | | - | { |
| | 794 | | - | if (key != "type") |
| | | 850 | + | foreach (string key in child.Attributes.Keys) |
| 795 | 851 | | { |
  | 796 | | - | args.Add(child.Attributes[key]); |
| | | 852 | + | if (key != "type") |
| | | 853 | + | { |
| | | 854 | + | args.Add(child.Attributes[key]); |
| | | 855 | + | } |
| 797 | 856 | | } |
  | 798 | | - | } |
| | 799 | | - | args.Add(DatabaseManager.MessageQueue); |
| | | 857 | + | args.Add(DatabaseManager.MessageQueue); |
| 800 | 858 | | |
  | 801 | | - | Sensor sensor = LookupSensor(type, args.ToArray()); |
| | | 859 | + | Sensor sensor = LookupSensor(type, args.ToArray()); |
| 802 | 860 | | |
  | 803 | | - | if (sensor == null) |
| | 804 | | - | DatabaseManager.MessageQueue.PostItem(new Message("Sensor not supported (" + type + ")", MessageType.Warning)); |
| | 805 | | - | else |
| | 806 | | - | _sensorDataManager.assignSensors(sensor, sensorName); |
| | | 861 | + | if (sensor == null) |
| | | 862 | + | DatabaseManager.MessageQueue.PostItem(new Message("Sensor not supported (" + type + ")", MessageType.Warning)); |
| | | 863 | + | else |
| | | 864 | + | manager.AssignSensor(sensor, sensorName); |
| | | 865 | + | } |
| | | 866 | + | |
| 807 | 867 | | } |
  | 808 | | - | |
| | | 868 | + | catch (Exception ex) |
| | | 869 | + | { |
| | | 870 | + | |
| | | 871 | + | |
| | | 872 | + | DatabaseManager.MessageQueue.PostItem(new Message("Sensor module failed (" + type + ", " + ex.Message + ")", MessageType.Warning)); |
| | | 873 | + | } |
| 809 | 874 | | } |
  | 810 | | - | catch (Exception ex) |
| | 811 | | - | { |
| | 812 | | - | |
| | 813 | | - | |
| | 814 | | - | DatabaseManager.MessageQueue.PostItem(new Message("Sensor module failed (" + type + ", " + ex.Message + ")", MessageType.Warning)); |
| | 815 | | - | } |
| | 816 | | - | } |
| | 817 | | - | } |
| | 818 | | - | else if (name.ToLower().Equals("upload")) |
| | 819 | | - | { |
| | 820 | | - | String dest = child.Attribute("dest"); |
| | 821 | | - | String uploadType = child.Attribute("type"); |
| | 822 | | - | |
| | 823 | | - | switch (uploadType) |
| | | 875 | + | } |
| | | 876 | + | else if (name.ToLower().Equals("upload")) |
| 824 | 877 | | { |
  | 825 | | - | |
| | 826 | | - | |
| | 827 | | - | case "sensorbase.org": |
| | 828 | | - | _uploadManager = new WebUploadManager(); |
| | 829 | | - | _uploadManager.UploadType = UploadManager.UploadTypes.SensorBase; |
| | 830 | | - | _uploadServer = _uploadManager.Module.ServerUri; |
| | | 878 | + | String dest = child.Attribute("dest"); |
| | | 879 | + | String uploadType = child.Attribute("type"); |
| 831 | 880 | | |
  | 832 | | - | Sensorbase sensorbase = (Sensorbase)_uploadManager.Module; |
| | | 881 | + | UploadManager uploadManager; |
| 833 | 882 | | |
  | 834 | | - | SimpleElements uploadElements = child.ChildElements; |
| | 835 | | - | SimpleElement sensorBaseProjectElement = uploadElements.Item("project"); |
| | 836 | | - | string sensorBaseProjectID = sensorBaseProjectElement.Attributes["id"]; |
| | | 883 | + | switch (uploadType) |
| | | 884 | + | { |
| | | 885 | + | |
| | | 886 | + | |
| | | 887 | + | case "sensorbase.org": |
| | | 888 | + | uploadManager = new WebUploadManager(); |
| | | 889 | + | uploadManager.UploadType = UploadManager.UploadTypes.SensorBase; |
| 837 | 890 | | |
  | 838 | | - | SimpleElement tableElement = (sensorBaseProjectElement.ChildElements).Item("table"); |
| | 839 | | - | string tableName = tableElement.Attributes["name"]; |
| | | 891 | + | Sensorbase sensorbase = (Sensorbase)uploadManager.Module; |
| 840 | 892 | | |
  | 841 | | - | sensorbase.ProjectID = sensorBaseProjectID; |
| | 842 | | - | sensorbase.TableName = tableName; |
| | | 893 | + | SimpleElements uploadElements = child.ChildElements; |
| | | 894 | + | SimpleElement sensorBaseProjectElement = uploadElements.Item("project"); |
| | | 895 | + | string sensorBaseProjectID = sensorBaseProjectElement.Attributes["id"]; |
| 843 | 896 | | |
  | 844 | | - | |
| | 845 | | - | SimpleElements selements = (SimpleElements)tableElement.ChildElements; |
| | 846 | | - | for (int sectr = 0; sectr < selements.Count; sectr++) |
| | 847 | | - | { |
| | 848 | | - | SimpleElement field = selements.Item(sectr); |
| | 849 | | - | string fieldName = ""; |
| | 850 | | - | string sensorName = ""; |
| | 851 | | - | fieldName = field.Attributes["name"]; |
| | 852 | | - | sensorName = field.Attributes["sensor"]; |
| | | 897 | + | SimpleElement tableElement = (sensorBaseProjectElement.ChildElements).Item("table"); |
| | | 898 | + | string tableName = tableElement.Attributes["name"]; |
| 853 | 899 | | |
  | 854 | | - | sensorbase.AddRecord(fieldName, sensorName); |
| | 855 | | - | } |
| | 856 | | - | break; |
| | 857 | | - | case "flickr": |
| | 858 | | - | _uploadManager = new FlickrUploadManager(); |
| | 859 | | - | _uploadServer = _uploadManager.Module.ServerUri; |
| | | 900 | + | sensorbase.ProjectID = sensorBaseProjectID; |
| | | 901 | + | sensorbase.TableName = tableName; |
| 860 | 902 | | |
  | 861 | | - | FlickrUploadManager manager = (FlickrUploadManager)_uploadManager; |
| | 862 | | - | |
| | 863 | | - | |
| | 864 | | - | string token = ConfigurationManager.AppSettings["FlickrToken"]; |
| | | 903 | + | |
| | | 904 | + | SimpleElements selements = (SimpleElements)tableElement.ChildElements; |
| | | 905 | + | for (int sectr = 0; sectr < selements.Count; sectr++) |
| | | 906 | + | { |
| | | 907 | + | SimpleElement field = selements.Item(sectr); |
| | | 908 | + | string fieldName = ""; |
| | | 909 | + | string sensorName = ""; |
| | | 910 | + | fieldName = field.Attributes["name"]; |
| | | 911 | + | sensorName = field.Attributes["sensor"]; |
| 865 | 912 | | |
  | 866 | | - | if (token != null) |
| | 867 | | - | manager.FlickrToken = token; |
| | | 913 | + | sensorbase.AddRecord(fieldName, sensorName); |
| | | 914 | + | } |
| | | 915 | + | break; |
| | | 916 | + | case "flickr": |
| | | 917 | + | uploadManager = new FlickrUploadManager(); |
| 868 | 918 | | |
  | 869 | | - | if (!manager.IsAuthenticated) |
| | 870 | | - | { |
| | 871 | | - | string url = manager.GetLoginUrl(); |
| | | 919 | + | FlickrUploadManager flickrUploadManager = (FlickrUploadManager)uploadManager; |
| 872 | 920 | | |
  | 873 | | - | MessageBox.Show("You have not yet authenticated Campaignr to add pictures to your Flickr account. We will now redirect you to the Flicker website so you can login and approve Campaignr.", "Flickr Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); |
| | | 921 | + | |
| | | 922 | + | string token = ConfigurationManager.AppSettings["FlickrToken"]; |
| 874 | 923 | | |
  | 875 | | - | WebForm web = new WebForm(); |
| | 876 | | - | web.Url = url; |
| | 877 | | - | web.ShowDialog(); |
| | | 924 | + | if (token != null) |
| | | 925 | + | flickrUploadManager.FlickrToken = token; |
| 878 | 926 | | |
  | 879 | | - | if (!manager.Authenticate()) |
| | | 927 | + | if (!flickrUploadManager.IsAuthenticated) |
| 880 | 928 | | { |
  | 881 | | - | throw new Exception("Failed to authenticate with Flickr"); |
| | | 929 | + | string url = flickrUploadManager.GetLoginUrl(); |
| | | 930 | + | |
| | | 931 | + | MessageBox.Show("You have not yet authenticated Campaignr to add pictures to your Flickr account. We will now redirect you to the Flicker website so you can login and approve Campaignr.", "Flickr Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); |
| | | 932 | + | |
| | | 933 | + | WebForm web = new WebForm(); |
| | | 934 | + | web.Url = url; |
| | | 935 | + | web.ShowDialog(); |
| | | 936 | + | |
| | | 937 | + | if (!flickrUploadManager.Authenticate()) |
| | | 938 | + | { |
| | | 939 | + | throw new Exception("Failed to authenticate with Flickr"); |
| | | 940 | + | } |
| | | 941 | + | else |
| | | 942 | + | { |
| | | 943 | + | ConfigurationManager.AppSettings["FlickrToken"] = flickrUploadManager.FlickrToken; |
| | | 944 | + | ConfigurationManager.Save(); |
| | | 945 | + | } |
| 882 | 946 | | } |
| | 883 | 947 | | else |
| | 884 | 948 | | { |
  | 885 | | - | ConfigurationManager.AppSettings["FlickrToken"] = manager.FlickrToken; |
| | 886 | | - | ConfigurationManager.Save(); |
| | | 949 | + | |
| | | 950 | + | DatabaseManager.MessageQueue.PostItem(new Message("Authenticated with Flickr", MessageType.Information)); |
| 887 | 951 | | } |
  | 888 | | - | } |
| | 889 | | - | else |
| | 890 | | - | { |
| | 891 | | - | |
| | 892 | | - | DatabaseManager.MessageQueue.PostItem(new Message("Authenticated with Flickr", MessageType.Information)); |
| | 893 | | - | } |
| | 894 | | - | |
| | 895 | | - | break; |
| | 896 | | - | case "twitter": |
| | 897 | | - | GenericLogin login = new GenericLogin(); |
| | 898 | | - | login.Text = "Twitter Login"; |
| 899 | 952 | | |
  | 900 | | - | _uploadManager = new TwitterUploadManager(); |
| | 901 | | - | _uploadServer = _uploadManager.Module.ServerUri; |
| | | 953 | + | break; |
| | | 954 | + | case "twitter": |
| | | 955 | + | GenericLogin login = new GenericLogin(); |
| | | 956 | + | login.Text = "Twitter Login"; |
| 902 | 957 | | |
  | 903 | | - | TwitterUploadManager twitter = (TwitterUploadManager) _uploadManager; |
| | | 958 | + | uploadManager = new TwitterUploadManager(); |
| 904 | 959 | | |
  | 905 | | - | bool loginOk = false; |
| | | 960 | + | TwitterUploadManager twitterUploadManager = (TwitterUploadManager)uploadManager; |
| 906 | 961 | | |
  | 907 | | - | while (login.ShowDialog() == DialogResult.OK) |
| | 908 | | - | { |
| | 909 | | - | if (twitter.Authenticate(login.Username, login.Password)) |
| | | 962 | + | bool loginOk = false; |
| | | 963 | + | |
| | | 964 | + | while (login.ShowDialog() == DialogResult.OK) |
| 910 | 965 | | { |
  | 911 | | - | loginOk = true; |
| | 912 | | - | break; |
| | | 966 | + | if (twitterUploadManager.Authenticate(login.Username, login.Password)) |
| | | 967 | + | { |
| | | 968 | + | loginOk = true; |
| | | 969 | + | break; |
| | | 970 | + | } |
| | | 971 | + | else |
| | | 972 | + | { |
| | | 973 | + | login.LoginFailed(); |
| | | 974 | + | } |
| 913 | 975 | | } |
  | 914 | | - | else |
| | | 976 | + | |
| | | 977 | + | if (!loginOk) |
| 915 | 978 | | { |
  | 916 | | - | login.LoginFailed(); |
| | | 979 | + | DatabaseManager.MessageQueue.PostItem(new Message("No username and password was entered. Unable to upload to Twitter.", MessageType.Warning)); |
| 917 | 980 | | } |
  | 918 | | - | } |
| | 919 | | - | |
| | 920 | | - | if(!loginOk) |
| | 921 | | - | { |
| | 922 | | - | DatabaseManager.MessageQueue.PostItem(new Message("No username and password was entered. Unable to upload to Twitter.", MessageType.Warning)); |
| | 923 | | - | } |
| 924 | 981 | | |
  | 925 | | - | break; |
| | 926 | | - | |
| | 927 | | - | case "perff": |
| | 928 | | - | default: |
| | 929 | | - | _uploadManager = new WebUploadManager(); |
| | 930 | | - | _uploadManager.UploadType = UploadManager.UploadTypes.Perff; |
| | 931 | | - | _uploadServer = _uploadManager.Module.ServerUri; |
| | | 982 | + | break; |
| | | 983 | + | |
| | | 984 | + | case "perff": |
| | | 985 | + | default: |
| | | 986 | + | uploadManager = new WebUploadManager(); |
| | | 987 | + | uploadManager.UploadType = UploadManager.UploadTypes.Perff; |
| | | 988 | + | |
| | | 989 | + | break; |
| | | 990 | + | } |
| 932 | 991 | | |
  | 933 | | - | break; |
| | 934 | | - | } |
| | | 992 | + | if (uploadManager != null) |
| | | 993 | + | { |
| | | 994 | + | if (dest == null) |
| | | 995 | + | uploadManager.Server = uploadManager.Module.ServerUri; |
| | | 996 | + | else |
| | | 997 | + | uploadManager.Server = dest; |
| 935 | 998 | | |
  | 936 | | - | if (dest != null) |
| | 937 | | - | _uploadServer = dest; |
| | 938 | | - | } |
| | 939 | | - | else if (name.ToLower().Equals("interval")) |
| | 940 | | - | { |
| | 941 | | - | if (child.Text.Length > 0) |
| | 942 | | - | { |
| | 943 | | - | try |
| | | 999 | + | uploadManager.SensorDataManager = manager; |
| | | 1000 | + | |
| | | 1001 | + | manager.UploadManager = uploadManager; |
| | | 1002 | + | } |
| | | 1003 | + | else |
| 944 | 1004 | | { |
  | 945 | | - | _uploadManager.UploadInterval = System.Convert.ToInt32(child.Text) * 1000; |
| | | 1005 | + | throw new Exception("Upload end-point was not defined or invalid."); |
| 946 | 1006 | | } |
  | 947 | | - | catch (Exception) |
| | | 1007 | + | |
| | | 1008 | + | } |
| | | 1009 | + | else if (name.ToLower().Equals("interval")) |
| | | 1010 | + | { |
| | | 1011 | + | if (child.Text.Length > 0) |
| 948 | 1012 | | { |
  | | 1013 | + | try |
| | | 1014 | + | { |
| | | 1015 | + | manager.UploadManager.UploadInterval = System.Convert.ToInt32(child.Text) * 1000; |
| | | 1016 | + | } |
| | | 1017 | + | catch (Exception) |
| | | 1018 | + | { |
| 949 | 1019 | | |
  | | 1020 | + | } |
| 950 | 1021 | | } |
| | 951 | 1022 | | } |
  | 952 | | - | } |
| | 953 | | - | else if (name.ToLower().Equals("pipeline")) |
| | 954 | | - | { |
| | 955 | | - | string type = child.Attributes["type"]; |
| | 956 | | - | |
| | 957 | | - | if (type.ToLower().Equals("caloriemeter")) |
| | | 1023 | + | else if (name.ToLower().Equals("pipeline")) |
| 958 | 1024 | | { |
  | 959 | | - | int weight = 0; |
| | | 1025 | + | string type = child.Attributes["type"]; |
| 960 | 1026 | | |
  | 961 | | - | if (child.Attribute("weight") != null) |
| | 962 | | - | weight = int.Parse(child.Attribute("weight")); |
| | | 1027 | + | if (type.ToLower().Equals("caloriemeter")) |
| | | 1028 | + | { |
| | | 1029 | + | int weight = 0; |
| 963 | 1030 | | |
  | 964 | | - | _sensorDataManager.addPipeline(new Ucla.Cens.Campaignr.Library.Pipelines.CalorieMeter(weight)); |
| | | 1031 | + | if (child.Attribute("weight") != null) |
| | | 1032 | + | weight = int.Parse(child.Attribute("weight")); |
| | | 1033 | + | |
| | | 1034 | + | manager.AddPipeline(new Ucla.Cens.Campaignr.Library.Pipelines.CalorieMeter(weight)); |
| | | 1035 | + | } |
| 965 | 1036 | | } |
| | 966 | 1037 | | } |
| | 967 | 1038 | | } |
| |
|
|
 |
… |
| 971 | 1042 | | } |
| | 972 | 1043 | | catch (Exception e) |
| | 973 | 1044 | | { |
  | 974 | | - | string msg = "Error loading " + xmlcfgfilename + ", using default configuration, " + e.Message; |
| | | 1045 | + | string msg = "Error loading " + filename + ", using default configuration, " + e.Message; |
| 975 | 1046 | | |
| | 976 | 1047 | | status.Text = msg + "\r\n" + status.Text; |
| | 977 | 1048 | | } |
| | 978 | 1049 | | |
  | 979 | | - | _sensorDataManager.UploadManager = _uploadManager; |
| | | 1050 | + | |
| 980 | 1051 | | } |
| | 981 | 1052 | | |
| | 982 | 1053 | | private Sensor LookupSensor(string assemblyName, object[] args) |
| |
|
|
 |
… |
| 1023 | 1094 | | try |
| | 1024 | 1095 | | { |
| | 1025 | 1096 | | string dirname = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); |
  | 1026 | | - | |
| 1027 | 1097 | | |
| | 1028 | 1098 | | |
| | 1029 | 1099 | | |
  | 1030 | | - | |
| 1031 | 1100 | | if (Directory.Exists(dirname + "\\Configurations")) |
| | 1032 | 1101 | | { |
| | 1033 | 1102 | | bool manualLoad = false; |
| |
|
|
 |
… |
| 1105 | 1174 | | fileChooser.Close(); |
| | 1106 | 1175 | | |
| | 1107 | 1176 | | fileToLoad = fileChooser.File; |
  | 1108 | | - | readXMLConfig(dirname + "\\Configurations\\" + fileToLoad); |
| | | 1177 | + | ParseXMLConfiguration(fileToLoad, dirname + "\\Configurations\\"); |
| 1109 | 1178 | | } |
| | 1110 | 1179 | | else |
| | 1111 | 1180 | | { |
| |
|
|
 |
… |
| 1116 | 1185 | | } |
| | 1117 | 1186 | | else |
| | 1118 | 1187 | | { |
  | 1119 | | - | readXMLConfig(dirname + "\\Configurations\\" + fileToLoad); |
| | | 1188 | + | ParseXMLConfiguration(fileToLoad, dirname + "\\Configurations\\"); |
| 1120 | 1189 | | } |
| | 1121 | 1190 | | } |
| | 1122 | 1191 | | } |
| |
|
|
 |
… |
| 1126 | 1195 | | return; |
| | 1127 | 1196 | | } |
| | 1128 | 1197 | | |
  | 1129 | | - | progressBar1.Value += 10; |
| | | 1198 | + | progressBar1.Value += Math.Min((progressBar1.Maximum - progressBar1.Value), 10); |
| 1130 | 1199 | | |
  | 1131 | | - | _uploadManager.Server = _uploadServer; |
| | 1132 | | - | |
| | 1133 | | - | |
| | 1134 | | - | if (_manualCapture == false) |
| | | 1200 | + | if(manualSensorDataManagers.Count > 0) |
| 1135 | 1201 | | { |
  | 1136 | | - | _sensorDataManager.CollectInterval = uploadInterval; |
| | 1137 | | - | } |
| | 1138 | | - | else |
| | 1139 | | - | { |
| 1140 | 1202 | | |
| | 1141 | 1203 | | this.KeyPress += new KeyPressEventHandler(MainForm_KeyPress); |
| | 1142 | 1204 | | } |
| |
|
|
 |
… |
| 1151 | 1213 | | } |
| | 1152 | 1214 | | else if (_uploadOnStart) |
| | 1153 | 1215 | | { |
  | 1154 | | - | if (_manualCapture) |
| | | 1216 | + | if (manualSensorDataManagers.Count > 0) |
| 1155 | 1217 | | { |
  | 1156 | | - | |
| | 1157 | | - | _uploadManager.StartUpload(); |
| | | 1218 | + | |
| | | 1219 | + | foreach(SensorDataManager manager in manualSensorDataManagers) |
| | | 1220 | + | manager.StartUpload(); |
| | | 1221 | + | |
| 1158 | 1222 | | startMonitor(); |
| | 1159 | 1223 | | } |
  | 1160 | | - | else |
| | | 1224 | + | |
| | | 1225 | + | if (automaticSensorDataManagers.Count > 0) |
| | | 1226 | + | { |
| 1161 | 1227 | | this.Mode = OperationModes.Upload; |
  | | 1228 | + | } |
| 1162 | 1229 | | } |
| | 1163 | 1230 | | |
| | 1164 | 1231 | | progressBar1.Value = 100; |
| |
|
|
 |
… |
| 1171 | 1238 | | { |
| | 1172 | 1239 | | _graphicalInterface = new GraphicalInterface(); |
| | 1173 | 1240 | | _graphicalInterface.ParentWindow = this; |
  | 1174 | | - | _graphicalInterface.ManualMode = _manualCapture; |
| | | 1241 | + | _graphicalInterface.ManualMode = (manualSensorDataManagers.Count > 0) ? true : false; |
| 1175 | 1242 | | _graphicalInterface.Running = _uploadOnStart; |
| | 1176 | 1243 | | _graphicalInterface.CampaignrName = _campaignname; |
| | 1177 | 1244 | | |
| |
|
|
 |
… |
| 1186 | 1253 | | if (sender == null || e.KeyChar == 13) |
| | 1187 | 1254 | | { |
| | 1188 | 1255 | | DatabaseManager.MessageQueue.PostItem(new Message("Packaging data for transmission", MessageType.Status)); |
  | 1189 | | - | _sensorDataManager.Collect(true, false); |
| | | 1256 | + | |
| | | 1257 | + | foreach (SensorDataManager manager in manualSensorDataManagers) |
| | | 1258 | + | manager.Collect(true, false); |
  | 1190 | 1259 | | } |
| | 1191 | 1260 | | } |
| | 1192 | 1261 | | |