コード例 #1
0
ファイル: AddAction.cs プロジェクト: willwhitehead94/SCIPA
        public AddAction(Models.Rule rule)
        {
            //Initialise
            InitializeComponent();
            _rule = rule;

            //If Action already created, load the info.
            _action = rule.Action;

            //If Communicator already created, load the info.
            if (_action != null)
            {
                var controller = new CommunicatorController();
                _comm = controller.GetAllCommunicators().FirstOrDefault(c => c.Id == rule.Action.CommunicatorId);
            }
        }
コード例 #2
0
ファイル: DataBoard.cs プロジェクト: willwhitehead94/SCIPA
        private void DataBoard_Load(object sender, EventArgs e)
        {
            add_cbCommType.DataSource = Enum.GetValues(typeof (Models.CommunicatorType));
            add_cbValueType.DataSource = Enum.GetValues(typeof (Models.ValueType));
            add_cbDatabaseType.DataSource = Enum.GetValues(typeof (Models.DatabaseType));
            add_cbComPort.DataSource = SerialPort.GetPortNames();
            add_cbRuleCheckValue.DataSource = Enum.GetValues(typeof (Models.ValueType));
            //add_cbRuleType.DataSource = Enum.GetValues(typeof (Models.RuleType));

            //Adds known rules for the device to the list box.
            var controller = new RuleController();
            add_cbRule.Items.Clear();
            foreach (Models.Rule rule in controller.RetrieveRulesForDevice(_device.Id)) add_cbRule.Items.Add(rule);

            //Adds outbound comms to the Action list box.
            var commController = new CommunicatorController();
            add_cbCommunicatorDestination.Items.Clear();
            List<Communicator> allComms = commController.GetAllCommunicators().Where(c => c.Device.Id == _device.Id && c.Inbound == false).ToList();
            add_cbCommunicatorDestination.Items.AddRange(allComms.ToArray());
        }
コード例 #3
0
        /// <summary>
        /// Returns a list of Communicator objects for the given Device via the
        /// parametised Device ID.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IEnumerable<Communicator> GetCommunicatorsForDevice(int id)
        {
            CommunicatorController commCont = new CommunicatorController();

            return commCont.GetAllCommunicators().Where(comm=>comm.Id==id);
        }
コード例 #4
0
ファイル: Dashboard.cs プロジェクト: willwhitehead94/SCIPA
        private void modrules_bSetAction_Click(object sender, EventArgs e)
        {
            //Save the Rule as it stands.
            modrules_tSave.PerformClick();

            var controller = new ActionController();
            if (controller.RetrieveActionsForRule(_rule.Id).Any())
            {
                //Get the actual Action.
                var action = controller.RetrieveActionsForRule(_rule.Id).FirstOrDefault();
                _action = action;

                //Load the values required.
                modact_cEnabled.Checked = action.Enabled;
                modact_tValue.Text = action.OutputValue;
                modact_tRule.Text = _rule.ToString();

                //Download the required communicator
                var commController = new CommunicatorController();
                var comm = commController.GetAllCommunicators().FirstOrDefault(c => c.Id == action.CommunicatorId);

                if (comm != null)
                {
                    _communicator = comm;
                    _action.Communicator = comm;
                    modact_tComm.Text = comm.ToString();
                }
                else
                {
                    modact_tComm.Text = "";
                }

                //Actions exist.
                pTabPanel.SelectedTab = pModifyActions;
            }
            else
            {
                var db = new DataBoard(_communicator,_selectedDevice);
                db.GoToActionPage(_rule);
                db.ShowDialog();

                _action = db.GetAction();
                DebugOutput.Print("Changes made in the Data Manager are saved.");
            }

        }
コード例 #5
0
ファイル: Dashboard.cs プロジェクト: willwhitehead94/SCIPA
        private void modify_bComms_Click(object sender, EventArgs e)
        {
            try
            {
                //Loads the relevant communicators.
                var controller = new CommunicatorController();
                modcomms_lbComms.Items.Clear();
                modcomms_lbComms.Items.AddRange(
                    controller.GetAllCommunicators().Where(c => c.Device.Id == _selectedDevice.Id).ToArray());

                if (modcomms_lbComms.Items.Count > 0)
                {
                    //Select the first element
                    modcomms_lbComms.SelectedItem = modcomms_lbComms.Items[0];

                    //Shows the modify tab.
                    pTabPanel.SelectedTab = pModifyCommunicators;
                }
                else
                {
                    var msg =
                        System.Windows.Forms.MessageBox.Show(
                            "There are no Communicators for this Device.", "No Communicators Available",
                            MessageBoxButtons.OK, MessageBoxIcon.Hand);

                    // -------- Create new communicator ----------

                    //Create and display the DataBoard form.
                    var window = new DataBoard(null, _selectedDevice);
                    window.GoToCommunicatorPage();
                    window.ShowDialog();

                    //Get the Comm object created.
                    _communicator = window.GetCommunicator();
                }
            }
            catch (Exception ex)
            {
                DebugOutput.Print("Could not load/store/update information for selected Device", ex.Message);
            }
        }
コード例 #6
0
ファイル: Dashboard.cs プロジェクト: willwhitehead94/SCIPA
        private void start_bStart_Click(object sender, EventArgs e)
        {
            try
            {
                var controller = new CommunicatorController();
                var commList = controller.GetAllCommunicators().Where(comm => comm.Device.Id == _selectedDevice.Id);

                foreach (var comm in commList)
                    new Inbound(comm);

                //Once started, stops allowing a second start.
                start_bStart.Enabled = false;
            }
            catch
            {
                DebugOutput.Print("Unable to start the selected device!");
            }

        }
コード例 #7
0
ファイル: RuleChecker.cs プロジェクト: willwhitehead94/SCIPA
        private void WriteData(Rule rule, Value value)
        {
            var controller = new CommunicatorController();
            var comm = controller.GetAllCommunicators().FirstOrDefault(com => com.Id == rule.Action.CommunicatorId);

            if (comm == null) return;

            DataHandler handler = null;

            switch (comm.Type)
            {
                case CommunicatorType.FlatFile:
                    handler = new FlatFileHandler((FileCommunicator)comm,rule,value);
                    break;
                case CommunicatorType.Serial:
                    handler = new SerialDataHandler((SerialCommunicator)comm,rule,value);
                    break;
                case CommunicatorType.Database:
                    handler = new DatabaseHandler((DatabaseCommunicator)comm,rule,value);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
コード例 #8
0
ファイル: LogTest.cs プロジェクト: willwhitehead94/SCIPA
        private void button6_Click(object sender, EventArgs e)
        {
            var cont = new CommunicatorController();

            CommunicatorModifier cm = new CommunicatorModifier(cont.GetAllCommunicators().First());
            cm.Show();
        }