Exemplo n.º 1
0
        //send discuss
        private void button1_Click(object sender, EventArgs e)
        {
            string discuss_;

            //get all information from database
            alarmTableStructImpl = mySQLClass.getAlarmTableContent(alarmDatabaseName, gVariable.alarmListTableName, alarmID);

            discuss_ = alarmTableStructImpl.discuss + gVariable.userAccount + " (" + DateTime.Now.ToString() + "):" + textBox3.Text + editorLineFeed;

            SetAlarmDataOnScreen(null, null, null, null, gVariable.ALARM_STATUS_UNCHANGED, null, discuss_, null);

            textBox3.Text = "";

            tellCounterpartAlarmUpdated(alarmDatabaseName, alarmID);
        }
Exemplo n.º 2
0
        private void detailsForm_Load(object sender, EventArgs e)
        {
            string statusStr;
            string typeStr;

            try
            {
                alarmTableStructImpl = mySQLClass.getAlarmTableContent(databaseName, tableName, id);

                textBox1.Text  = "【报警单号】:" + alarmTableStructImpl.alarmFailureCode + lineFeed;
                textBox1.Text += "【报警工单】:" + alarmTableStructImpl.dispatchCode + lineFeed;
                textBox1.Text += "【报警设备】:" + alarmTableStructImpl.machineCode + "(" + alarmTableStructImpl.machineName + ")" + lineFeed;

                if (alarmTableStructImpl.status < gVariable.strAlarmStatus.Length)
                {
                    statusStr = gVariable.strAlarmStatus[alarmTableStructImpl.status];
                }
                else
                {
                    statusStr = gVariable.strAlarmStatus[0];
                }

                if (alarmTableStructImpl.type == gVariable.ALARM_TYPE_DEVICE)
                {
                    typeStr        = gVariable.strAlarmTypeInDetail[gVariable.ALARM_TYPE_DEVICE];
                    textBox1.Text += "【报警原因】:" + alarmTableStructImpl.errorDesc + lineFeed;
                }
                else if (alarmTableStructImpl.type == gVariable.ALARM_TYPE_MATERIAL)
                {
                    typeStr        = gVariable.strAlarmTypeInDetail[gVariable.ALARM_TYPE_MATERIAL];
                    textBox1.Text += "【物料批次】:" + alarmTableStructImpl.errorDesc + lineFeed;
                }
                else if (alarmTableStructImpl.type == gVariable.ALARM_TYPE_QUALITY_DATA)
                {
                    typeStr        = gVariable.strAlarmTypeInDetail[gVariable.ALARM_TYPE_QUALITY_DATA];
                    textBox1.Text += "【报警原因】:" + alarmTableStructImpl.errorDesc + lineFeed;
                }
                else if (alarmTableStructImpl.type == gVariable.ALARM_TYPE_CRAFT_DATA)
                {
                    typeStr        = gVariable.strAlarmTypeInDetail[gVariable.ALARM_TYPE_CRAFT_DATA];
                    textBox1.Text += "【报警原因】:" + alarmTableStructImpl.errorDesc + lineFeed;
                }
                else if (alarmTableStructImpl.type == gVariable.ALARM_TYPE_CURRENT_VALUE)
                {
                    typeStr        = gVariable.strAlarmTypeInDetail[gVariable.ALARM_TYPE_CURRENT_VALUE];
                    textBox1.Text += "【报警原因】:" + alarmTableStructImpl.errorDesc + lineFeed;
                }
                else
                {
                    typeStr = "报警类型未知";
                }
                textBox1.Text += "【报警员工】:" + alarmTableStructImpl.operatorName + lineFeed;
                textBox1.Text += "【报警时间】:" + alarmTableStructImpl.time + lineFeed;
                textBox1.Text += "【报警类型】:" + typeStr + lineFeed;
                textBox1.Text += "【报警状态】:" + statusStr;

                textBox5.Text = alarmTableStructImpl.operatorName + " 于 " + alarmTableStructImpl.time + " " + "开启安灯报警" + lineFeed;

                if (alarmTableStructImpl.signer.Length > 2)
                {
                    textBox5.Text += alarmTableStructImpl.signer + " 于 " + alarmTableStructImpl.time1 + "报警签到" + lineFeed;
                }

                if (alarmTableStructImpl.status == gVariable.ALARM_STATUS_COMPLETED)
                {
                    textBox5.Text += alarmTableStructImpl.completer + " 于 " + alarmTableStructImpl.time2 + " 确认报警处理完成" + lineFeed;
                }
                else if (alarmTableStructImpl.status == gVariable.ALARM_STATUS_CANCELLED)
                {
                    textBox5.Text += alarmTableStructImpl.completer + " 于 " + alarmTableStructImpl.time2 + " 确认报警取消" + lineFeed;
                }

                textBox2.Text = alarmTableStructImpl.discuss;
                textBox4.Text = alarmTableStructImpl.solution;
            }
            catch (Exception ex)
            {
                Console.WriteLine("deviceAlarm_Load exception occurred!" + ex);
            }
        }
