Пример #1
0
 private void btnMsgDisplay_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         byte id;
         if (!byte.TryParse(tbMsgId.Text, out id) || id == 0)
         {
             throw new Exception("Illegal Message ID");
         }
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         lock (ctrl)
         {
             rpl = ctrl.SignDisplayMessage(1, id);
         }
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             throw new Exception(rpl.status.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #2
0
 private void btnReqEnabledPlans_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         lock (ctrl)
         {
             rpl = ctrl.RequestEnabledPlans();
         }
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             throw new Exception(rpl.status.ToString());
         }
         if (ctrl.EnabledPlans.Count == 0)
         {
             tbEnabledPlans.Text = "No enabled plan";
         }
         else
         {
             StringBuilder s = new StringBuilder();
             foreach (var v in ctrl.EnabledPlans)
             {
                 s.AppendLine(String.Format("Group ID = {0}, Plan ID = {1}", v.groupId, v.planId));
             }
             tbEnabledPlans.Text = s.ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #3
0
        private void DoWork_Handler(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker     worker = sender as BackgroundWorker;
            ControllerReply      rpl;
            RemoteControllerLink _ctrl = (RemoteControllerLink)e.Argument;

            while (true)
            {
                lock (_ctrl)
                {
                    rpl = _ctrl.HeartbeatPoll();
                    if (rpl.status == ControllerReply.Status.SUCCESS)
                    {
                        byte id = _ctrl.Ssr.signStatusEntry[0].frameId;
                        if (id != 0 && _ctrl.Frames[id] == null)
                        {
                            rpl = _ctrl.SignRequestStoredFrm(id);
                        }
                        if (rpl.status == ControllerReply.Status.SUCCESS)
                        {
                            worker.ReportProgress(id);
                        }
                    }
                }
                for (int i = 0; i < 10; i++)
                {
                    if (worker.CancellationPending)
                    {
                        return;
                    }
                    Thread.Sleep(100);
                }
            }
        }
Пример #4
0
        public SignWindow(RemoteControllerLink ctrl, Button s)
        {
            InitializeComponent();
            this.ctrl = ctrl;
            this.s    = s;
            if (ctrl.Scr != null)
            {
                X = ctrl.Scr.groupConfigs[0].signConfigs[0].width;
                Y = ctrl.Scr.groupConfigs[0].signConfigs[0].height;
            }
            else if (ctrl.Sesr != null)
            {
                X = ctrl.Sesr.signExtendedStatusEntry[0].columns;
                Y = ctrl.Sesr.signExtendedStatusEntry[0].rows;
            }
            else
            {
                throw new Exception("Can't get sign width & height");
            }
            virtualSign = new VirtualSign(SignArea, X, Y);

            bgWorker = new BackgroundWorker();
            bgWorker.WorkerReportsProgress      = true;
            bgWorker.WorkerSupportsCancellation = true;
            bgWorker.DoWork          += DoWork_Handler;
            bgWorker.ProgressChanged += ProgressChanged_Handler;
            //bgWorker.RunWorkerCompleted += RunWorkerCompleted_Handler;
            bgWorker.RunWorkerAsync(ctrl);
            s.IsEnabled = false;
        }
Пример #5
0
        private void SetFrameToCtrller(SignSetTextFrame f, byte frmId, byte frmRev)
        {
            f.frameId  = frmId;
            f.frameRev = frmRev;
            if (cbFrmColour.SelectedIndex < 0 || cbFrmColour.SelectedIndex > 9)
            {
                throw new Exception("Illegal colour");
            }
            f.colour = (FrameColour)Enum.Parse(typeof(FrameColour), cbFrmColour.SelectedValue.ToString());
            f.cd     = (ConspicuityDevices)Enum.Parse(typeof(ConspicuityDevices), cbFrmConspicuity.SelectedValue.ToString());
            f.font   = (ITS_FONT_SIZE)Enum.Parse(typeof(ITS_FONT_SIZE), cbFrmFont.SelectedValue.ToString());



            // todo : font width
            RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
            ControllerReply      rpl;

            lock (ctrl)
            {
                rpl = ctrl.SignSetTextFrame(f);
            }
            if (rpl.status != ControllerReply.Status.SUCCESS)
            {
                MessageBox.Show(rpl.status.ToString());
            }
        }
Пример #6
0
 private void btnPlanGetFromCtrller_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         byte id;
         if (!byte.TryParse(tbPlanId.Text, out id) || id == 0)
         {
             throw new Exception("Illegal Plan ID");
         }
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         rpl = ctrl.SignRequestStoredPlan(id);
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             throw new Exception(rpl.status.ToString());
         }
         SignSetPlan plan = ctrl.Plans[id];
         tbPlanRev.Text = plan.planRev.ToString();
         for (int d = 0; d < 7; d++)
         {
             tabPlanWeekdays[d].IsChecked = (plan.dayOfWeek & (1 << d)) != 0;
         }
         for (int i = 0; i < 6; i++)
         {
             if (i < plan.planSubsq.Count)
             {
                 tabPlanF_M_Mode[i].SelectedIndex = plan.planSubsq[i].peType - 1;
                 tabPlanF_M_Id[i].Text            = plan.planSubsq[i].frmmsgId.ToString();
                 tabPlanStart[i].Text             = plan.planSubsq[i].startHour + ":" + plan.planSubsq[i].startMinute.ToString("D2");
                 tabPlanStop[i].Text = plan.planSubsq[i].stopHour + ":" + plan.planSubsq[i].stopMinute.ToString("D2");
             }
             else
             {
                 tabPlanF_M_Mode[i].SelectedIndex = -1;
                 tabPlanF_M_Id[i].Text            = null;
                 tabPlanStart[i].Text             = null;
                 tabPlanStop[i].Text = null;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #7
0
        private void btnFrmDisplayFrame_Click(object sender, RoutedEventArgs e)
        {
            byte frmId = 1;

            if (!byte.TryParse(tbFrmFrameId.Text, out frmId) || frmId == 0)
            {
                MessageBox.Show("Illegal Frame ID");
                return;
            }
            RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
            ControllerReply      rpl;

            rpl = ctrl.SignDisplayFrame(1, frmId);
            if (rpl.status != ControllerReply.Status.SUCCESS)
            {
                MessageBox.Show(rpl.status.ToString());
            }
        }
Пример #8
0
 private void SetFrameToCtrller(SignSetHighResolutionGraphicsFrame f, byte frmId, byte frmRev)
 {
     try
     {
         f.frameId  = frmId;
         f.frameRev = frmRev;
         if (cbFrmColour.SelectedIndex < 0 || cbFrmColour.SelectedIndex > 11)
         {
             throw new Exception("Illegal colour");
         }
         if (pixelHeight > 65535 || pixelWidth > 65535)
         {
             throw new Exception("Can't fit in Graphics Frame");
         }
         f.colour  = (FrameColour)Enum.Parse(typeof(FrameColour), cbFrmColour.SelectedValue.ToString());
         f.cd      = (ConspicuityDevices)Enum.Parse(typeof(ConspicuityDevices), cbFrmConspicuity.SelectedValue.ToString());
         f.columns = (ushort)pixelWidth;
         f.rows    = (ushort)pixelHeight;
         f.pixels  = new int[pixelWidth, pixelHeight];
         for (int x = 0; x < pixelWidth; x++)
         {
             for (int y = 0; y < pixelHeight; y++)
             {
                 f.pixels[x, y] = treatedPixels[x, y].R * 0x10000 +
                                  treatedPixels[x, y].G * 0x100 +
                                  treatedPixels[x, y].B;
             }
         }
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         lock (ctrl)
         {
             rpl = ctrl.SignSetHighResolutionGraphicsFrame(f);
         }
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             throw new Exception(rpl.status.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #9
0
 private void btnFrmGetFromCtrller_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         byte frmId = 1;
         if (!byte.TryParse(tbFrmFrameId.Text, out frmId) || frmId == 0)
         {
             throw new Exception("Illegal Frame ID");
         }
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         rpl = ctrl.SignRequestStoredFrm(frmId);
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             throw new Exception(rpl.status.ToString());
         }
         if ((ctrl.Frames[frmId] is SignSetTextFrame))
         {
             LoadFrame((ctrl.Frames[frmId] as SignSetTextFrame));
             return;
         }
         else if ((ctrl.Frames[frmId] is SignSetGraphicsFrame))
         {
             LoadFrame((ctrl.Frames[frmId] as SignSetGraphicsFrame));
         }
         else if ((ctrl.Frames[frmId] is SignSetHighResolutionGraphicsFrame))
         {
             LoadFrame((ctrl.Frames[frmId] as SignSetHighResolutionGraphicsFrame));
             return;
         }
         else
         {
             throw new Exception("Illegal frame type from controller");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #10
0
 private void btnMsgGetFromCtrller_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         byte id;
         if (!byte.TryParse(tbMsgId.Text, out id) || id == 0)
         {
             throw new Exception("Illegal Message ID");
         }
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         rpl = ctrl.SignRequestStoredMsg(id);
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             MessageBox.Show(rpl.status.ToString());
             return;
         }
         SignSetMessage msg = ctrl.Messages[id];
         tbMsgRev.Text       = msg.msgRev.ToString();
         tbMsgTransTime.Text = msg.transitionTime.ToString();
         for (int i = 0; i < 6; i++)
         {
             if (i < msg.msgFrame.Count)
             {
                 tabMsgFrmId[i].Text     = msg.msgFrame[i].frameId.ToString();
                 tabMsgFrmOnTime[i].Text = msg.msgFrame[i].frameTime.ToString();
             }
             else
             {
                 tabMsgFrmId[i].Text     = null;
                 tabMsgFrmOnTime[i].Text = null;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #11
0
 private void btnEnDisPlan(object sender, RoutedEventArgs e)
 {
     try
     {
         byte id;
         if (!byte.TryParse(tbPlanId.Text, out id) || id == 0)
         {
             throw new Exception("Illegal Plan ID");
         }
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         lock (ctrl)
         {
             if (sender == btnPlanDisable)
             {
                 rpl = ctrl.DisablePlan(1, id);
             }
             else if (sender == btnPlanEnable)
             {
                 rpl = ctrl.EnablePlan(1, id);
             }
             else
             {
                 throw new Exception("EnDisPlan ???");
             }
         }
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             throw new Exception(rpl.status.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #12
0
 private void btnPlanFrmSetToCtrller_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         byte id = 1;
         if (!byte.TryParse(tbPlanId.Text, out id) || id == 0)
         {
             throw new Exception("Illegal Plan ID");
         }
         byte rev;
         if (!byte.TryParse(tbPlanRev.Text, out rev))
         {
             throw new Exception("Illegal Plan Rev");
         }
         byte weekDays = 0;
         for (int i = 0; i < 7; i++)
         {
             if (tabPlanWeekdays[i].IsChecked == true)
             {
                 weekDays |= (byte)(1 << i);
             }
         }
         if (weekDays == 0)
         {
             throw new Exception("Week days error");
         }
         SignSetPlan plan = new SignSetPlan();
         plan.dayOfWeek = weekDays;
         plan.planId    = id;
         plan.planRev   = rev;
         plan.planSubsq = new List <PlanEntry>();
         for (int i = 0; i < 6; i++)
         {
             if ((tabPlanF_M_Mode[i].SelectedIndex == 0 || tabPlanF_M_Mode[i].SelectedIndex == 1) &&
                 tabPlanF_M_Id[i].Text.Length > 0 && tabPlanStart[i].Text.Length > 0 && tabPlanStop[i].Text.Length > 0)
             {
                 PlanEntry entry = new PlanEntry();
                 hh_mm(tabPlanStart[i].Text, out entry.startHour, out entry.startMinute);
                 hh_mm(tabPlanStop[i].Text, out entry.stopHour, out entry.stopMinute);
                 entry.peType   = (byte)(tabPlanF_M_Mode[i].SelectedIndex + 1);
                 entry.frmmsgId = byte.Parse(tabPlanF_M_Id[i].Text);
                 plan.planSubsq.Add(entry);
             }
             else if (tabPlanF_M_Mode[i].SelectedIndex == -1 && tabPlanF_M_Id[i].Text.Length == 0 &&
                      tabPlanStart[i].Text.Length == 0 && tabPlanStop[i].Text.Length == 0)
             {
                 if (i == 0)
                 {
                     throw new Exception("Plan entry error");
                 }
                 break;
             }
             else
             {
                 throw new Exception("Plan entry error");
             }
         }
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         lock (ctrl)
         {
             rpl = ctrl.SignSetPlan(plan);
         }
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             MessageBox.Show(rpl.status.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #13
0
 private void btnMsgFrmSetToCtrller_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         byte id = 1;
         if (!byte.TryParse(tbMsgId.Text, out id) || id == 0)
         {
             throw new Exception("Illegal Message ID");
         }
         byte rev;
         if (!byte.TryParse(tbMsgRev.Text, out rev))
         {
             throw new Exception("Illegal Message Rev");
         }
         byte tt;
         if (!byte.TryParse(tbMsgTransTime.Text, out tt))
         {
             throw new Exception("Illegal Transition Time");
         }
         SignSetMessage msg = new SignSetMessage();
         msg.msgId          = id;
         msg.msgRev         = rev;
         msg.transitionTime = tt;
         msg.msgFrame       = new List <MsgFrame>();
         for (int i = 0; i < 6; i++)
         {
             byte fid, time;
             if (tabMsgFrmId[i].Text.Length > 0 && tabMsgFrmOnTime[i].Text.Length > 0)
             {
                 fid  = byte.Parse(tabMsgFrmId[i].Text);
                 time = byte.Parse(tabMsgFrmOnTime[i].Text);
                 if (fid == 0 || time == 0)
                 {
                     throw new Exception("Message entry error");
                 }
                 msg.msgFrame.Add(new MsgFrame()
                 {
                     frameId = fid, frameTime = time
                 });
             }
             else if (tabMsgFrmId[i].Text.Length == 0 && tabMsgFrmOnTime[i].Text.Length == 0)
             {
                 if (i == 0)
                 {
                     throw new Exception("Message entry error");
                 }
                 break;
             }
             else
             {
                 throw new Exception("Message entry error");
             }
         }
         RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
         ControllerReply      rpl;
         lock (ctrl)
         {
             rpl = ctrl.SignSetMessage(msg);
         }
         if (rpl.status != ControllerReply.Status.SUCCESS)
         {
             throw new Exception(rpl.status.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #14
0
        private void btnRefreshStatus_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                RemoteControllerLink ctrl = remoteConctrollerLinks[parameters.ControllerID];
                ControllerReply      rpl;
                lock (ctrl)
                {
                    /*
                     * rpl = ctrl.SignConfigurationRequest();
                     * if (rpl.status == ControllerReply.Status.SUCCESS)
                     * {
                     *  pixelWidth = ctrl.Scr.groupConfigs[0].signConfigs[0].width;
                     *  pixelHeight = ctrl.Scr.groupConfigs[0].signConfigs[0].height;
                     * }*/
                    rpl = ctrl.SignExtendedStatusRequest();
                    if (rpl.status == ControllerReply.Status.SUCCESS)
                    {
                        foreach (var s in cbFrmFrameType.Items)
                        {
                            (s as Control).IsEnabled = false;
                        }
                        switch (ctrl.Sesr.signExtendedStatusEntry[0].signType)
                        {
                        case ConstCode.SesrSignType.TEXT:
                            pixelWidth  = 0;
                            pixelHeight = 0;
                            (cbFrmFrameType.Items[0] as Control).IsEnabled = true;
                            break;

                        case ConstCode.SesrSignType.GFX:
                            pixelWidth  = ctrl.Sesr.signExtendedStatusEntry[0].columns;
                            pixelHeight = ctrl.Sesr.signExtendedStatusEntry[0].rows;
                            (cbFrmFrameType.Items[0] as Control).IsEnabled = true;
                            (cbFrmFrameType.Items[1] as Control).IsEnabled = true;
                            (cbFrmFrameType.Items[2] as Control).IsEnabled = true;
                            break;

                        case ConstCode.SesrSignType.ADVGFX:
                            pixelWidth = ctrl.Sesr.signExtendedStatusEntry[0].status[0] * 0x100 +
                                         ctrl.Sesr.signExtendedStatusEntry[0].status[1];
                            pixelHeight = ctrl.Sesr.signExtendedStatusEntry[0].status[2] * 0x100 +
                                          ctrl.Sesr.signExtendedStatusEntry[0].status[3];
                            (cbFrmFrameType.Items[0] as Control).IsEnabled = true;
                            if (pixelWidth < 256 || pixelHeight < 256)
                            {
                                (cbFrmFrameType.Items[1] as Control).IsEnabled = true;
                            }
                            (cbFrmFrameType.Items[2] as Control).IsEnabled = true;
                            break;

                        default:
                            throw new Exception("Sign Extended Status Request Got illegal sign type");
                        }
                    }
                    else
                    {
                        throw new Exception("Sign Extended Status Request:" + rpl.status.ToString());
                    }

                    /*
                     * RtaFont.SignFont font = RtaFont.GetFont(RtaFont.ITS_FONT_SIZE.FONT_DEFAULT);
                     *
                     * int nlines = (txtRows + font.line_space) / font.rows_per_cell;
                     * textLines = new TextBox[nlines];
                     * for (int i = 0; i < nlines; i++)
                     * {
                     *  textLines[i] = new TextBox();
                     *  spTxtFrmLines.Children.Add(textLines[i]);
                     * }*/
                    rpl = ctrl.HeartbeatPoll();
                    if (rpl.status != ControllerReply.Status.SUCCESS)
                    {
                        throw new Exception("Heartbeat Poll:" + rpl.status.ToString());
                    }
                }
                bmpPixels     = new System.Windows.Media.Color[pixelWidth, pixelHeight];
                treatedPixels = new System.Windows.Media.Color[pixelWidth, pixelHeight];
                canvas.Width  = pixelWidth;
                canvas.Height = pixelHeight;
                StRefreshSsr(ctrl.Ssr);
                tbStMfcCode.Text = Encoding.ASCII.GetString(ctrl.Sesr.manufacturer);
                SignExtendedStatusEntry sese = ctrl.Sesr.signExtendedStatusEntry[0];
                tbStSignType.Text    = sese.signType.ToString();
                tbSignDimension.Text = pixelWidth + "*" + pixelHeight;
                tbStDimmingMode.Text = sese.dimmingMode == 0 ? "Auto" : "Manual";
                tbStDimmingLvl.Text  = sese.dimmingLevel.ToString();
                tbStLedStatus.Text   = BitConverter.ToString(sese.status.ToArray());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }