public Form1() { ModeCartTraining = ModeRSV2Training = false; ModeCartExecutingMetaNetwork = false; ModeCartMapping = ModeRSV2Browsing = false; ModeRsv2ExecutingMetaNetwork = false; InitializeComponent(); server = new EZRoboNetDevice(1, EZRoboNetDevice.t_Node_Station); rnd = new Random((int)DateTime.Now.Ticks); SensorDataRequested = CameraFrameRequested = false; rsv2pass = cartpass = 0; robosapien = new RobosapienV2(server, 2, rnd); cart = new LMMobileRobot(server, 3, rnd); cartTrainingFSM = new CartTrainingFSM(cart); cartMNExecutingFSM = new CartMetaNetworkFSM(cart); rsv2MNExecutingFSM = new RSV2MetanetworkFSM(robosapien); // creating mapping and browsing FSMs mappingFSM = new MappingFSM(cart, 4, MappingFSM.orSOUTH, 1, 1); rsv2BrowsingFSM = new RSV2BrowsingFSM(mappingFSM, robosapien, 0, 1, RSV2BrowsingFSM.orSOUTH); rsv2TrainingFSM = new RSV2TrainingFSM(robosapien); timer1.Start(); timer2.Start(); comboBox1.SelectedIndex = 2; comboBox2.SelectedIndex = 2; }
public EZStationPacketFSM(EZRoboNetDevice device, EZFrame frame) { // registering the Net Device NetDevice = device; // capturing time of first reception ReceptionStartTime = DateTime.Now; // acknowledging NetDevice.sendAcknowledge(PacketSenderID); // retrieving sender id PacketSenderID = frame.SenderID; // calculating total packet length ushort packetlength = (ushort)(frame.Payload[3] + 256 * frame.Payload[4] + 5); CurrentPacketLength = packetlength; // calculating total number of frames required for full packet transmission TotalFrames = packetlength / EZRoboNetDevice.MAX_FRAME_PAYLOAD_LENGTH + 1; // allocating memory space for the packet being received CurrentPacket = new byte[packetlength]; // now filling initial space in CurrentPacket int i; for (i = 0; i < frame.PayloadLength; i++) CurrentPacket[i] = frame.Payload[i]; // done copying // setting number of frames received to 1 FramesReceived = 1; // sending an acknowledgement frame NetDevice.sendAcknowledge(frame.SenderID); if (FramesReceived < TotalFrames) { // need to receive more state = EZRoboNetDevice.stReceiving; // marrking time of acknowledgement FrameReceptionStartTime = DateTime.Now; } else { state = EZRoboNetDevice.stPacketReady; FramesReceived = 0; TotalFrames = 0; } }
public RoboEntity(EZRoboNetDevice netdevice, byte avatarnodeid, Random randgen) { NetDevice = netdevice; AvatarNodeID = avatarnodeid; // assigning random generator RandGen = randgen; // initializing the timer SyncTimer = new System.Windows.Forms.Timer(); SyncTimer.Interval = 500; // 0.5 s interval SyncTimer.Tick += handleMessages; // initializing the incoming packet queue ReceivedPackets = new EZPacket[MAX_RECEIVED_PACKETS_NUM]; ReceivedPacketsNum = 0; // registering the entity to the NetDevice server EntityID = NetDevice.registerEntity(this); // starting the Timer SyncTimer.Start(); }
// constructor public LMMobileRobot(EZRoboNetDevice netdevice, byte avatarnodeid, Random randgen) : base(netdevice, avatarnodeid, randgen) { flagAbstractionDataReady = false; flagAbstractionReady = false; flagSensorDataAcquired = false; AbstractionBytes = 0; // creating the sonar array SonarArray = new ushort[8]; PrevSonarArray = new ushort[8]; // creating the cognitive array CogTop = createLMCartCognitiveArray(ref CogSonarNode, ref CogCamLinesNodes); state = stIdle; flagSonarArrayFiring = flagSonarArrayFiringDone = false; flagAbilityDone = flagAbilityExecuting = false; RawAbstraction = new byte[ABSTRACTION_FRAME_HEIGHT * ABSTRACTION_FRAME_WIDTH * 3]; }