Exemplo n.º 3
0
        private void displayAlarmListView()
        {
            int i, j;
            //int ret;
            //int two_char_len = 48;
            //int three_char_len = 60;
            //int five_char_len = 85;
            //int eight_char_len = 103;
            //int ten_char_len = 113;
            //int twelve_char_len = 192;
            int        startIndex, endIndex;
            string     statusStr;
            List <int> idList;

            int[] dispatchLenArray = { 48, 113, 85, 79, 97, 192, 80, 125, 60, 60, 125, 60, 125 };

            try
            {
                totalAlarmNum    = getRecordNumbyConditions(dateTimePicker1.Value.ToString("yyyy-MM-dd 00:00:00"), dateTimePicker2.Value.ToString("yyyy-MM-dd 23:59:59"));
                numOfPagesInList = totalAlarmNum / alarmNumInOnePage[gVariable.resolutionLevel] + 1;

                if (currentPageIndex >= numOfPagesInList)
                {
                    currentPageIndex = 0;
                }

                if (currentPageIndex < numOfPagesInList - 1)
                {
                    numOfAlarmInThisPage = alarmNumInOnePage[gVariable.resolutionLevel];
                }
                else
                {
                    numOfAlarmInThisPage = totalAlarmNum % alarmNumInOnePage[gVariable.resolutionLevel];
                }

                label8.Text = "页 (共" + numOfPagesInList.ToString() + "页)";
                label9.Text = (currentPageIndex + 1).ToString();

                this.listView1.Clear();
                this.listView1.BeginUpdate();
                listView1.GridLines = true;
                listView1.Dock      = DockStyle.Fill;

                //used to increase the height of one line of the listview
                this.listView1.SmallImageList = imageList1;

                i = 0;
                j = 0;

                this.Text   = gVariable.programTitle + "安灯报警列表";
                label1.Text = gVariable.enterpriseTitle + "安灯报警列表";

                listView1.Columns.Add(" ", 0, HorizontalAlignment.Center);
                listView1.Columns.Add(gConstText.deviceAlarmListTitle0, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //id
                listView1.Columns.Add(gConstText.deviceAlarmListTitle1, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //device failureNo
                listView1.Columns.Add(gConstText.deviceAlarmListTitle4, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //alarm type
                listView1.Columns.Add(gConstText.deviceAlarmListTitle2, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //device code
                listView1.Columns.Add(gConstText.deviceAlarmListTitle3, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //device name
                listView1.Columns.Add(gConstText.deviceAlarmListTitle5, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //error desc
                listView1.Columns.Add(gConstText.deviceAlarmListTitle6, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //operator
                listView1.Columns.Add(gConstText.deviceAlarmListTitle7, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //time
                listView1.Columns.Add(gConstText.deviceAlarmListTitle8, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //status
                listView1.Columns.Add(gConstText.deviceAlarmListTitle9, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center);  //signer
                listView1.Columns.Add(gConstText.deviceAlarmListTitle11, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center); //sign time
                listView1.Columns.Add(gConstText.deviceAlarmListTitle10, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center); //completer
                listView1.Columns.Add(gConstText.deviceAlarmListTitle14, (int)(dispatchLenArray[i++] * gVariable.screenRatioX), HorizontalAlignment.Center); //complete time

                startIndex = currentPageIndex * alarmNumInOnePage[gVariable.resolutionLevel];
                endIndex   = startIndex + alarmNumInOnePage[gVariable.resolutionLevel];

                idList = getRecordIndexArraybyConditions(startIndex, endIndex, dateTimePicker1.Value.ToString("yyyy-MM-dd 00:00:00"), dateTimePicker2.Value.ToString("yyyy-MM-dd 23:59:59"));
                for (i = 0; i < idList.Count; i++)
                {
                    ListViewItem OptionItem = new ListViewItem();

                    alarmTableStructImpl = mySQLClass.getAlarmTableContent(dName, tName, idList[i]); //, ref errorDesc, ref dispatchCode, ref alarmFailureCode, ref machineCode, ref machineName,
                    if (alarmTableStructImpl.dispatchCode == null)
                    {
                        break;
                    }

                    if (alarmTableStructImpl.status < gVariable.strAlarmStatus.Length)
                    {
                        statusStr = gVariable.strAlarmStatus[alarmTableStructImpl.status];
                    }
                    else
                    {
                        statusStr = gVariable.strAlarmStatus[0];
                    }

                    OptionItem.SubItems.Add((startIndex + i + 1).ToString());
                    OptionItem.SubItems.Add(alarmTableStructImpl.alarmFailureCode);

                    if (alarmTableStructImpl.type >= gVariable.ALARM_TYPE_TOTAL_NUM - 1)  //type is illegal
                    {
                        alarmTableStructImpl.type = gVariable.ALARM_TYPE_DEVICE;
                    }
                    OptionItem.SubItems.Add(gVariable.strAlarmTypeInDetail[alarmTableStructImpl.type]);

                    OptionItem.SubItems.Add(alarmTableStructImpl.machineCode);
                    OptionItem.SubItems.Add(alarmTableStructImpl.machineName);
                    OptionItem.SubItems.Add(alarmTableStructImpl.errorDesc);
                    OptionItem.SubItems.Add(alarmTableStructImpl.operatorName);
                    OptionItem.SubItems.Add(alarmTableStructImpl.time);
                    OptionItem.SubItems.Add(statusStr);
                    OptionItem.SubItems.Add(alarmTableStructImpl.signer);
                    OptionItem.SubItems.Add(alarmTableStructImpl.time1);
                    OptionItem.SubItems.Add(alarmTableStructImpl.completer);
                    OptionItem.SubItems.Add(alarmTableStructImpl.time2);

                    listView1.Items.Add(OptionItem);

                    alarmIDArray[j]     = idList[i];                                  //put alarm id in alarm table in array
                    alarmStatusArray[j] = alarmTableStructImpl.status;                //put alarm status in alarm table in array

                    alarmFailureCodeArray[j] = alarmTableStructImpl.alarmFailureCode; //record alarm failure number in buffer, so we can get this alarm
                    alarmMachineCodeArray[j] = alarmTableStructImpl.machineCode;
                    j++;

                    if (j >= alarmNumInOnePage[gVariable.resolutionLevel])
                    {
                        break;
                    }
                }

                this.listView1.EndUpdate();
            }
            catch (Exception ex)
            {
                Console.WriteLine("deviceAlarm_Load exception occurred!" + ex);
            }
        }
Exemplo n.º 4
0
        private void emulateHoverFunc()
        {
            int effective;
            int k, n, v;
//            int len, num;
            int    id;
            int    index;
            int    machineIndex;
            string str;
            string databaseName;
            int    type = 0;

            int timeV1, timeV2;

            string statusStr = null;
            Point  ms        = Control.MousePosition;

            effective = 0;

            if (mouseX != ms.X || mouseY != ms.Y)  //the mouse is still moving, not in hovering mode
            {
                mouseX = ms.X;
                mouseY = ms.Y;
                return;
            }

            try
            {
                if (ms.Y < 31)
                {
                    return;
                }

                machineIndex = 0;
                ms.Y        -= 30; //height[resIndex] for the title bar of this screen, that is out side of the mouse position
                databaseName = null;

//                Console.WriteLine(DateTime.Now.ToString() + ":got hover info, ms.X = " + ms.X + "; ms.Y = " + ms.Y);

//                i = 0;
                for (n = 0; n < machineCodeZihua.Length; n++)
                {
                    if (machineCodeZihua[n].Remove(0, 1) == "000")
                    {
                        continue;
                    }

                    machineIndex = Convert.ToInt16(machineCodeZihua[n].Remove(0, 1)) - 1;

                    databaseName = machineCodeZihua[n];

                    if (ms.X >= start_x[resIndex] && ms.X <= start_x[resIndex] + width[resIndex] && ms.Y >= start_y[resIndex] + n * (gap_y[resIndex] + height[resIndex]) && ms.Y <= start_y[resIndex] + n * (gap_y[resIndex] + height[resIndex]) + height[resIndex])
                    {
                        effective = 1;
                        break;
                    }
                }

                if (effective == 0)
                {
                    return;
                }

                v = ms.X - start_x[resIndex];  //the minute value of the time frame appointed by the user, or how long will this status keep on
                if (v < 0 || v >= (1440 / gVariable.onePointstandForHowManyMinutes))
                {
                    return;
                }

//                Console.WriteLine(DateTime.Now.ToString() + ":info into position");

                timeV1 = toolClass.ConvertDateTimeInt(DateTime.Now.Date);
                timeV2 = timeV1 + 3600 * 24;
                //get machine status for one day by minutes
                mySQLClass.readMachineStatusForOneDay(databaseName, gVariable.machineStatusRecordTableName, timeV1, timeV2);

                type  = gVariable.currentStatusForOneDay[v];
                index = gVariable.dispatchAlarmIDForOneDay[machineIndex, v];

                switch (type)
                {
                case gVariable.MACHINE_STATUS_DOWN:
                    k = (toolClass.ConvertDateTimeInt(DateTime.Now) - toolClass.ConvertDateTimeInt(DateTime.Now.Date)) / 60;

                    if (k < v)
                    {
                        toolTip1.SetToolTip(this, "时间未到,设备状态未知");
                    }
                    else
                    {
                        toolTip1.SetToolTip(this, "设备处于停机状态");
                    }
                    break;

                case gVariable.MACHINE_STATUS_IDLE:
                case gVariable.MACHINE_STATUS_STARTED:
                    str = getTooltipData(databaseName, v, index);
                    toolTip1.SetToolTip(this, str);
                    break;

                case gVariable.MACHINE_STATUS_MATERIAL_ALARM:
                case gVariable.MACHINE_STATUS_DEVICE_ALARM:
                case gVariable.MACHINE_STATUS_DATA_ALARM:
                    id = gVariable.dispatchAlarmIDForOneDay[n, v];
                    alarmTableStructImpl = mySQLClass.getAlarmTableContent(databaseName, gVariable.alarmListTableName, id);

                    if (alarmTableStructImpl.status < gVariable.strAlarmStatus.Length)
                    {
                        statusStr = gVariable.strAlarmStatus[alarmTableStructImpl.status];
                    }
                    else
                    {
                        statusStr = gVariable.strAlarmStatus[0];
                    }

                    type = alarmTableStructImpl.type;
                    if (type == gVariable.ALARM_TYPE_DEVICE)
                    {
                        toolTip1.SetToolTip(this, "设备处于设备报警状态\n\r派工单编号:" + alarmTableStructImpl.dispatchCode + "\r\n操作员:" + alarmTableStructImpl.operatorName + "\n\r报警原因:" + alarmTableStructImpl.errorDesc + "\r\n报警时间:" +
                                            alarmTableStructImpl.time + "\r\n报警状态:" + statusStr);
                    }
                    else if (type == gVariable.ALARM_TYPE_MATERIAL)
                    {
                        toolTip1.SetToolTip(this, "设备处于物料报警状态\n\r派工单编号:" + alarmTableStructImpl.dispatchCode + "\r\n操作员:" + alarmTableStructImpl.operatorName + "\n\r缺料批次:" + alarmTableStructImpl.errorDesc + "\r\n报警时间:" +
                                            alarmTableStructImpl.time + "\r\n报警状态:" + statusStr);
                    }
                    else      //if (type == gVariable.ALARM_TYPE_QUALITY/CRAFT_DATA)
                    {
                        toolTip1.SetToolTip(this, "设备处于数据报警状态\n\r派工单编号:" + alarmTableStructImpl.dispatchCode + "\r\n操作员:" + alarmTableStructImpl.operatorName + "\n\r报警原因:" + alarmTableStructImpl.errorDesc + "\r\n报警时间:" +
                                            alarmTableStructImpl.time + "\r\n报警状态:" + statusStr);
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("failed in hover function:" + ex);
            }
        }
Exemplo n.º 5
0
        //display an alarm on screen
        //idOfAlarm means the index for this alarm in current machine's alarm table
        public SetAlarmClass(string databaseName, gVariable.alarmTableStruct alarmTableStructImpl, int alarmID_)
        {
            try
            {
                InitializeComponent();

                this.Icon = new Icon(gVariable.logoInTitleArray[gVariable.CompanyIndex]);
//                this.TopMost = true;

                alarmID = alarmID_;

                closeAlarmTimer();

                alarmDatabaseName  = databaseName;
                alarmListTableName = gVariable.alarmListTableName;

                boardIndex = toolClass.getBoardIndexByDatabaseName(alarmDatabaseName);

                dispatchCode     = alarmTableStructImpl.dispatchCode;
                machineCode      = alarmTableStructImpl.machineCode;
                errorDesc        = alarmTableStructImpl.errorDesc;
                alarmFailureCode = alarmTableStructImpl.alarmFailureCode;
                machineName      = alarmTableStructImpl.machineName;
                operatorName     = alarmTableStructImpl.operatorName;
                workshop         = alarmTableStructImpl.workshop;
                category         = alarmTableStructImpl.category;
                time             = alarmTableStructImpl.time;
                type             = alarmTableStructImpl.type;
                status           = alarmTableStructImpl.status;
                indexInTable     = alarmTableStructImpl.indexInTable;
                mailList         = alarmTableStructImpl.mailList;
                discuss          = alarmTableStructImpl.discuss;
                solution         = alarmTableStructImpl.solution;

                if (type == gVariable.ALARM_TYPE_DEVICE)
                {
                    this.Text        = workshop + "设备" + machineCode + "发出设备安灯报警指令";
                    button12.Visible = false;
                }
                else if (type == gVariable.ALARM_TYPE_MATERIAL)
                {
                    this.Text        = workshop + "设备" + machineCode + "发出物料报警指令";
                    button10.Visible = false;
                    button11.Visible = false;
                    button12.Visible = false;
                }
                else if (type == gVariable.ALARM_TYPE_QUALITY_DATA)
                {
                    this.Text = workshop + "设备" + machineCode + "发出质量数据报警指令";
                }
                else if (type == gVariable.ALARM_TYPE_CRAFT_DATA)
                {
                    this.Text = workshop + "设备" + machineCode + "发出工艺参数报警指令";
                }

                mailList = gVariable.basicmailListAlarm;

                SetAlarmDataForEmail();

                textBox1.Text = setAlarmText(LINE_EDITOR_MODE);
                textBox2.Text = discuss;
                textBox4.Text = solution;

                if (gVariable.thisIsHostPC != true)
                {
                    gVariable.clientalarmStatus = status;
                    gVariable.clientMailList    = mailList;
                    gVariable.clientDiscussInfo = discuss;
                }

                if (status == gVariable.ALARM_STATUS_COMPLETED || status == gVariable.ALARM_STATUS_CANCELLED)
                {
                    button3.Visible = false;
                    button7.Visible = false;

                    button1.Enabled = false;
                    button2.Enabled = false;
                    button8.Enabled = false;
                    button9.Enabled = false;
                }
                else
                {
                    //no one can close an alarm before it is completed or cancelled
//                    button6.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                Console.Write("new alarm class failed!" + ex);
            }
        }