373 for element in elements: |
374 for element in elements: |
374 element_type = GetElementType(element) |
375 element_type = GetElementType(element) |
375 element_state = " in_state_%d = %s;\n"%(element.getid(), "%s") |
376 element_state = " in_state_%d = %s;\n"%(element.getid(), "%s") |
376 element_name = element.getname() |
377 element_name = element.getname() |
377 |
378 |
378 block_infos = GetBlockType(SVGUIFB_Types[element_type]) |
|
379 if element_type == ITEM_BUTTON: |
379 if element_type == ITEM_BUTTON: |
380 text += """void Program::On%sClick(wxCommandEvent& event) |
380 text += """void Program::On%sClick(wxCommandEvent& event) |
381 { |
381 { |
382 SVGUIButton* button = (SVGUIButton*)GetElementByName(wxT("%s"));\n"""%(element_name, element_name) |
382 SVGUIButton* button = (SVGUIButton*)GetElementByName(wxT("%s"));\n"""%(element_name, element_name) |
383 text += element_state%"GUI_BUSY" |
383 text += element_state%"GUI_BUSY" |
384 for i, output in enumerate(block_infos["outputs"]): |
384 text += " _copy__IX%s_%d_1 = button->GetToggle();\n"%(current_location, element.getid()) |
385 element_type = TYPECONVERSION[output[1]] |
|
386 if i == 0: |
|
387 value = "button->IsVisible()" |
|
388 elif i == 1: |
|
389 value = "button->GetToggle()" |
|
390 else: |
|
391 value = "0" |
|
392 text += " _copy__I%s%s_%d_%d = %s;\n"%(TYPECONVERSION[output[1]], current_location, element.getid(), i + 1, value) |
|
393 text += element_state%"CHANGED" |
385 text += element_state%"CHANGED" |
394 text += " event.Skip();\n}\n\n" |
386 text += " event.Skip();\n}\n\n" |
395 elif element_type == ITEM_ROTATING: |
387 elif element_type == ITEM_ROTATING: |
396 text += """void Program::On%sChanged(wxScrollEvent& event) |
388 text += """void Program::On%sChanged(wxScrollEvent& event) |
397 { |
389 { |
398 SVGUIRotatingCtrl* rotating = (SVGUIRotatingCtrl*)GetElementByName(wxT("%s")); |
390 SVGUIRotatingCtrl* rotating = (SVGUIRotatingCtrl*)GetElementByName(wxT("%s")); |
399 rotating->SendScrollEvent(event); |
|
400 double angle = rotating->GetAngle(); |
|
401 """%(element_name, element_name) |
391 """%(element_name, element_name) |
402 text += element_state%"GUI_BUSY" |
392 text += element_state%"GUI_BUSY" |
403 for i, output in enumerate(block_infos["outputs"]): |
393 text += " _copy__ID%s_%d_1 = rotating->GetAngle();\n"%(current_location, element.getid()) |
404 text += " _copy__I%s%s_%d_%d = %s;\n"%(TYPECONVERSION[output[1]], current_location, element.getid(), i + 1, ["angle", "true"][value]) |
|
405 text += element_state%"CHANGED" |
394 text += element_state%"CHANGED" |
406 text += " event.Skip();\n}\n\n" |
395 text += " event.Skip();\n}\n\n" |
407 elif element_type == ITEM_NOTEBOOK: |
396 elif element_type == ITEM_NOTEBOOK: |
408 text += """void Program::On%sTabChanged(wxNotebookEvent& event) |
397 text += """void Program::On%sTabChanged(wxNotebookEvent& event) |
409 { |
398 { |
410 SVGUINoteBook* notebook = (SVGUINoteBook*)GetElementByName(wxT("%s")); |
399 SVGUINoteBook* notebook = (SVGUINoteBook*)GetElementByName(wxT("%s")); |
411 notebook->SendNotebookEvent(event); |
|
412 unsigned int selected = notebook->GetCurrentPage(); |
|
413 """%(element_name, element_name) |
400 """%(element_name, element_name) |
414 text += element_state%"GUI_BUSY" |
401 text += element_state%"GUI_BUSY" |
415 for i, output in enumerate(block_infos["outputs"]): |
402 text += " _copy__IB%s_%d_1 = notebook->GetCurrentPage();\n"%(current_location, element.getid()) |
416 text += " _copy__I%s%s_%d_%d = %s;\n"%(TYPECONVERSION[output[1]], current_location, element.getid(), i + 1, ["selected", "true"][value]) |
|
417 text += element_state%"CHANGED" |
403 text += element_state%"CHANGED" |
418 text += " event.Skip();\n}\n\n" |
404 text += " event.Skip();\n}\n\n" |
419 elif element_type == ITEM_TRANSFORM: |
405 elif element_type == ITEM_TRANSFORM: |
420 text += """void Program::On%sPaint(wxPaintEvent& event) |
406 text += """void Program::On%sPaint(wxPaintEvent& event) |
421 { |
407 { |
422 SVGUITransform* transform = (SVGUITransform*)GetElementByName(wxT("%s")); |
408 SVGUITransform* transform = (SVGUITransform*)GetElementByName(wxT("%s")); |
423 """%(element_name, element_name) |
409 """%(element_name, element_name) |
424 text += element_state%"GUI_BUSY" |
410 text += element_state%"GUI_BUSY" |
425 for i, output in enumerate(block_infos["outputs"]): |
411 text += " _copy__ID%s_%d_1 = transform->GetX();\n"%(current_location, element.getid()) |
426 if i < 5: |
412 text += " _copy__ID%s_%d_2 = transform->GetY();\n"%(current_location, element.getid()) |
427 texts = {"location" : current_location, "id" : element.getid(), |
|
428 "pin" : i + 1, "param" : ["X", "Y", "XScale", "YScale", "Angle"][i]} |
|
429 |
|
430 text += """ if (transform->Get%(param)s() != _copy__ID%(location)s_%(id)d_%(pin)d) |
|
431 { |
|
432 _copy__ID%(location)s_%(id)d_%(pin)d = transform->Get%(param)s(); |
|
433 _copy__IX%(location)s_%(id)d_6 = true; |
|
434 } |
|
435 """%texts |
|
436 text += element_state%"CHANGED" |
413 text += element_state%"CHANGED" |
437 text += " event.Skip();\n}\n\n" |
414 text += " event.Skip();\n}\n\n" |
438 elif element_type == ITEM_CONTAINER: |
|
439 text += """void Program::On%sPaint(wxPaintEvent& event) |
|
440 { |
|
441 SVGUIContainer* container = (SVGUIContainer*)GetElementByName(wxT("%s")); |
|
442 bool isvisible = container->IsVisible(); |
|
443 """%(element_name, element_name) |
|
444 text += element_state%"GUI_BUSY" |
|
445 texts = {"location" : current_location, "id" : element.getid()} |
|
446 |
|
447 text += """ if (isvisible != _copy__IX%(location)s_%(id)d_1) |
|
448 { |
|
449 _copy__IX%(location)s_%(id)d_1 = container->IsVisible(); |
|
450 _copy__IX%(location)s_%(id)d_2 = true; |
|
451 """%texts |
|
452 text += " %s }\n else {\n %s }\n"%(element_state%"CHANGED", element_state%"UNCHANGED") |
|
453 text += " event.Skip();\n}\n\n" |
|
454 |
|
455 |
415 |
456 text += """void Program::OnChar(wxKeyEvent& event) |
416 text += """void Program::OnChar(wxKeyEvent& event) |
457 { |
417 { |
458 SVGUIContainer* container = GetSVGUIRootElement(); |
418 SVGUIContainer* container = GetSVGUIRootElement(); |
459 if (container->GetFocusedElementName() == wxT("TextCtrl")) |
419 if (container->GetFocusedElementName() == wxT("TextCtrl")) |
503 |
463 |
504 text += " }\n event.Skip();\n}\n\n" |
464 text += " }\n event.Skip();\n}\n\n" |
505 |
465 |
506 |
466 |
507 text += "/* OnPlcOutEvent update GUI with provided IEC __Q* PLC output variables */\n" |
467 text += "/* OnPlcOutEvent update GUI with provided IEC __Q* PLC output variables */\n" |
508 text += "void Program::OnPlcOutEvent(wxEvent& event)\n{\n wxMutexGuiEnter();" |
468 text += """void Program::OnPlcOutEvent(wxEvent& event) |
|
469 { |
|
470 SVGUIElement* element; |
|
471 |
|
472 refreshing = true; |
|
473 |
|
474 wxMutexGuiEnter(); |
|
475 """ |
509 for element in elements: |
476 for element in elements: |
510 element_type = GetElementType(element) |
477 element_type = GetElementType(element) |
511 texts = {"location" : current_location, "id" : element.getid()} |
478 texts = {"location" : current_location, "id" : element.getid()} |
512 |
479 |
513 element_lock = " if (__sync_val_compare_and_swap (&out_state_%(id)d, CHANGED, GUI_BUSY) == CHANGED)\n {\n"%texts |
480 text += """ if (__sync_bool_compare_and_swap (&out_state_%(id)d, CHANGED, GUI_BUSY)) |
514 element_unlock = " __sync_val_compare_and_swap (&out_state_%(id)d, GUI_BUSY, UNCHANGED);\n }\n"%texts |
481 { |
|
482 element = (SVGUIElement*)GetElementById(wxT("%(id)d")); |
|
483 |
|
484 if (_copy__QX%(location)s_%(id)d_1 != element->IsVisible()) { |
|
485 if (_copy__QX%(location)s_%(id)d_1) |
|
486 element->Show(); |
|
487 else |
|
488 element->Hide(); |
|
489 } |
|
490 if (_copy__QX%(location)s_%(id)d_2 != element->IsEnabled()) { |
|
491 if (_copy__QX%(location)s_%(id)d_2) |
|
492 element->Enable(); |
|
493 else |
|
494 element->Disable(); |
|
495 } |
|
496 """%texts |
515 if element_type == ITEM_BUTTON: |
497 if element_type == ITEM_BUTTON: |
516 text += element_lock |
498 text += """ if (_copy__QX%(location)s_%(id)d_3 != ((SVGUIButton*)element)->GetToggle()) |
517 text += """ SVGUIButton* button = (SVGUIButton*)GetElementById(wxT("%(id)d")); |
499 ((SVGUIButton*)element)->SetToggle(_copy__QX%(location)s_%(id)d_3); |
518 //if (_copy__QX%(location)s_%(id)d_1) |
500 """%texts |
519 // button->Show(); |
501 elif element_type == ITEM_TEXT: |
520 //else |
502 text += """ if (((SVGUITextCtrl*)element)->GetValue().compare(_copy__QX%(location)s_%(id)d_3)) |
521 // button->Hide(); |
503 { |
522 if (_copy__QX%(location)s_%(id)d_2 != button->GetToggle()) { |
504 wxString str = wxString::FromAscii(_copy__QB%(location)s_%(id)d_3); |
523 button->SetToggle(_copy__QX%(location)s_%(id)d_2); |
505 ((SVGUITextCtrl*)element)->SetText(str); |
524 } |
506 } |
525 """%texts |
507 """%texts |
526 text += element_unlock |
|
527 elif element_type == ITEM_CONTAINER: |
|
528 text += element_lock |
|
529 text += """ if (_copy__QX%(location)s_%(id)d_2) |
|
530 { |
|
531 SVGUIContainer* container = (SVGUIContainer*)GetElementById(wxT("%(id)d")); |
|
532 //if (_copy__QX%(location)s_%(id)d_1) |
|
533 // container->Show(); |
|
534 //else |
|
535 // container->Hide(); |
|
536 } |
|
537 """%texts |
|
538 text += element_unlock |
|
539 elif element_type == ITEM_TEXT: |
|
540 text += element_lock |
|
541 text += """ if (_copy__QX%(location)s_%(id)d_2) |
|
542 { |
|
543 SVGUITextCtrl* text = (SVGUITextCtrl*)GetElementById(wxT("%(id)d")); |
|
544 wxString str = wxString::FromAscii(_copy__QB%(location)s_%(id)d_1); |
|
545 text->SetText(str); |
|
546 } |
|
547 """%texts |
|
548 text += element_unlock |
|
549 elif element_type == ITEM_SCROLLBAR: |
508 elif element_type == ITEM_SCROLLBAR: |
550 text += element_lock |
509 text += """ if (_copy__QW%(location)s_%(id)d_3 != ((SVGUIScrollBar*)element)->GetThumbPosition() || |
551 text += """ if (_copy__QX%(location)s_%(id)d_2) |
510 _copy__QW%(location)s_%(id)d_4 != ((SVGUIScrollBar*)element)->GetThumbSize() || |
552 { |
511 _copy__QW%(location)s_%(id)d_5 != ((SVGUIScrollBar*)element)->GetRange()) |
553 SVGUIScrollBar* scrollbar = (SVGUIScrollBar*)GetElementById(wxT("%(id)d")); |
512 ((SVGUIScrollBar*)element)->Init_ScrollBar(_copy__QW%(location)s_%(id)d_3, _copy__QW%(location)s_%(id)d_4, _copy__QW%(location)s_%(id)d_5); |
554 scrollbar->SetThumbPosition(_copy__QW%(location)s_%(id)d_1);\n" |
513 """%texts |
555 } |
|
556 """%texts |
|
557 text += element_unlock |
|
558 elif element_type == ITEM_ROTATING: |
514 elif element_type == ITEM_ROTATING: |
559 text += element_lock |
515 text += """ if (_copy__QD%(location)s_%(id)d_3 != ((SVGUIRotatingCtrl*)element)->GetAngle()) |
560 text += """ if (_copy__QX%(location)s_%(id)d_2) |
516 ((SVGUIRotatingCtrl*)element)->SetAngle(_copy__QD%(location)s_%(id)d_3); |
561 { |
517 """%texts |
562 SVGUIRotatingCtrl* rotating = (SVGUIRotatingCtrl*)GetElementById(wxT("%(id)d")); |
518 elif element_type == ITEM_NOTEBOOK: |
563 rotating->SetAngle(_copy__QD%(location)s_%(id)d_1);\n" |
519 text += """ if (_copy__QB%(location)s_%(id)d_3 != ((SVGUINoteBook*)element)->GetCurrentPage()) |
564 } |
520 ((SVGUINoteBook*)element)->SetCurrentPage(_copy__QB%(location)s_%(id)d_3); |
565 """%texts |
521 """%texts |
566 text += element_unlock |
522 elif element_type == ITEM_TRANSFORM: |
567 elif elment_type == ITEM_NOTEBOOK: |
523 text += """ if (_copy__QD%(location)s_%(id)d_3 != ((SVGUITransform*)element)->GetX() || |
568 text += element_lock |
524 copy__QD%(location)s_%(id)d_4 != ((SVGUITransform*)element)->GetY()) |
569 text += """ if (copy__QX%(location)s_%(id)d_2) |
525 transform->Move(_copy__QD%(location)s_%(id)d_3, _copy__QD%(location)s_%(id)d_4); |
570 { |
526 if (_copy__QD%(location)s_%(id)d_5 != ((SVGUITransform*)element)->GetXScale() || |
571 SVGUINoteBook* notebook = (SVGUINoteBook*)GetElementById(wxT("%(id)d")); |
527 copy__QD%(location)s_%(id)d_6 != ((SVGUITransform*)element)->GetYScale()) |
572 notebook->SetCurrentPage(_copy__QB%(location)s_%(id)d_1); |
528 transform->Scale(_copy__QD%(location)s_%(id)d_5, _copy__QD%(location)s_%(id)d_6); |
573 } |
529 if (_copy__QD%(location)s_%(id)d_7 != ((SVGUITransform*)element)->GetAngle()) |
574 """%texts |
530 transform->Rotate(_copy__QD%(location)s_%(id)d_7); |
575 text += element_unlock |
531 """%texts |
576 elif elment_type == ITEM_TRANSFORM: |
532 text += " __sync_bool_compare_and_swap (&out_state_%(id)d, GUI_BUSY, UNCHANGED);\n }\n"%texts |
577 text += element_lock |
533 |
578 text += """ if (copy__QX%(location)s_%(id)d_6) |
|
579 { |
|
580 SVGUITransform* transform = (SVGUITransform*)GetElementById(wxT("%(id)d")); |
|
581 transform->Move(_copy__QD%(location)s_%(id)d_1, _copy__QD%(location)s_%(id)d_2); |
|
582 transform->Scale(_copy__QD%(location)s_%(id)d_3, _copy__QD%(location)s_%(id)d_4); |
|
583 transform->Rotate(_copy__QD%(location)s_%(id)d_5); |
|
584 } |
|
585 """%texts |
|
586 text += element_unlock |
|
587 text += """ wxMutexGuiLeave(); |
534 text += """ wxMutexGuiLeave(); |
|
535 |
|
536 refreshing = false; |
|
537 |
588 event.Skip(); |
538 event.Skip(); |
589 } |
539 } |
590 |
540 |
591 """ |
541 """ |
592 return text |
542 return text |
651 } |
596 } |
652 } |
597 } |
653 """%texts |
598 """%texts |
654 |
599 |
655 text += """ /*Replace this with determinist signal if called from RT*/; |
600 text += """ /*Replace this with determinist signal if called from RT*/; |
656 if (refresh) { |
601 if (refresh && !refreshing) { |
657 wxCommandEvent event( EVT_PLC ); |
602 wxCommandEvent event( EVT_PLC ); |
658 ProcessEvent(event); |
603 ProcessEvent(event); |
659 } |
604 } |
660 }; |
605 }; |
661 |
606 |
662 """ |
607 """ |
663 |
608 |
664 text += "void Program::Initialize()\n{\n" |
609 text += """void Program::Initialize() |
665 button = False |
610 { |
666 container = False |
611 SVGUIElement* element; |
667 textctrl = False |
612 """ |
668 scrollbar = False |
|
669 rotatingctrl = False |
|
670 notebook = False |
|
671 transform = False |
|
672 for element in elements: |
613 for element in elements: |
673 element_type = GetElementType(element) |
614 element_type = GetElementType(element) |
674 texts = {"location" : current_location, "id" : element.getid()} |
615 texts = {"location" : current_location, "id" : element.getid()} |
675 |
616 |
|
617 text += """ |
|
618 element = (SVGUIElement*)GetElementById(wxT("%(id)d")); |
|
619 __QX%(location)s_%(id)d_1 = 1; |
|
620 _copy__QX%(location)s_%(id)d_1 = 1; |
|
621 __QX%(location)s_%(id)d_2 = 1; |
|
622 _copy__QX%(location)s_%(id)d_2 = 1; |
|
623 """%texts |
676 if element_type == ITEM_BUTTON: |
624 if element_type == ITEM_BUTTON: |
677 if (not button): |
625 text += " _copy__IX%(location)s_%(id)d_1 = ((SVGUIButton*)element)->GetToggle();\n"%texts |
678 text += " SVGUIButton* button;\n" |
|
679 text += """ button = (SVGUIButton*)GetElementById(wxT("%(id)d")); |
|
680 if (button->IsVisible()) |
|
681 _copy__IX%(location)s_%(id)d_1 = true; |
|
682 else |
|
683 _copy__IX%(location)s_%(id)d_1 = false; |
|
684 _copy__IX%(location)s_%(id)d_2 = false; |
|
685 |
|
686 """%texts |
|
687 button = True |
|
688 elif element_type == ITEM_CONTAINER: |
|
689 if (not container): |
|
690 text += " SVGUIContainer* container;\n" |
|
691 text += """ container = (SVGUIContainer*)GetElementById(wxT("%(id)d")); |
|
692 if (container->IsVisible()) |
|
693 _copy__IX%(location)s_%(id)d_1 = true; |
|
694 else |
|
695 _copy__IX%(location)s_%(id)d_1 = false; |
|
696 _copy__IX%(location)s_%(id)d_2 = true; |
|
697 |
|
698 """%texts |
|
699 container = True |
|
700 elif element_type == ITEM_TEXT: |
626 elif element_type == ITEM_TEXT: |
701 if (not textctrl): |
627 text += " _copy__IB%(location)s_%(id)d_1 = ((SVGUITextCtrl*)element)->GetValue();\n"%texts |
702 text += " SVGUITextCtrl* text;\n" |
|
703 text += """ text = (SVGUITextCtrl*)GetElementById(wxT("%(id)d")); |
|
704 _copy__IB%(location)s_%(id)d_1 = wxStringToIEC_STRING(text->GetValue()); |
|
705 _copy__IX%(location)s_%(id)d_2 = true; |
|
706 |
|
707 """%texts |
|
708 textctrl = True |
|
709 elif element_type == ITEM_SCROLLBAR: |
628 elif element_type == ITEM_SCROLLBAR: |
710 if (not scrollbar): |
629 text += " _copy__IW%(location)s_%(id)d_1 = ((SVGUIScrollBar*)element)->GetThumbPosition();\n"%texts |
711 text += " SVGUIScrollBar* scrollbar;\n" |
|
712 text += """ scrollbar = (SVGUIScrollBar*)GetElementById(wxT("%(id)d")); |
|
713 _copy__IW%(location)s_%(id)d_1 = scrollbar->GetThumbPosition(); |
|
714 _copy__IX%(location)s_%(id)d_2 = true; |
|
715 |
|
716 """%texts |
|
717 scrollbar = True |
|
718 elif element_type == ITEM_ROTATING: |
630 elif element_type == ITEM_ROTATING: |
719 if (not rotatingctrl): |
631 text += " _copy__ID%(location)s_%(id)d_1 = ((SVGUIRotatingCtrl*)element)->GetAngle();\n"%texts |
720 text += " SVGUIRotatingCtrl* rotating;\n" |
|
721 text += """ rotating = (SVGUIRotatingCtrl*)GetElementById(wxT("%(id)d")); |
|
722 _copy__ID%(location)s_%(id)d_1 = rotating->GetAngle(); |
|
723 _copy__IX%(location)s_%(id)d_2 = true; |
|
724 |
|
725 """%texts |
|
726 rotatingctrl = True |
|
727 elif element_type == ITEM_NOTEBOOK: |
632 elif element_type == ITEM_NOTEBOOK: |
728 if (not notebook): |
633 text += " _copy__IB%(location)s_%(id)d_1 = ((SVGUINoteBook*)element)->GetCurrentPage();\n"%texts |
729 text += " SVGUINoteBook* notebook;\n" |
|
730 text += """ notebook = (SVGUINoteBook*)GetElementById(wxT("%(id)d")); |
|
731 _copy__IB%(location)s_%(id)d_1 = notebook->GetCurrentPage(); |
|
732 _copy__IX%(location)s_%(id)d_2 = true; |
|
733 |
|
734 """%texts |
|
735 notebook = True |
|
736 elif element_type == ITEM_TRANSFORM: |
634 elif element_type == ITEM_TRANSFORM: |
737 if (not transform): |
635 text += " _copy__ID%(location)s_%(id)d_1 = ((SVGUITransform*)element)->GetX();\n"%texts |
738 text += " SVGUITransform* transform;\n" |
636 text += " _copy__ID%(location)s_%(id)d_2 = ((SVGUITransform*)element)->GetY();\n"%texts |
739 text += """ transform = (SVGUITransform*)GetElementById(wxT("%(id)d")); |
|
740 _copy__ID%(location)s_%(id)d_1 = transform->GetX(); |
|
741 _copy__ID%(location)s_%(id)d_2 = transform->GetY(); |
|
742 _copy__ID%(location)s_%(id)d_3 = transform->GetXScale(); |
|
743 _copy__ID%(location)s_%(id)d_4 = transform->GetYScale(); |
|
744 _copy__ID%(location)s_%(id)d_5 = transform->GetAngle(); |
|
745 _copy__IX%(location)s_%(id)d_6 = true; |
|
746 |
|
747 """%texts |
|
748 transform = True |
|
749 text += "}\n\n" |
637 text += "}\n\n" |
750 |
638 |
751 #DEBUG Fonction d'affichage |
639 #DEBUG Fonction d'affichage |
752 # fct += "void Program::Print()\n{\n" |
640 # fct += "void Program::Print()\n{\n" |
753 # for element in elementsTab: |
641 # for element in elementsTab: |
817 return "%sI%s%s.%d.%d"%("%", TYPECONVERSION[block_infos["outputs"][num][1]], current_location, block_id, num+1) |
705 return "%sI%s%s.%d.%d"%("%", TYPECONVERSION[block_infos["outputs"][num][1]], current_location, block_id, num+1) |
818 raise ValueError, "No output variable found" |
706 raise ValueError, "No output variable found" |
819 else: |
707 else: |
820 return None |
708 return None |
821 |
709 |
822 def initialise_block(type, name): |
710 def initialise_block(type, name, block = None): |
823 block_id = self.GetElementIdFromName(name) |
711 block_id = self.GetElementIdFromName(name) |
824 if block_id == None: |
712 if block_id == None: |
825 raise ValueError, "No corresponding block found" |
713 raise ValueError, "No corresponding block found" |
826 block_infos = GetBlockType(type) |
714 block_infos = GetBlockType(type) |
827 current_location = ".".join(map(str, self.GetCurrentLocation())) |
715 current_location = ".".join(map(str, self.GetCurrentLocation())) |
828 variables = [] |
716 variables = [] |
|
717 if block is not None: |
|
718 input_variables = block.inputVariables.getvariable() |
|
719 output_variables = block.outputVariables.getvariable() |
|
720 else: |
|
721 input_variables = None |
|
722 output_variables = None |
829 for num, (input_name, input_type, input_modifier) in enumerate(block_infos["inputs"]): |
723 for num, (input_name, input_type, input_modifier) in enumerate(block_infos["inputs"]): |
830 variables.append((input_type, None, "%sQ%s%s.%d.%d"%("%", TYPECONVERSION[input_type], current_location, block_id, num+1), None)) |
724 if input_variables is not None and num < len(input_variables): |
|
725 connections = input_variables[num].connectionPointIn.getconnections() |
|
726 if input_variables is None or connections and len(connections) == 1: |
|
727 variables.append((input_type, None, "%sQ%s%s.%d.%d"%("%", TYPECONVERSION[input_type], current_location, block_id, num+1), None)) |
831 for num, (output_name, output_type, output_modifier) in enumerate(block_infos["outputs"]): |
728 for num, (output_name, output_type, output_modifier) in enumerate(block_infos["outputs"]): |
832 variables.append((output_type, None, "%sI%s%s.%d.%d"%("%", TYPECONVERSION[input_type], current_location, block_id, num+1), None)) |
729 variables.append((output_type, None, "%sI%s%s.%d.%d"%("%", TYPECONVERSION[input_type], current_location, block_id, num+1), None)) |
833 return variables |
730 return variables |
834 |
731 |
835 return [{"name" : "SVGUI function blocks", "list" : |
732 return [{"name" : "SVGUI function blocks", "list" : |
836 [{"name" : "Container", "type" : "functionBlock", "extensible" : False, |
733 [{"name" : "Container", "type" : "functionBlock", "extensible" : False, |
837 "inputs" : [("Show","BOOL","none"),("SetState","BOOL","none")], |
734 "inputs" : [("Show","BOOL","none"),("Enable","BOOL","none")], |
838 "outputs" : [("Visible","BOOL","none"),("StateChanged","BOOL","none")], |
735 "outputs" : [], |
839 "comment" : "SVGUI Container", |
736 "comment" : "SVGUI Container", |
840 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
737 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
841 {"name" : "Button", "type" : "functionBlock", "extensible" : False, |
738 {"name" : "Button", "type" : "functionBlock", "extensible" : False, |
842 "inputs" : [("Show","BOOL","none"),("Toggle","BOOL","none")], |
739 "inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("Toggle","BOOL","none")], |
843 "outputs" : [("Visible","BOOL","none"),("State","BOOL","none")], |
740 "outputs" : [("State","BOOL","none")], |
844 "comment" : "SVGUI Button", |
741 "comment" : "SVGUI Button", |
845 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
742 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
846 {"name" : "TextCtrl", "type" : "functionBlock", "extensible" : False, |
743 {"name" : "TextCtrl", "type" : "functionBlock", "extensible" : False, |
847 "inputs" : [("Text","STRING","none"),("SetText","BOOL","none")], |
744 "inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetText","STRING","none")], |
848 "outputs" : [("Text","STRING","none"),("TextChanged","BOOL","none")], |
745 "outputs" : [("Text","STRING","none")], |
849 "comment" : "SVGUI Text Control", |
746 "comment" : "SVGUI Text Control", |
850 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
747 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
851 {"name" : "ScrollBar", "type" : "functionBlock", "extensible" : False, |
748 {"name" : "ScrollBar", "type" : "functionBlock", "extensible" : False, |
852 "inputs" : [("Position","UINT","none"),("SetPosition","BOOL","none")], |
749 "inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetThumb","UINT","none"),("SetRange","UINT","none"),("SetPosition","UINT","none")], |
853 "outputs" : [("Position","UINT","none"),("PositionChanged","BOOL","none")], |
750 "outputs" : [("Position","UINT","none")], |
854 "comment" : "SVGUI ScrollBar", |
751 "comment" : "SVGUI ScrollBar", |
855 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
752 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
856 {"name" : "NoteBook", "type" : "functionBlock", "extensible" : False, |
753 {"name" : "NoteBook", "type" : "functionBlock", "extensible" : False, |
857 "inputs" : [("Selected","UINT","none"),("SetSelected","BOOL","none")], |
754 "inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetSelected","BOOL","none")], |
858 "outputs" : [("Selected","UINT","none"),("SelectedChanged","BOOL","none")], |
755 "outputs" : [("Selected","UINT","none")], |
859 "comment" : "SVGUI Notebook", |
756 "comment" : "SVGUI Notebook", |
860 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
757 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
861 {"name" : "RotatingCtrl", "type" : "functionBlock", "extensible" : False, |
758 {"name" : "RotatingCtrl", "type" : "functionBlock", "extensible" : False, |
862 "inputs" : [("Angle","REAL","none"),("SetAngle","BOOL","none")], |
759 "inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetAngle","REAL","none")], |
863 "outputs" : [("Angle","REAL","none"),("AngleChanged","BOOL","none")], |
760 "outputs" : [("Angle","REAL","none")], |
864 "comment" : "SVGUI Rotating Control", |
761 "comment" : "SVGUI Rotating Control", |
865 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
762 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
866 {"name" : "Transform", "type" : "functionBlock", "extensible" : False, |
763 {"name" : "Transform", "type" : "functionBlock", "extensible" : False, |
867 "inputs" : [("X","REAL","none"),("Y","REAL","none"),("XScale","REAL","none"),("YScale","REAL","none"),("Angle","REAL","none"),("Set","BOOL","none")], |
764 "inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetX","REAL","none"),("SetY","REAL","none"),("SetXScale","REAL","none"),("SetYScale","REAL","none"),("SetAngle","REAL","none")], |
868 "outputs" : [("X","REAL","none"),("Y","REAL","none"),("XScale","REAL","none"),("YScale","REAL","none"),("Angle","REAL","none"),("Changed","BOOL","none")], |
765 "outputs" : [("X","REAL","none"),("Y","REAL","none")], |
869 "comment" : "SVGUI Transform", |
766 "comment" : "SVGUI Transform", |
870 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
767 "generate" : generate_svgui_block, "initialise" : initialise_block}, |
871 ]} |
768 ]} |
872 ] |
769 ] |
873 |
770 |