ningshuxia
2022-10-27 2b6eeda2c91f0e570b58b2799758475b46c1ad61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using IStation.DataDockingSocket.MsgHandle;
using IStation.Untity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.DataDockingSocket 
{
    internal class StartUpMsgHelper
    {
        public static eStartUpInstructionStatus ShutUpInstructionStatus = eStartUpInstructionStatus.未发送;
 
        /// <summary>
        /// 开机
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        public static bool StartJob(Model.IMonitorDataDockingSession session)
        {
            if (session != null)
            {
                NtLogHelper.Error($"开机 session:Close");
                return false;
            }
 
            if (session.IsConnected)
            {
                byte[] bts = GetControlMsg开机();
 
                session.Send(bts, 0, bts.Length);
                ShutUpInstructionStatus = eStartUpInstructionStatus.调频指令发送;
                NtLogHelper.Info("开机" + session.SessionName + ":" + BitTransfer.ToString(bts) + ", 发送一条请求控制指令");
 
                return true;
            }
            else
            {
                NtLogHelper.Error($"开机时 session:Not connected");
                return false;
            }
 
        }
 
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="byteMessage"></param>
        /// <returns></returns>
        public static bool IsCurrentMsg(byte[] byteMessage)
        {
            if(byteMessage.Length == 8)
            {
                if (byteMessage[0] == 0x01 && byteMessage[1] == 0x06 && byteMessage[2] == 0x00
    && byteMessage[3] == 0x0F && byteMessage[4] == 0x00 && byteMessage[5] == 0x01
    && byteMessage[6] == 0x78 && byteMessage[7] == 0x09)
                {//01-06-00-0F-00-01-78-09
                    return true;
                }
            }
      
            return false;
        }
 
        /// <summary>
        /// 获取控制指令(开机)
        /// </summary>
        /// <returns></returns>
        public static byte[] GetControlMsg开机()
        {
            //var appParas = AppParasHelper.GetInstance();
            //if (appParas == null || appParas.InstructionStartUp == null || appParas.InstructionStartUp.Content == null)
            {
                return BitTransfer.FromString("01-06-00-0F-00-01-78-09");
            }
            //return BitTransfer.FromString(appParas.InstructionStartUp.Content);
        }
 
        /// <summary>
        /// 获取控制指令(调频)
        /// </summary>
        /// <returns></returns>
        public static byte[] GetControlMsg调频(double frequece)
        {
            var iFrequece = (int)(frequece * 10);
 
            byte[] commandSend = null;
 
            ModBusRtuHelper.BuildSendMessage06(0x01, 20, 2,
                iFrequece, ref commandSend);
 
            return commandSend;
        }
 
 
 
 
 
    }
}