使用 spel 将对象(从 dll 创建)传递给 C# 上的其他 class 文件

Passing object(create from dll) to other class file on C# with spel

谁能建议我如何将 class 程序传递给另一个 class 文件? 我的代码: (主窗体)

private SpelNetLib.Spel m_spel;
Robot robot = new Robot();
private void Prototype_Load(object sender, EventArgs e)
    {
        m_spel = new SpelNetLib.Spel();
        m_spel.Initialize();
        m_spel.Project = "c:\EPSONRC50\projects\TimCS\TimCS.sprj";
        m_spel.MotorsOn = true;
        m_spel.PowerHigh = true;
        m_spel.Speed(100);
    }
 private void startBt_ButtonClick(object sender, EventArgs e)
    {
       SpelPoint pt = new SpelPoint();
        pt = m_spel.GetPoint("P*");
        pt.X = (float)125.5;   
        robot.goTOPT(pos,10,5,5);
        }

机器人Class

class Robot
public void goToPt(SpelPoint point,int x,int y,int z)
{
 point.X=point.X+x;
 m_spel.Go(point); // Want to use this function direct from class
}
}

希望有人能帮忙?谢谢。

您可以通过将其作为参数传递来执行此操作:

private SpelNetLib.Spel m_spel;
Robot robot = new Robot();

private void startBt_ButtonClick(object sender, EventArgs e)
{
    SpelPoint pt = new SpelPoint();
    pt = m_spel.GetPoint("P*");
    pt.X = (float)125.5;   
    robot.goTOPT(m_spel, pos,10,5,5);
}

机器人Class

class Robot
{
    public void goToPt(SpelNetLib.Spel m_spel, SpelPoint point,int x,int y,int z)
    {
        point.X=point.X+x;
        m_spel.Go(point); 
    }
}