schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using XCommon;
using XCore;
using XImagingXhandler.XDAL;
using DataEntity;
using DriverLib.Engine;
namespace XCore
{
    public class ShakerBll
    {
        #region 生成振动方向集合
        public List<ShakerDirection> GenerateShakerDirection()
        {
            List<ShakerDirection> shakerDirections= new List<ShakerDirection>();
            ShakerDirection shakerDirection= new ShakerDirection();
            shakerDirection.shakerdirection_id = "1";
            shakerDirection.shakerdirection_name = "顺时针";
            shakerDirections.Add(shakerDirection);
 
            shakerDirection = new ShakerDirection();
            shakerDirection.shakerdirection_id = "2";
            shakerDirection.shakerdirection_name = "逆时针";
            shakerDirections.Add(shakerDirection);
 
            return shakerDirections; 
        }
        #endregion
 
        string strCurrentCulture = "";
        WellCalc wellCalc = new WellCalc();
        LatticeBll latticeBll = new LatticeBll();
 
        public ShakerBll()
        {
            strCurrentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
        }
 
        public MethodShake GenerateMethodShakeDataByXmlNode(XmlNode xmlNode)
        {
            MethodShake methodShake = new MethodShake();
 
            methodShake.isrun = xmlNode.SelectSingleNode("isrun").InnerText;
            methodShake.status = xmlNode.SelectSingleNode("status").InnerText;
            methodShake.name = xmlNode.SelectSingleNode("name").InnerText;
            methodShake.label = xmlNode.SelectSingleNode("label").InnerText;
            methodShake.strIndex = xmlNode.SelectSingleNode("strIndex").InnerText;
            methodShake.modeVal = Convert.ToInt32(xmlNode.SelectSingleNode("modeVal").InnerText);
            methodShake.shakeSpeed = Convert.ToDouble(xmlNode.SelectSingleNode("shakeSpeed").InnerText);
            methodShake.shakeDuringTime = Convert.ToInt32(xmlNode.SelectSingleNode("shakeDuringTime").InnerText);
            methodShake.shakeMoveSpeed = Convert.ToDouble(xmlNode.SelectSingleNode("shakeMoveSpeed").InnerText);
            methodShake.shakeMoveAngle = Convert.ToDouble(xmlNode.SelectSingleNode("shakeMoveAngle").InnerText);
            return methodShake;
        }
 
        public HxResult ExecuteShake(MethodShake methodShake, bool isSimulator = false)
        {
            HxResult ret = new HxResult();
            if (!isSimulator)
            {
                if (methodShake.modeVal == 0)
                {
                    ret = MethodAction.Instance.Shake((float)methodShake.shakeSpeed,(float)methodShake.shakeDuringTime);
                }
                else
                {
                    ret = MethodAction.Instance.ShakerMove((float)methodShake.shakeMoveAngle, Convert.ToInt32(methodShake.shakeMoveSpeed));
                }
            }
            else
            {
                CommonBll.DoSimulateDelay();
                ret.Result = ResultType.Success;
            }
 
            return ret;
        }
    }
}